Search in sources :

Example 21 with DefaultMessageListenerContainer

use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-framework by spring-projects.

the class JmsNamespaceHandlerTests method testResponseDestination.

@Test
public void testResponseDestination() {
    // JMS
    DefaultMessageListenerContainer listener1 = this.context.getBean("listener1", DefaultMessageListenerContainer.class);
    DefaultMessageListenerContainer listener2 = this.context.getBean("listener2", DefaultMessageListenerContainer.class);
    assertEquals("Wrong destination type on listener1", true, listener1.isPubSubDomain());
    assertEquals("Wrong destination type on listener2", true, listener2.isPubSubDomain());
    assertEquals("Wrong response destination type on listener1", false, listener1.isReplyPubSubDomain());
    assertEquals("Wrong response destination type on listener2", false, listener2.isReplyPubSubDomain());
    // JCA
    JmsMessageEndpointManager listener3 = this.context.getBean("listener3", JmsMessageEndpointManager.class);
    JmsMessageEndpointManager listener4 = this.context.getBean("listener4", JmsMessageEndpointManager.class);
    assertEquals("Wrong destination type on listener3", true, listener3.isPubSubDomain());
    assertEquals("Wrong destination type on listener4", true, listener4.isPubSubDomain());
    assertEquals("Wrong response destination type on listener3", false, listener3.isReplyPubSubDomain());
    assertEquals("Wrong response destination type on listener4", false, listener4.isReplyPubSubDomain());
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsMessageEndpointManager(org.springframework.jms.listener.endpoint.JmsMessageEndpointManager) Test(org.junit.Test)

Example 22 with DefaultMessageListenerContainer

use of org.springframework.jms.listener.DefaultMessageListenerContainer in project spring-framework by spring-projects.

the class JmsNamespaceHandlerTests method testContainerConfiguration.

@Test
public void testContainerConfiguration() throws Exception {
    Map<String, DefaultMessageListenerContainer> containers = context.getBeansOfType(DefaultMessageListenerContainer.class);
    ConnectionFactory defaultConnectionFactory = context.getBean(DEFAULT_CONNECTION_FACTORY, ConnectionFactory.class);
    ConnectionFactory explicitConnectionFactory = context.getBean(EXPLICIT_CONNECTION_FACTORY, ConnectionFactory.class);
    int defaultConnectionFactoryCount = 0;
    int explicitConnectionFactoryCount = 0;
    for (DefaultMessageListenerContainer container : containers.values()) {
        if (container.getConnectionFactory().equals(defaultConnectionFactory)) {
            defaultConnectionFactoryCount++;
        } else if (container.getConnectionFactory().equals(explicitConnectionFactory)) {
            explicitConnectionFactoryCount++;
        }
    }
    assertEquals("1 container should have the default connectionFactory", 1, defaultConnectionFactoryCount);
    assertEquals("2 containers should have the explicit connectionFactory", 2, explicitConnectionFactoryCount);
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) ConnectionFactory(javax.jms.ConnectionFactory) Test(org.junit.Test)

Example 23 with DefaultMessageListenerContainer

use of org.springframework.jms.listener.DefaultMessageListenerContainer in project opennms by OpenNMS.

the class AppConfig method listenerContainer.

//
// JMS DLMC
//
@Bean(name = "listenerContainer")
public AbstractMessageListenerContainer listenerContainer() {
    CollectionJobListener collectionJobListener = new CollectionJobListener(jmsTemplate());
    collectionJobListener.setProtocolCollectorRegistry(protocolCollectorRegistry());
    DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
    listenerContainer.setConnectionFactory(connectionFactory());
    listenerContainer.setConcurrentConsumers(16);
    listenerContainer.setMaxConcurrentConsumers(16);
    listenerContainer.setDestinationName("NrtCollectMe");
    listenerContainer.setMessageListener(collectionJobListener);
    return listenerContainer;
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) CollectionJobListener(org.opennms.nrtg.nrtcollector.internal.jms.CollectionJobListener) Bean(org.springframework.context.annotation.Bean)

Example 24 with DefaultMessageListenerContainer

use of org.springframework.jms.listener.DefaultMessageListenerContainer in project simba-os by cegeka.

the class EventServiceConfiguration method jmsContainer.

@Bean
public DefaultMessageListenerContainer jmsContainer() {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setDestination(destination);
    container.setMessageListener(messageListener);
    container.start();
    return container;
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) Bean(org.springframework.context.annotation.Bean)

Aggregations

DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)24 Test (org.junit.Test)15 DefaultJmsListenerContainerFactory (org.springframework.jms.config.DefaultJmsListenerContainerFactory)7 JmsListenerEndpoint (org.springframework.jms.config.JmsListenerEndpoint)7 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)5 MessageListener (javax.jms.MessageListener)4 Bean (org.springframework.context.annotation.Bean)4 MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)3 DefaultSpringErrorHandler (org.apache.camel.component.jms.DefaultSpringErrorHandler)2 CollectionJobListener (org.opennms.nrtg.nrtcollector.internal.jms.CollectionJobListener)2 JmsMessageEndpointManager (org.springframework.jms.listener.endpoint.JmsMessageEndpointManager)2 ErrorHandler (org.springframework.util.ErrorHandler)2 BigInteger (java.math.BigInteger)1 Random (java.util.Random)1 ConnectionFactory (javax.jms.ConnectionFactory)1 Session (javax.jms.Session)1 DefaultJmsMessageListenerContainer (org.apache.camel.component.jms.DefaultJmsMessageListenerContainer)1 ReplyToType (org.apache.camel.component.jms.ReplyToType)1 JmsTemplate (org.springframework.jms.core.JmsTemplate)1 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)1