1

I am trying to use sjms Camel component for integration with IBM MQ. Configuring jms component with transacted=false works just fine. As long as i try to use batch features it starts failing.

Thanks in advance...

Endpoint DSL:

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

Configuration:

@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;
    }

Due to warning in logs below messages are not commited and stay in MQ eventually.

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)
gpushkas
  • 37
  • 4
  • I don't anything specific about Apache Camel sjms, but in JMS a transacted session must commit. The error seems to indicate you are calling this from a session that was setup for asynchronous consume. Also note that acknowledgement mode is ignored on a transacted session. IBM documents it in the knowledge center "acknowledgeMode is ignored if the session is transacted." There is a constant `SESSION_TRANSACTED` that I have seen some examples uses to signify it is a transacted session but the value can be any of those values as it is ignored. – JoshMc Jun 01 '18 at 21:06
  • Some links that might be helpful: 1. [Class MQConnection](https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.javadoc.doc/WMQJMSClasses/com/ibm/mq/jms/MQConnection.html#createSession_boolean_int_) ; 2. [Interface JmsSession](https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.javadoc.doc/WMQJMSClasses/com/ibm/msg/client/jms/JmsSession.html) ; 3. [Working With Sessions](https://docs.oracle.com/cd/E19340-01/820-6767/aeqbj/index.html) ; 4. [Guaranteed Messaging with JMS](http://www2.sys-con.com/itsg/virtualcd/Java/archives/0604/chappell/index.html) – JoshMc Jun 01 '18 at 21:08
  • Here is a older APAR that provides some more info on why that error is produced: [IV26277: WMQ JMS V7.0.1 JMSCC0033 A SYNCHRONOUS METHOD CALL IS NOT PERMITTED WHEN A SESSION IS BEING USED ASYNCHRONOUSLY.](http://www-01.ibm.com/support/docview.wss?uid=swg1IV26277) – JoshMc Jun 01 '18 at 21:18
  • The page "[SJMS Component](http://camel.apache.org/sjms.html)" under "Consumers Configuration Options" it has another parameter `synchronous` which says the default value is `true`, perhaps try explicitly specifying this, for example `sjmsComponent://queue:XXX?acknowledgementMode=TRANSACTED&consumerCount=10&synchronous=true&transacted=true&transactionBatchCount=10&transactionBatchTimeout=10000` – JoshMc Jun 01 '18 at 22:03
  • Note this doc "[Simple JMS Batch Component](https://github.com/apache/camel/blob/master/components/camel-sjms/src/main/docs/sjms-batch-component.adoc)" specifically says that the default for `synchronous` is `false`, so try the suggestion of explicitly specifying it as true. – JoshMc Jun 01 '18 at 22:14
  • Hi Josh. Thanks for trying to help out. Yes, i tried to change the flag, still getting same issue. – gpushkas Jun 04 '18 at 12:13
  • Eventually i was able to properly process messages in batch manner. I have used SjmsBatchComponent instead of SjmsComponent. It works great so far. Both timeout and completion size. I would upvote you Josh, but seems like i am not eligible to. – gpushkas Jun 12 '18 at 14:35

0 Answers0