use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method setInstructionListener.
public void setInstructionListener(final Client client) {
try {
_instructionQueue = _instructionListenerSession.createTemporaryQueue();
final MessageConsumer instructionConsumer = _instructionListenerSession.createConsumer(_instructionQueue);
instructionConsumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(final Message message) {
client.processInstruction(JmsMessageAdaptor.messageToCommand(message));
}
});
} catch (final JMSException jmse) {
throw new DistributedTestException("Unable to setup instruction listener", jmse);
}
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method sendRegistrationMessage.
public void sendRegistrationMessage() {
Command command;
try {
command = new RegisterClientCommand(_clientName, _instructionQueue.getQueueName());
} catch (final JMSException e) {
throw new DistributedTestException(e);
}
sendCommand(command);
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method destroy.
/**
* destroy the client. Don't call from the Dispatcher thread.
*/
public void destroy() {
try {
// Stopping the connection allows in-flight onMessage calls to
// finish.
_controllerConnection.stop();
if (_instructionListenerSession != null) {
_instructionListenerSession.close();
}
if (_controllerSession != null) {
_controllerSession.close();
}
_controllerConnection.close();
} catch (final JMSException jmse) {
throw new DistributedTestException("Unable to destroy cleanly", jmse);
}
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method consumeMessage.
public Message consumeMessage(String consumerName, long receiveInterval) {
Message consumedMessage = null;
MessageConsumer consumer = _testConsumers.get(consumerName);
try {
consumedMessage = consumer.receive(receiveInterval);
} catch (JMSException e) {
throw new DistributedTestException("Unable to consume message with consumer: " + consumerName, e);
}
return consumedMessage;
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method createSession.
public void createSession(final CreateSessionCommand command) {
try {
final Connection connection = _testConnections.get(command.getConnectionName());
if (connection == null) {
throw new DistributedTestException("No test connection found called: " + command.getConnectionName(), command);
}
final boolean transacted = command.getAcknowledgeMode() == Session.SESSION_TRANSACTED;
final Session newSession = connection.createSession(transacted, command.getAcknowledgeMode());
LOGGER.debug("Created session {} with transacted = {} and acknowledgeMode = {}", command.getSessionName(), newSession.getTransacted(), newSession.getAcknowledgeMode());
addSession(command.getSessionName(), newSession);
_testSessionToConnections.put(newSession, connection);
} catch (final JMSException jmse) {
throw new DistributedTestException("Unable to create new session: " + command, jmse);
}
}
Aggregations