messaging-activemq/src/main/java/org/wildfly/extension/messaging/activemq/deployment/injection/InjectedJMSContext.java
@Override
    JMSContext getDelegate() {
        boolean inTx = isInTransaction();
        AbstractJMSContext jmsContext = inTx ? transactedJMSContext.get() : requestedJMSContext;

        ROOT_LOGGER.debugf("using %s to create the injected JMSContext", jmsContext, id);
        ConnectionFactory connectionFactory = getConnectionFactory();
        JMSContext contextInstance = jmsContext.getContext(id, info, connectionFactory);

        //fix of  WFLY-9501
        // CCM tries to clean opened connections before execution of @PreDestroy method on JMSContext - which is executed after completion, see .
        // Correct phase to call close is afterCompletion {@see TransactionSynchronizationRegistry.registerInterposedSynchronization}
        if(inTx) {
            TransactedJMSContext transactedJMSContext = (TransactedJMSContext)jmsContext;
            transactedJMSContext.registerCleanUpListener(transactionSynchronizationRegistry, contextInstance);
        }

        return contextInstance;
    }
@Override
    JMSContext getDelegate() {
        boolean inTx = isInTransaction();
        AbstractJMSContext jmsContext = inTx ? transactedJMSContext.get() : requestedJMSContext;

        ROOT_LOGGER.debugf("using %s to create the injected JMSContext", jmsContext, id);
        ConnectionFactory connectionFactory = getConnectionFactory();
        JMSContext contextInstance = jmsContext.getContext(id, info, connectionFactory);

        //fix of  WFLY-9501
        // CCM tries to clean opened connections before execution of @PreDestroy method on JMSContext - which is executed after completion, see .
        // Correct phase to call close is afterCompletion {@see TransactionSynchronizationRegistry.registerInterposedSynchronization}
        if(inTx) {
            TransactedJMSContext transactedJMSContext = (TransactedJMSContext)jmsContext;
            transactedJMSContext.registerCleanUpListener(transactionSynchronizationRegistry, contextInstance);
        }

        return contextInstance;
    }
@ Override JMSContext getDelegate ( ) { boolean inTx = isInTransaction ( ) ; AbstractJMSContext jmsContext = inTx ? transactedJMSContext . get ( ) : requestedJMSContext ; ROOT_LOGGER . debugf ( "using %s to create the injected JMSContext" , jmsContext , id ) ; ConnectionFactory connectionFactory = getConnectionFactory ( ) ; JMSContext contextInstance = jmsContext . getContext ( id , info , connectionFactory ) ; //fix of  WFLY-9501 // CCM tries to clean opened connections before execution of @PreDestroy method on JMSContext - which is executed after completion, see . // Correct phase to call close is afterCompletion {@see TransactionSynchronizationRegistry.registerInterposedSynchronization} if ( inTx ) { TransactedJMSContext transactedJMSContext = ( TransactedJMSContext ) jmsContext ; transactedJMSContext . registerCleanUpListener ( transactionSynchronizationRegistry , contextInstance ) ; } return contextInstance ; }
Return the actual JMSContext used by this injection.

The use of the correct AbstractJMSContext (one with the @RequestScoped, the other
with the @TransactionScoped) is determined by the presence on an active transaction.
Return the actual JMSContext used by this injection .