ARTEMIS-4427 MDB reusing Thread is using wrong transactionTimeout.

* Unsetting the transation timeout on the TransactionManager after the
  onMessage has been called

Issue: https://issues.apache.org/jira/browse/ARTEMIS-4427

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
This commit is contained in:
Emmanuel Hugonnet 2023-09-12 15:51:23 +02:00 committed by clebertsuconic
parent 495350a0c1
commit 1d88b293c3
1 changed files with 10 additions and 1 deletions

View File

@ -55,6 +55,7 @@ import org.apache.activemq.artemis.utils.VersionLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@ -288,7 +289,6 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
@Override
public void onMessage(final ClientMessage message) {
logger.trace("onMessage({})", message);
ActiveMQMessage msg;
if (enable1XPrefix) {
msg = ActiveMQCompatibleMessage.createMessage(message, session, options);
@ -379,6 +379,15 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
session.markRollbackOnly();
} finally {
try {
if (activation.getActivationSpec().getTransactionTimeout() > 0) {
TransactionManager tm = ServiceUtils.getTransactionManager();
if (tm != null) {
try {
tm.setTransactionTimeout(0);
} catch (SystemException ex) {
}
}
}
session.resetIfNeeded();
} catch (ActiveMQException e) {
ActiveMQRALogger.LOGGER.unableToResetSession(activation.toString(), e);