use of org.springframework.jms.listener.DefaultMessageListenerContainer in project camel by apache.
the class JmsConfiguration method configureMessageListenerContainer.
protected void configureMessageListenerContainer(AbstractMessageListenerContainer container, JmsEndpoint endpoint) throws Exception {
container.setConnectionFactory(getListenerConnectionFactory());
if (endpoint instanceof DestinationEndpoint) {
container.setDestinationResolver(createDestinationResolver((DestinationEndpoint) endpoint));
} else if (destinationResolver != null) {
container.setDestinationResolver(destinationResolver);
}
container.setAutoStartup(autoStartup);
if (durableSubscriptionName != null) {
container.setDurableSubscriptionName(durableSubscriptionName);
container.setSubscriptionDurable(true);
}
if (clientId != null) {
container.setClientId(clientId);
}
if (exceptionListener != null) {
container.setExceptionListener(exceptionListener);
}
if (errorHandler != null) {
container.setErrorHandler(errorHandler);
} else {
ErrorHandler handler = new DefaultSpringErrorHandler(endpoint.getCamelContext(), EndpointMessageListener.class, getErrorHandlerLoggingLevel(), isErrorHandlerLogStackTrace());
container.setErrorHandler(handler);
}
container.setAcceptMessagesWhileStopping(acceptMessagesWhileStopping);
container.setExposeListenerSession(exposeListenerSession);
container.setSessionTransacted(transacted);
if (transacted) {
container.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED);
} else {
if (acknowledgementMode >= 0) {
container.setSessionAcknowledgeMode(acknowledgementMode);
} else if (acknowledgementModeName != null) {
container.setSessionAcknowledgeModeName(acknowledgementModeName);
}
}
if (endpoint.getSelector() != null && endpoint.getSelector().length() != 0) {
container.setMessageSelector(endpoint.getSelector());
}
if (container instanceof DefaultMessageListenerContainer) {
DefaultMessageListenerContainer listenerContainer = (DefaultMessageListenerContainer) container;
configureDefaultMessageListenerContainer(endpoint, listenerContainer);
} else if (container instanceof SimpleMessageListenerContainer) {
SimpleMessageListenerContainer listenerContainer = (SimpleMessageListenerContainer) container;
configureSimpleMessageListenerContainer(listenerContainer);
}
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project camel by apache.
the class JmsEndpointConfigurationTest method assertCacheLevel.
protected void assertCacheLevel(JmsEndpoint endpoint, int expected) throws Exception {
JmsConsumer consumer = endpoint.createConsumer(dummyProcessor);
AbstractMessageListenerContainer container = consumer.getListenerContainer();
DefaultMessageListenerContainer defaultContainer = assertIsInstanceOf(DefaultMessageListenerContainer.class, container);
int cacheLevel = defaultContainer.getCacheLevel();
assertEquals("CacheLevel", expected, cacheLevel);
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryIntegrationTests method invokeListener.
@SuppressWarnings("unchecked")
private void invokeListener(JmsListenerEndpoint endpoint, Message message) throws JMSException {
DefaultMessageListenerContainer messageListenerContainer = containerFactory.createListenerContainer(endpoint);
Object listener = messageListenerContainer.getMessageListener();
if (listener instanceof SessionAwareMessageListener) {
((SessionAwareMessageListener<Message>) listener).onMessage(message, mock(Session.class));
} else {
((MessageListener) listener).onMessage(message);
}
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryTests method createJmsContainerFullConfig.
@Test
public void createJmsContainerFullConfig() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
setDefaultJmsConfig(factory);
factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
factory.setConcurrency("3-10");
factory.setMaxMessagesPerTask(5);
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener);
endpoint.setDestination("myQueue");
DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);
assertDefaultJmsConfig(container);
assertEquals(DefaultMessageListenerContainer.CACHE_CONSUMER, container.getCacheLevel());
assertEquals(3, container.getConcurrentConsumers());
assertEquals(10, container.getMaxConcurrentConsumers());
assertEquals(5, container.getMaxMessagesPerTask());
assertEquals(messageListener, container.getMessageListener());
assertEquals("myQueue", container.getDestinationName());
}
use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-framework by spring-projects.
the class JmsListenerEndpointTests method setupJmsMessageContainerFullConfig.
@Test
public void setupJmsMessageContainerFullConfig() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setDestination("myQueue");
endpoint.setSelector("foo = 'bar'");
endpoint.setSubscription("mySubscription");
endpoint.setConcurrency("5-10");
endpoint.setMessageListener(messageListener);
endpoint.setupListenerContainer(container);
assertEquals("myQueue", container.getDestinationName());
assertEquals("foo = 'bar'", container.getMessageSelector());
assertEquals("mySubscription", container.getSubscriptionName());
assertEquals(5, container.getConcurrentConsumers());
assertEquals(10, container.getMaxConcurrentConsumers());
assertEquals(messageListener, container.getMessageListener());
}
Aggregations