Skip to content

Commit

Permalink
Ensure that Observation is stopped and scope is closed in doReceiveAn…
Browse files Browse the repository at this point in the history
…dExecute()

Closes gh-31798
  • Loading branch information
izeye authored and bclozel committed Jan 5, 2024
1 parent 1372265 commit 0ad561d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,21 @@ protected boolean doReceiveAndExecute(Object invoker, @Nullable Session session,
}
Message message = receiveMessage(consumerToUse);
if (message != null) {
boolean exposeResource = (!transactional && isExposeListenerSession() &&
!TransactionSynchronizationManager.hasResource(obtainConnectionFactory()));
Observation observation = createObservation(message).start();
Observation.Scope scope = observation.openScope();
if (logger.isDebugEnabled()) {
logger.debug("Received message of type [" + message.getClass() + "] from consumer [" +
consumerToUse + "] of " + (transactional ? "transactional " : "") + "session [" +
sessionToUse + "]");
}
messageReceived(invoker, sessionToUse);
boolean exposeResource = (!transactional && isExposeListenerSession() &&
!TransactionSynchronizationManager.hasResource(obtainConnectionFactory()));
if (exposeResource) {
TransactionSynchronizationManager.bindResource(
obtainConnectionFactory(), new LocallyExposedJmsResourceHolder(sessionToUse));
}
try {
messageReceived(invoker, sessionToUse);
if (exposeResource) {
TransactionSynchronizationManager.bindResource(
obtainConnectionFactory(), new LocallyExposedJmsResourceHolder(sessionToUse));
}
doExecuteListener(sessionToUse, message);
}
catch (Throwable ex) {
Expand Down

0 comments on commit 0ad561d

Please sign in to comment.