消息处于挂起状态-会话处理,并发,缓存消费者

时间:2019-06-13 19:43:51

标签: tomcat jms activemq

我已经在使用tomcat服务器的hybris环境中实现了Apache activemq。我在同一台主机上部署了生产者和使用者,并在其中一台应用程序服务器上安装了jms。所有群集的应用程序服务器使用相同的jms代理url,并在JMS上创建自己的队列。这在所有较低的环境中都可以正常工作,但是一旦投入生产,我们会看到很多待处理的消息。哪些未交付。我不知道他们为什么要进入待处理状态。有什么帮助吗?

@Bean
public ActiveMQConnectionFactory connectionFactory()
{
    final ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    final RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    redeliveryPolicy.setInitialRedeliveryDelay(TimeUnit.MINUTES.toMillis(Long.parseLong(initialRedeliveryDelay)));
    redeliveryPolicy.setRedeliveryDelay(TimeUnit.HOURS.toMillis(Long.parseLong(redeliveryDelay)));
    redeliveryPolicy.setUseExponentialBackOff(false);
    redeliveryPolicy.setMaximumRedeliveries(Integer.parseInt(maximumRedeliveries));

    connectionFactory.setRedeliveryPolicy(redeliveryPolicy);
    connectionFactory.setTrustedPackages(Arrays.asList("com.cintas.core.jms", "javax.mail.internet", "java.util",
            "de.hybris.platform.acceleratorservices.model.email", "de.hybris.platform.servicelayer.model.strategies",
            "com.cintas.integration.vo.email"));
    connectionFactory.setBrokerURL(brokerUrl);
    connectionFactory.setUserName(userName);
    connectionFactory.setPassword(password);
    return connectionFactory;
}

@Bean
public ConnectionFactory cachingConnectionFactory()
{
    final CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
    connectionFactory.setTargetConnectionFactory(connectionFactory());
    connectionFactory.setCacheConsumers(false);
    return connectionFactory;
}

@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(final JMSErrorHandler errorHandler)
{
    final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory());
    factory.setSessionTransacted(true);
    factory.setConcurrency(concurrency);
    factory.setErrorHandler(errorHandler);

    return factory;
}

0 个答案:

没有答案