messaging-activemq/src/main/java/org/wildfly/extension/messaging/activemq/deployment/injection/TransactedJMSContext.java
void registerCleanUpListener(TransactionSynchronizationRegistry transactionSynchronizationRegistry, JMSContext contextInstance) {
        //to avoid registration of more listeners for one context, flag in transaction is used.
        Object alreadyRegistered = transactionSynchronizationRegistry.getResource(contextInstance);
        if (alreadyRegistered == null) {
            transactionSynchronizationRegistry.registerInterposedSynchronization(new AfterCompletionSynchronization(contextInstance));
            transactionSynchronizationRegistry.putResource(contextInstance, AfterCompletionSynchronization.class.getName());
        }
    }
void registerCleanUpListener(TransactionSynchronizationRegistry transactionSynchronizationRegistry, JMSContext contextInstance) {
        //to avoid registration of more listeners for one context, flag in transaction is used.
        Object alreadyRegistered = transactionSynchronizationRegistry.getResource(contextInstance);
        if (alreadyRegistered == null) {
            transactionSynchronizationRegistry.registerInterposedSynchronization(new AfterCompletionSynchronization(contextInstance));
            transactionSynchronizationRegistry.putResource(contextInstance, AfterCompletionSynchronization.class.getName());
        }
    }
Closing of transaction scoped JMSContext is executed through Synchronization listener.
This method registers listener, which takes care of closing JMSContext.

@param transactionSynchronizationRegistry
@param contextInstance