defaultmessagelistenercontainer

lh80um4z  于 2021-07-15  发布在  Java
关注(0)|答案(0)|浏览(203)

我正在构建一个需要高性能jms处理的应用程序。它将从队列中读取消息,经过处理后,同一消息将发布到另一个队列。

@JmsListener(destination = "queue1", containerFactory = "containerFactory", concurrency = "16-32")

@JmsListener(destination = "queue2", containerFactory = "containerFactoryExt", concurrency = "16-32")

@JmsListener(destination = "queue3", containerFactory = "containerFactory2", concurrency = "16-32")

@JmsListener(destination = "queue4", containerFactory = "containerFactoryExt2", concurrency = "16-32")

下面是我创建容器工厂的代码。

@Bean(name = "containerFactory")
public MQConnectionFactory mqConnectionFactory(DefaultJmsListenerContainerFactoryConfigurer configurer) throws NamingException {
    //call to createJmsListenerContainerFactory()
}

@Bean(name = "containerFactoryExt")
public MQConnectionFactory mqConnectionFactory(DefaultJmsListenerContainerFactoryConfigurer configurer) throws NamingException {
    //call to createJmsListenerContainerFactory()
}

@Bean(name = "containerFactory2")
public MQConnectionFactory mqConnectionFactory(DefaultJmsListenerContainerFactoryConfigurer configurer) throws NamingException {
    //call to createJmsListenerContainerFactory()
}

@Bean(name = "containerFactoryExt2")
public MQConnectionFactory mqConnectionFactory(DefaultJmsListenerContainerFactoryConfigurer configurer) throws NamingException {
    //call to createJmsListenerContainerFactory()
}

 JmsListenerContainerFactory<DefaultMessageListenerContainer> createJmsListenerContainerFactory(
        ConnectionFactory cf,DefaultJmsListenerContainerFactoryConfigurer configurer) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    configurer.configure(factory, cf);
    factory.setSessionTransacted(true);
    factory.setConcurrency("15-50");
    factory.setSessionAcknowledgeMode(2);
    factory.setBackOff(new FixedBackOff());
    return factory;
}

是否建议每个侦听器有单独的容器工厂?还有什么建议可以改进性能吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题