title: Spring integration : how to handle transaction commit while specific exception occurs
body: <p>Our application, based on spring integration (Spring Boot v2.2.5.RELEASE, Spring v5.2.4.RELEASE), accepts JMS messages via <em>inboundGateway</em> component, process a message flow and finally produces a JMS message as result in a different queue.</p>
  <p>In order to make our flow  <strong>transactional</strong>, we configure the following :</p>
  <ul>
  <li><p>At the <em>inboundGateway</em> component, we attach a <strong>JmsTransactionManager</strong> to the <em>DefaultMessageListenerContainer</em> instance</p>
  </li>
  <li><p>The <strong>input flow</strong></p>
  </li>
  </ul>
  <pre><code>IntegrationFlows.from(Jms.inboundGateway(defaultMessageListenerContainer).errorChannel(ERROR_CHANNEL));
  </code></pre>
  <ul>
  <li>At the <strong>process flow</strong></li>
  </ul>
  <pre><code>...
   .transform(jsonTransformer(), e -&gt; e.transactional(true))
  .handle (..)
  </code></pre>
  <p><strong>NB :</strong> the input flow and the process flow are connected through an <strong>executor channel</strong></p>
  <p>This works fine except for a particular scenario : when the process flow throws <strong>a specific unchecked exception</strong>, then we expect that it will be propagated to the ErrorHandler, where it <strong>will be written to an error queue AND transaction have to be COMMITTED</strong>. BUT the actual is that the transaction is rollbacked and the message is requeued.</p>
  <p>My questions are :</p>
  <ul>
  <li><p>is our transaction configuration well defined?  in addition of setting up the TX manager, is it mandatory to configure the <em>MessageListenerContainer</em> property <strong>SessionTransacted to true</strong>?</p>
  </li>
  <li><p>How to make commit even when the process flow throws the specific exception?  how and where to explicitly set/force the JMS transaction to be commited?</p>
  </li>
  </ul>
  <p>Thanks in advance,</p>