如何为多个主题配置多个 JmsListener
在我的项目中,我添加了两个不同的JmsListener,但是当我在ActiveMQ面板中运行项目时,只有其中一个主题具有消费者!
那么我应该为每个JmsListener添加单独的jmsListenerContainerFactory配置吗?
@JmsListener(destination = "foo1")
public void foo1(final Message jsonMessage) throws JMSException {
...
}
@JmsListener(destination = "foo2")
public void foo12(final Message jsonMessage) throws JMSException {
...
}
编辑:这是来自JMS配置文件:
@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;
}
}