try
{
final Session session = _testSessions.get(command.getSessionName());
if (session == null)
{
throw new DistributedTestException("No test session found called: " + command.getSessionName(), command);
}
synchronized(session)
{
Destination destination;
MessageConsumer jmsConsumer;
if(command.isTopic())
{
Topic topic = session.createTopic(command.getDestinationName());
if(command.isDurableSubscription())
{
String subscription = "subscription-" + command.getParticipantName() + System.currentTimeMillis();
jmsConsumer = session.createDurableSubscriber(topic, subscription);
_testSubscriptions.put(subscription, session);
LOGGER.debug("created durable suscription " + subscription + " to topic " + topic);
}
else
{
jmsConsumer = session.createConsumer(topic, command.getSelector());
}
destination = topic;
}
else
{
destination = session.createQueue(command.getDestinationName());
jmsConsumer = session.createConsumer(destination, command.getSelector());
}
_testConsumers.put(command.getParticipantName(), jmsConsumer);
}
}
catch (final JMSException jmse)
{
throw new DistributedTestException("Unable to create new consumer: " + command, jmse);
}
}