首页 > 解决方案 > Apache Camel sjms 批处理失败

问题描述

我正在尝试使用 sjms Camel 组件与 IBM MQ 集成。使用 transacted=false 配置 jms 组件就可以了。只要我尝试使用批处理功能,它就会开始失败。

提前致谢...

端点 DSL:

sjmsComponent://queue:XXX?acknowledgementMode=AUTO_ACKNOWLEDGE&consumerCount=10&transacted=true&transactionBatchCount=10&transactionBatchTimeout=10000

配置:

@Scope(scopeName = "prototype")
@Bean
public JmsConnectionFactory connectionFactory() throws JMSException
{
    MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();
    mqQueueConnectionFactory.setTransportType(this.mqTransportType);
    mqQueueConnectionFactory.setHostName(this.mqHostName);
    mqQueueConnectionFactory.setPort(this.mqPort);
    mqQueueConnectionFactory.setQueueManager(this.mqQueueManager);
    mqQueueConnectionFactory.setChannel(this.mqChannel);
    return mqQueueConnectionFactory;
}
    @Scope(scopeName = "prototype")
    @Bean
    public SjmsComponent sjmsComponent(ConnectionFactory connectionFactory) throws JMSException
    {
        SjmsComponent sjmsComponent = new SjmsComponent();
        sjmsComponent.setConnectionFactory(connectionFactory);
        return sjmsComponent;
    }

由于以下日志中的警告消息未提交并最终保留在 MQ 中。

Warning in logs : 

Failed to commit the session during timeout: JMSCC0033: A synchronous method call is not permitted when a session is being used asynchronously: 'commit'.. This exception will be ignored.
com.ibm.msg.client.jms.DetailedIllegalStateException: JMSCC0033: A synchronous method call is not permitted when a session is being used asynchronously: 'commit'.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.ibm.msg.client.commonservices.j2se.NLSServices.createException(NLSServices.java:319)
    at com.ibm.msg.client.commonservices.nls.NLSServices.createException(NLSServices.java:226)
    at com.ibm.msg.client.jms.internal.JmsErrorUtils.createException(JmsErrorUtils.java:126)
    at com.ibm.msg.client.jms.internal.JmsSessionImpl.checkSynchronousUsage(JmsSessionImpl.java:2959)
    at com.ibm.msg.client.jms.internal.JmsSessionImpl.commit(JmsSessionImpl.java:753)
    at com.ibm.mq.jms.MQSession.commit(MQSession.java:294)
    at org.apache.camel.component.sjms.tx.SessionBatchTransactionSynchronization$TimeoutTask.run(SessionBatchTransactionSynchronization.java:135)
    at java.util.TimerThread.mainLoop(Timer.java:555)

标签: apache-cameljmsibm-mq

解决方案


推荐阅读