Apache camel重试尝试使用关闭消息会话的activeMQ失败

时间:2017-07-11 07:57:52

标签: java spring apache-camel activemq

我正在开发一个春季启动项目。在那我试图使用apache camel路由重新发送消息到activeMQ。但是,当重试尝试完美时,消息无法在会话关闭时传递。

CamelRoute:

     @Override
    public void configure() throws Exception {

        onException(UncategorizedJmsException.class, JMSException.class, ConnectException.class)
        .maximumRedeliveries(retryCount).redeliveryDelay(redeliveryDelay).onRedelivery(retryProcessor).process(ExceptionProcessor);

        from("direct:sendMessage").to(queueName);
 }

queueName在application.properties中定义为 outbound.endpoint = JMS:DUMMY.QUEUE

retryProcessor只打印带有重试次数的日志消息。

执行时,即使activemq启动,我在每次重试时都会遇到错误。

2017-07-11 07:51:40.955  WARN 9912 --- []] o.a.c.c.jms.EndpointMessageListener      : Execution of JMS message listener failed. Caused by: [javax.jms.IllegalStateException - The Session is closed]

javax.jms.IllegalStateException: The Session is closed
at org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java:771) ~[activemq-client-5.13.4.jar:5.13.4]
at org.apache.activemq.ActiveMQSession.getTransacted(ActiveMQSession.java:540) ~[activemq-client-5.13.4.jar:5.13.4]
at org.apache.activemq.jms.pool.PooledSession.getTransacted(PooledSession.java:260) ~[activemq-jms-pool-5.13.4.jar:5.13.4]
at org.springframework.jms.listener.AbstractMessageListenerContainer.rollbackOnExceptionIfNecessary(AbstractMessageListenerContainer.java:794) ~[spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:658) ~[spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_74]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74]

我的JMS配置类是:

    @Bean
public ConnectionFactory getConnectionFactory() {
    // use a pool for ActiveMQ connections
    PooledConnectionFactory pool = new PooledConnectionFactory();
    pool.setConnectionFactory(
            new ActiveMQConnectionFactory(userName, password, "tcp://" + jmsServer + ":" + jmsPort));
    pool.setMaxConnections(maxConnections);

    return pool;
}

@Bean("activemq")
public ActiveMQComponent getActiveMQComponent() {
    // use a pool for ActiveMQ connections
    JmsConfiguration jmsConfig = new JmsConfiguration();
    jmsConfig.setConnectionFactory(getConnectionFactory());
    jmsConfig.setConcurrentConsumers(concurrentConsumers);

    ActiveMQComponent activeMqComponent = new ActiveMQComponent();
    activeMqComponent.setConfiguration(jmsConfig);

    return activeMqComponent;
}

非常感谢任何帮助。

提前致谢。

0 个答案:

没有答案