Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-16778

JMSContext cannot be instantiated/accessed during transaction phase committing/committed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 13.0.0.Beta1, 13.0.0.Final, 14.0.0.Final, 26.1.1.Final
    • JMS
    • None
    • Hide

      There isn't really a viable alternative, but one can eagerly initialise the JMS context whenever the transaction scope is entered. However, this will lead to unnecessary JMS connection usage.

      Show
      There isn't really a viable alternative, but one can eagerly initialise the JMS context whenever the transaction scope is entered. However, this will lead to unnecessary JMS connection usage.
    • ---
    • ---

    Description

      When a transaction is active the TransactedJMSContext is injected for the JMSContext. However, if the JMSContext is first interacted with while the transaction is already committing (i.e. from a Hibernate lifecycle listener or another JTA transaction synchronization), it can not place it's own JTA transaction synchronization and will fail to instantiate.

      This issue is kind of similar to the same issue with firing events with transactional observers during the committing phase (WELD-2444 and CDI-724).

      However, I think in the case of the TransactedJMSContext the issue can be quite easily solved by relying on the PreDestroy of the transaction context, just like the RequestedJMSContext does. I don't see what the added benefit of a transaction synchronization is here.

       

      Relevant classes: https://github.com/wildfly/wildfly/blob/main/messaging-activemq/injection/src/main/java/org/wildfly/extension/messaging/activemq/deployment/injection/RequestedJMSContext.java#L36-L40 and https://github.com/wildfly/wildfly/blob/main/messaging-activemq/injection/src/main/java/org/wildfly/extension/messaging/activemq/deployment/injection/TransactedJMSContext.java#L38

       

      I.e. use:

          @PreDestroy
          @Override
          void cleanUp() {
              super.cleanUp();
          }
      

      instead of:

                  transactionSynchronizationRegistry.registerInterposedSynchronization(new AfterCompletionSynchronization(contextInstance));
      

      Attachments

        Issue Links

          Activity

            People

              ehugonne1@redhat.com Emmanuel Hugonnet
              jwgmeligmeyling Jan-Willem Gmelig Meyling (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: