micro-integrator
micro-integrator copied to clipboard
Improve JMS listener logic to handle scenario where CLIENT_ACK and SessionTransacted are enabled
Description: With the fix we have introduced to address the issue https://github.com/wso2/product-ei/issues/4796, there is a possibility of executing session.recover() during a transacted session, if the configs are as below.
<parameter name="transport.jms.SessionAcknowledgement">CLIENT_ACKNOWLEDGE</parameter>
<parameter name="transport.jms.SessionTransacted">true</parameter>
We may get the following exception if we try to call session.recover() during transacted session,
ERROR {org.apache.axis2.transport.jms.ServiceTaskManager} - Error recovering the JMS session com.ibm.msg.client.jms.DetailedIllegalStateException: JMSCC0021: It is not valid to call the 'recover' method on a transacted session.
The application called a method that must not be called on a transacted session.
Change the application program to remove this behavior.
But the correct approach should be either of the following,
- Use transactions
<parameter name="transport.jms.SessionTransacted">true</parameter>
<parameter name="transport.jms.SessionAcknowledgement">SESSION_TRANSACTED</parameter>
- Use ClientAcknowledgement
<parameter name="transport.jms.SessionTransacted">false</parameter>
<parameter name="transport.jms.SessionAcknowledgement">CLIENT_ACKNOWLEDGE</parameter>
We need to improve the flow to handle the scenario where both session transaction and client acknowledge are configured.