Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure multiple JmsListener for multiple topics

Tags:

In my project I add two different JmsListener but when I run project in ActiveMQ panel only one of these topics has consumer!

So should I add separate jmsListenerContainerFactory configuration for each JmsListener ??

@JmsListener(destination = "foo1")
public void foo1(final Message jsonMessage) throws JMSException {
    ...
}

@JmsListener(destination = "foo2")
public void foo12(final Message jsonMessage) throws JMSException {
    ...
}

edit: this is from JMS config file:

@Configuration
@EnableJms
public class FooJmsConfig {

    @Bean
    public ActiveMQConnectionFactory connectionFactory() {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        connectionFactory.setBrokerURL(BROKER_URL);
        connectionFactory.setPassword(BROKER_USERNAME);
        connectionFactory.setUserName(BROKER_PASSWORD);
        connectionFactory.setUseCompression(true);
        connectionFactory.setClientID("FPP_API");
        connectionFactory.setConnectionIDPrefix("DRR");
        connectionFactory.setUseAsyncSend(true);
        return connectionFactory;
    }

    @Bean
    public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory());
        factory.setConcurrency("1-1");
        factory.setPubSubDomain(true);
        factory.setSubscriptionDurable(true);
        return factory;
    }
}