@Override
public AbstractMessageListenerContainer createListenerContainer() {
JmsConfiguration config = getConfiguration();
String replyToSelectorName = getConfiguration().getReplyToDestinationSelectorName();
AbstractMessageListenerContainer container =
config.isUseVersion102()
? (replyToSelectorName != null) ? new DefaultMessageListenerContainer102()
: new CamelDefaultMessageListenerContainer102()
: (replyToSelectorName != null) ? new DefaultMessageListenerContainer()
: new CamelDefaultMessageListenerContainer();
container.setConnectionFactory(config.getListenerConnectionFactory());
DestinationResolver resolver = config.getDestinationResolver();
if (resolver == null) {
resolver = container.getDestinationResolver();
}
container.setDestinationResolver(new DestinationResolverDelegate(resolver));
container.setDestinationName(getConfiguration().getReplyTo());
if (replyToSelectorName != null) {
replyToSelectorValue = "ID:" + new BigInteger(24 * 8, new Random()).toString(16);
container.setMessageSelector(replyToSelectorName + "='" + replyToSelectorValue + "'");
} else {
((MessageSelectorComposer)container).addCorrelationID("ID:" + new BigInteger(24 * 8, new Random()).toString(16));
}
container.setAutoStartup(true);
container.setMessageListener(this);
container.setPubSubDomain(false);
container.setSubscriptionDurable(false);
ExceptionListener exceptionListener = config.getExceptionListener();
if (exceptionListener != null) {
container.setExceptionListener(exceptionListener);
}
container.setSessionTransacted(config.isTransacted());
if (config.isTransacted()) {
container.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED);
} else {
if (config.getAcknowledgementMode() >= 0) {
container.setSessionAcknowledgeMode(config.getAcknowledgementMode());
} else if (config.getAcknowledgementModeName() != null) {
container.setSessionAcknowledgeModeName(config.getAcknowledgementModeName());
}
}
if (container instanceof DefaultMessageListenerContainer) {
DefaultMessageListenerContainer defContainer = (DefaultMessageListenerContainer)container;
defContainer.setConcurrentConsumers(1);