glassfish
  1. glassfish
  2. GLASSFISH-20973

annotated JMS ConnectionFactory doesn't enroll in container managed transaction

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1
    • Component/s: jms
    • Labels:
      None
    • Environment:

      GF v4.0

      Description

      On the attached example, a 12 messages are sent via 1.1 and 2.0 style to 2 destinations and then ctx.setRollbackOnly() is invoked. All messages arrive at two destinations, one outside the EJB container (Java SE) and on MDBs inside the container.

      1. JmsNoEnroleInTransaction.zip.exe
        95 kB
        amyk

        Issue Links

          Activity

          Hide
          pranahata added a comment - - edited

          Can't attach file, so pasting here

          package ejbs;
          /*
           *  Copyright © - 2014 Anahata Technologies.
           */
          
          import javax.annotation.PostConstruct;
          import javax.annotation.Resource;
          import javax.ejb.EJBContext;
          import javax.ejb.Stateless;
          import javax.ejb.TransactionManagement;
          import javax.ejb.TransactionManagementType;
          import javax.inject.Inject;
          import javax.jms.*;
          
          /**
           *
           * @author Pablo Rodriguez Pina <pablo@anahata-it.com.au>
           */
          @JMSConnectionFactoryDefinition(
                  name = "java:module/jms/annotationCF",
                  maxPoolSize = 30,
                  minPoolSize = 20,
                  interfaceName = "javax.jms.TopicXAConnectionFactory",
                  properties = {
                      "addressList=mq://localhost:7676",
                      "reconnectEnabled=true"
                  }
          )
          @JMSDestinationDefinition(
                  name = "java:module/jms/annotationTopic",
                  interfaceName = "javax.jms.Topic",
                  description = "Yam Dms Event Topic",
                  destinationName = "annotationTopic"
          )
          @Stateless
          @TransactionManagement(TransactionManagementType.CONTAINER)
          public class JmsBean {
              @Resource(lookup = "java:module/jms/annotationCF")
              private ConnectionFactory annotationCF;
          
              @Inject
              @JMSConnectionFactory("java:module/jms/annotationCF")
              @JMSSessionMode(JMSContext.SESSION_TRANSACTED)
              private JMSContext annotationInjectedContext;
          
              @Resource(lookup = "java:module/jms/annotationTopic")
              private Topic annotationTopic;
          
              @Resource(lookup = "jms/gf-resourcesCF")
              private ConnectionFactory resourcesCF;
          //
          
              @Inject
              @JMSConnectionFactory("jms/gf-resourcesCF")
              private JMSContext resourcesInjectedContext;
          //
          
              @Resource(lookup = "jms/resourcesTopic")
              private Topic resourcesTopic;
          
              @Resource
              private EJBContext ctx;
          
              @PostConstruct
              public void postConstruct() {
                  System.out.println("annotationCF=" + annotationCF);
                  System.out.println("resourcesCF=" + resourcesCF);
              }
          
              public void sendMessages() {
                  sendMessage11(annotationCF, annotationTopic, "annotationCF + annotationTopic 1.1");
                  sendMessage11(annotationCF, resourcesTopic, "annotationCF + resourcesTopic 1.1");
                  sendMessage11(resourcesCF, resourcesTopic, "resourcesCF + annotationTopic 1.1");
                  sendMessage11(resourcesCF, annotationTopic, "resourcesCF + annotationTopic 1.1");
          
                  sendMessage20CreateContext(annotationCF, annotationTopic, "annotationCF + annotationTopic + created context 2.0");
                  sendMessage20CreateContext(annotationCF, resourcesTopic, "annotationCF + resourcesTopic + created context 2.0");
                  sendMessage20CreateContext(resourcesCF, resourcesTopic, "resourcesCF + resourcesTopic + created context 2.0");
                  sendMessage20CreateContext(resourcesCF, annotationTopic, "resourcesCF + annotationTopic + created context 2.0");
          
                  sendMessage20(annotationInjectedContext, annotationTopic, "annotationInjectedContext + annotationTopic 2.0");
                  sendMessage20(annotationInjectedContext, resourcesTopic, "annotationInjectedContext + annotationTopic 2.0");
                  sendMessage20(resourcesInjectedContext, resourcesTopic, "resourcesInjectedContext + resourcesTopic 2.0");
                  sendMessage20(resourcesInjectedContext, annotationTopic, "resourcesInjectedContext + resourcesTopic 2.0");
                  System.out.println("rolling back on sendMessages()");
                  ctx.setRollbackOnly();
              }
          
              private void sendMessage20CreateContext(ConnectionFactory cf, Topic topic, String message) {
                  try (JMSContext ctx = cf.createContext()) {
                      sendMessage20(ctx, topic, message);
                  }
              }
          
              private void sendMessage20(JMSContext context, Topic topic, String message) {
                  JMSProducer producer = context.createProducer();
                  producer.send(topic, message);
              }
          
              private void sendMessage11(ConnectionFactory cf, Topic topic, String message) {
                  try {
                      try (Connection con = cf.createConnection()) {
                          try (Session s = con.createSession(true, 0)) {
                              MessageProducer mp = s.createProducer(topic);
                              TextMessage om = s.createTextMessage();
                              om.setText(message);
                              mp.send(om);
                          }
                      }
          
                  } catch (JMSException e) {
                      e.printStackTrace();
                  }
          
              }
          }
          
          
          ---------------------------------------------------------------------------------------------
          
          
          
          /*
           *  Copyright © - 2014 Anahata Technologies.
           */
          package javase;
          
          //import com.sun.messaging.ConnectionConfiguration;
          import static java.lang.StrictMath.*;
          import javax.annotation.PostConstruct;
          import javax.annotation.PreDestroy;
          import javax.annotation.Resource;
          import javax.ejb.EJBContext;
          import javax.enterprise.context.ApplicationScoped;
          import javax.jms.*;
          
          /**
           *
           * @author Pablo Rodriguez Pina <pablo@anahata-it.com.au>
           */
          public class JMSListener {
              private Connection connection;
          
              private Session session;
          
              private Topic topic;
          
              public void init(String topicName) throws Exception {
                  long ts = System.currentTimeMillis();
                  com.sun.messaging.ConnectionFactory cf = new com.sun.messaging.ConnectionFactory();
                  cf.setProperty(ConnectionConfiguration.imqAddressList, "localhost:7676");
                  cf.setProperty(ConnectionConfiguration.imqReconnectEnabled, "true");
                  connection = cf.createConnection("guest", "guest");
                  connection.setExceptionListener(new ExceptionListener() {
                      @Override
                      public void onException(JMSException exception) {
                          System.out.println("exception: " + exception);
                      }
                  });
                  session = connection.createSession(true, Session.SESSION_TRANSACTED);
                  topic = session.createTopic(topicName);
                  connection.start();
                  MessageConsumer messageConsumer = session.createConsumer(topic);
                  messageConsumer.setMessageListener(new MessageListener() {
                      @Override
                      public void onMessage(Message message) {
                          try {
                              System.out.println("Got message " + ((TextMessage)message).getText());
                          } catch (Exception e) {
                              e.printStackTrace();
                          }
                      }
                  });
              }
          
              public static void main(String[] args) throws Exception {
                  new JMSListener().init("annotationTopic");
                  new JMSListener().init("resourcesTopic");
              }
          
          }
          
          
          Show
          pranahata added a comment - - edited Can't attach file, so pasting here package ejbs; /* * Copyright © - 2014 Anahata Technologies. */ import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.ejb.EJBContext; import javax.ejb.Stateless; import javax.ejb.TransactionManagement; import javax.ejb.TransactionManagementType; import javax.inject.Inject; import javax.jms.*; /** * * @author Pablo Rodriguez Pina <pablo@anahata-it.com.au> */ @JMSConnectionFactoryDefinition( name = "java:module/jms/annotationCF", maxPoolSize = 30, minPoolSize = 20, interfaceName = "javax.jms.TopicXAConnectionFactory", properties = { "addressList=mq://localhost:7676", "reconnectEnabled=true" } ) @JMSDestinationDefinition( name = "java:module/jms/annotationTopic", interfaceName = "javax.jms.Topic", description = "Yam Dms Event Topic", destinationName = "annotationTopic" ) @Stateless @TransactionManagement(TransactionManagementType.CONTAINER) public class JmsBean { @Resource(lookup = "java:module/jms/annotationCF") private ConnectionFactory annotationCF; @Inject @JMSConnectionFactory("java:module/jms/annotationCF") @JMSSessionMode(JMSContext.SESSION_TRANSACTED) private JMSContext annotationInjectedContext; @Resource(lookup = "java:module/jms/annotationTopic") private Topic annotationTopic; @Resource(lookup = "jms/gf-resourcesCF") private ConnectionFactory resourcesCF; // @Inject @JMSConnectionFactory("jms/gf-resourcesCF") private JMSContext resourcesInjectedContext; // @Resource(lookup = "jms/resourcesTopic") private Topic resourcesTopic; @Resource private EJBContext ctx; @PostConstruct public void postConstruct() { System.out.println("annotationCF=" + annotationCF); System.out.println("resourcesCF=" + resourcesCF); } public void sendMessages() { sendMessage11(annotationCF, annotationTopic, "annotationCF + annotationTopic 1.1"); sendMessage11(annotationCF, resourcesTopic, "annotationCF + resourcesTopic 1.1"); sendMessage11(resourcesCF, resourcesTopic, "resourcesCF + annotationTopic 1.1"); sendMessage11(resourcesCF, annotationTopic, "resourcesCF + annotationTopic 1.1"); sendMessage20CreateContext(annotationCF, annotationTopic, "annotationCF + annotationTopic + created context 2.0"); sendMessage20CreateContext(annotationCF, resourcesTopic, "annotationCF + resourcesTopic + created context 2.0"); sendMessage20CreateContext(resourcesCF, resourcesTopic, "resourcesCF + resourcesTopic + created context 2.0"); sendMessage20CreateContext(resourcesCF, annotationTopic, "resourcesCF + annotationTopic + created context 2.0"); sendMessage20(annotationInjectedContext, annotationTopic, "annotationInjectedContext + annotationTopic 2.0"); sendMessage20(annotationInjectedContext, resourcesTopic, "annotationInjectedContext + annotationTopic 2.0"); sendMessage20(resourcesInjectedContext, resourcesTopic, "resourcesInjectedContext + resourcesTopic 2.0"); sendMessage20(resourcesInjectedContext, annotationTopic, "resourcesInjectedContext + resourcesTopic 2.0"); System.out.println("rolling back on sendMessages()"); ctx.setRollbackOnly(); } private void sendMessage20CreateContext(ConnectionFactory cf, Topic topic, String message) { try (JMSContext ctx = cf.createContext()) { sendMessage20(ctx, topic, message); } } private void sendMessage20(JMSContext context, Topic topic, String message) { JMSProducer producer = context.createProducer(); producer.send(topic, message); } private void sendMessage11(ConnectionFactory cf, Topic topic, String message) { try { try (Connection con = cf.createConnection()) { try (Session s = con.createSession(true, 0)) { MessageProducer mp = s.createProducer(topic); TextMessage om = s.createTextMessage(); om.setText(message); mp.send(om); } } } catch (JMSException e) { e.printStackTrace(); } } } --------------------------------------------------------------------------------------------- /* * Copyright © - 2014 Anahata Technologies. */ package javase; //import com.sun.messaging.ConnectionConfiguration; import static java.lang.StrictMath.*; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.annotation.Resource; import javax.ejb.EJBContext; import javax.enterprise.context.ApplicationScoped; import javax.jms.*; /** * * @author Pablo Rodriguez Pina <pablo@anahata-it.com.au> */ public class JMSListener { private Connection connection; private Session session; private Topic topic; public void init(String topicName) throws Exception { long ts = System.currentTimeMillis(); com.sun.messaging.ConnectionFactory cf = new com.sun.messaging.ConnectionFactory(); cf.setProperty(ConnectionConfiguration.imqAddressList, "localhost:7676"); cf.setProperty(ConnectionConfiguration.imqReconnectEnabled, "true"); connection = cf.createConnection("guest", "guest"); connection.setExceptionListener(new ExceptionListener() { @Override public void onException(JMSException exception) { System.out.println("exception: " + exception); } }); session = connection.createSession(true, Session.SESSION_TRANSACTED); topic = session.createTopic(topicName); connection.start(); MessageConsumer messageConsumer = session.createConsumer(topic); messageConsumer.setMessageListener(new MessageListener() { @Override public void onMessage(Message message) { try { System.out.println("Got message " + ((TextMessage)message).getText()); } catch (Exception e) { e.printStackTrace(); } } }); } public static void main(String[] args) throws Exception { new JMSListener().init("annotationTopic"); new JMSListener().init("resourcesTopic"); } }
          Hide
          David Zhao added a comment -

          Duplicate to GLASSFISH-20975.

          Show
          David Zhao added a comment - Duplicate to GLASSFISH-20975 .
          Hide
          amyk added a comment - - edited

          With following simplified test case, it shows the one that has issue is annotated JMS ConnectionFactory (Summary changed accordingly),

          1. Use 2 components: a) application client component to invoke the b) stateless session bean JmsBean.sendMessages()
          2. Change the test to use Queues instead of Topics so that messages will be retained in its Queue after test (no consumer)
          3. Modify JmsBean to set a property on each message sent to indicate how the message is sent, e.g.
          SEND_HOW="annotationCF + annotationTopic 1.1"
          4. When the test completes, run 'imqcmd list dst' to see any messages in the 2 Queues and use 'imqcmd list/query msg' (a GlassFish MQ unofficial feature) to examine each message's SEND_HOW property in the Queues

          [also the original test case should specify the interfaceName in JMSConnectionFactoryDefinition with a permitted value, see http://docs.oracle.com/javaee/7/api/javax/jms/JMSConnectionFactoryDefinition.html]

          After 1-4 steps, the result indicated following (see details below) sendMessage11/20 operations are not enrolled in the transaction, whereas other sendMessage11/20 operations are rolled back as expected.

          sendMessage11(annotationCF, annotationQueue, "annotationCF + annotationQueue 1.1");
          sendMessage11(annotationCF, resourcesQueue, "annotationCF + resourcesQueue 1.1");

          sendMessage20CreateContext(annotationCF, annotationQueue, "annotationCF + annotationQueue + created context 2.0");
          sendMessage20CreateContext(annotationCF, resourcesQueue, "annotationCF + resourcesQueue + created context 2.0");

          sendMessage20(annotationInjectedContext, annotationQueue, "annotationInjectedContext + annotationQueue 2.0");
          sendMessage20(annotationInjectedContext, resourcesQueue, "annotationInjectedContext + annotationQueue 2.0");

          ========'imqcmd list/query msg' outputs after the test, notices the SEND_HOW property values

          imqcmd list msg -t q -n annotationQueue -u admin -pw admin -nocheck
          Listing messages for the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          annotationQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          ------------------------------------------------------------------------------------------------
          Message # Message IDs Priority Body Type
          ------------------------------------------------------------------------------------------------
          0 ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749 4 TextMessage
          1 ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874 4 TextMessage
          2 ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889 4 TextMessage

          Successfully listed messages.

          imqcmd query msg -t q -n annotationQueue -msgID "ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749" -nocheck

          Querying message:
          -----------------------------------------------------------
          Message ID
          -----------------------------------------------------------
          ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749

          In the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          annotationQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          --------------------------
          Message Header Information
          --------------------------
          Message ID ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749
          Correlation ID
          Destination Name annotationQueue
          Destination Type Queue
          Delivery Mode PERSISTENT (2)
          Priority 4
          Redelivered false
          Timestamp 2/26/14 10:09:34 PM
          Type
          Expiration 12/31/69 4:00:00 PM
          ReplyTo Destination Name
          ReplyTo Destination Type

          ------------------------------
          Message Properties Information
          ------------------------------
          SEND_HOW annotationCF + annotationQueue 1.1

          ------------------------
          Message Body Information
          ------------------------
          Body Type TextMessage (1)

          Successfully queried message.

          imqcmd query msg -t q -n annotationQueue -msgID "ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874" -nocheck

          Querying message:
          -----------------------------------------------------------
          Message ID
          -----------------------------------------------------------
          ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874

          In the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          annotationQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          --------------------------
          Message Header Information
          --------------------------
          Message ID ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874
          Correlation ID
          Destination Name annotationQueue
          Destination Type Queue
          Delivery Mode PERSISTENT (2)
          Priority 4
          Redelivered false
          Timestamp 2/26/14 10:09:34 PM
          Type
          Expiration 12/31/69 4:00:00 PM
          ReplyTo Destination Name
          ReplyTo Destination Type

          ------------------------------
          Message Properties Information
          ------------------------------
          SEND_HOW annotationCF + annotationQueue + created context 2.0

          ------------------------
          Message Body Information
          ------------------------
          Body Type TextMessage (1)

          Successfully queried message.

          imqcmd query msg -t q -n annotationQueue -msgID "ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889" -nocheck

          Querying message:
          -----------------------------------------------------------
          Message ID
          -----------------------------------------------------------
          ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889

          In the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          annotationQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          --------------------------
          Message Header Information
          --------------------------
          Message ID ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889
          Correlation ID
          Destination Name annotationQueue
          Destination Type Queue
          Delivery Mode PERSISTENT (2)
          Priority 4
          Redelivered false
          Timestamp 2/26/14 10:09:34 PM
          Type
          Expiration 12/31/69 4:00:00 PM
          ReplyTo Destination Name
          ReplyTo Destination Type

          ------------------------------
          Message Properties Information
          ------------------------------
          SEND_HOW annotationInjectedContext + annotationQueue 2.0

          ------------------------
          Message Body Information
          ------------------------
          Body Type TextMessage (1)

          Successfully queried message.

          imqcmd list msg -t q -n resourcesQueue -nocheck

          Listing messages for the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          resourcesQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          ------------------------------------------------------------------------------------------------
          Message # Message IDs Priority Body Type
          ------------------------------------------------------------------------------------------------
          0 ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764 4 TextMessage
          1 ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878 4 TextMessage
          2 ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890 4 TextMessage

          Successfully listed messages.

          imqcmd query msg -t q -n resourcesQueue -msgID "ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764" -nocheck

          Querying message:
          -----------------------------------------------------------
          Message ID
          -----------------------------------------------------------
          ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764

          In the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          resourcesQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          --------------------------
          Message Header Information
          --------------------------
          Message ID ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764
          Correlation ID
          Destination Name resourcesQueue
          Destination Type Queue
          Delivery Mode PERSISTENT (2)
          Priority 4
          Redelivered false
          Timestamp 2/26/14 10:09:34 PM
          Type
          Expiration 12/31/69 4:00:00 PM
          ReplyTo Destination Name
          ReplyTo Destination Type

          ------------------------------
          Message Properties Information
          ------------------------------
          SEND_HOW annotationCF + resourcesQueue 1.1

          ------------------------
          Message Body Information
          ------------------------
          Body Type TextMessage (1)

          Successfully queried message.

          imqcmd query msg -t q -n resourcesQueue -msgID "ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878" -nocheck

          Querying message:
          -----------------------------------------------------------
          Message ID
          -----------------------------------------------------------
          ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878

          In the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          resourcesQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          --------------------------
          Message Header Information
          --------------------------
          Message ID ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878
          Correlation ID
          Destination Name resourcesQueue
          Destination Type Queue
          Delivery Mode PERSISTENT (2)
          Priority 4
          Redelivered false
          Timestamp 2/26/14 10:09:34 PM
          Type
          Expiration 12/31/69 4:00:00 PM
          ReplyTo Destination Name
          ReplyTo Destination Type

          ------------------------------
          Message Properties Information
          ------------------------------
          SEND_HOW annotationCF + resourcesQueue + created context 2.0

          ------------------------
          Message Body Information
          ------------------------
          Body Type TextMessage (1)

          Successfully queried message.

          imqcmd query msg -t q -n resourcesQueue -msgID "ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890" -nocheck

          Querying message:
          -----------------------------------------------------------
          Message ID
          -----------------------------------------------------------
          ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890

          In the destination
          ------------------------------------
          Destination Name Destination Type
          ------------------------------------
          resourcesQueue Queue

          On the broker specified by:

          -------------------------
          Host Primary Port
          -------------------------
          localhost 7676

          --------------------------
          Message Header Information
          --------------------------
          Message ID ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890
          Correlation ID
          Destination Name resourcesQueue
          Destination Type Queue
          Delivery Mode PERSISTENT (2)
          Priority 4
          Redelivered false
          Timestamp 2/26/14 10:09:34 PM
          Type
          Expiration 12/31/69 4:00:00 PM
          ReplyTo Destination Name
          ReplyTo Destination Type

          ------------------------------
          Message Properties Information
          ------------------------------
          SEND_HOW annotationInjectedContext + annotationQueue 2.0

          ------------------------
          Message Body Information
          ------------------------
          Body Type TextMessage (1)

          Successfully queried message.
          =============================================================

          Show
          amyk added a comment - - edited With following simplified test case, it shows the one that has issue is annotated JMS ConnectionFactory (Summary changed accordingly), 1. Use 2 components: a) application client component to invoke the b) stateless session bean JmsBean.sendMessages() 2. Change the test to use Queues instead of Topics so that messages will be retained in its Queue after test (no consumer) 3. Modify JmsBean to set a property on each message sent to indicate how the message is sent, e.g. SEND_HOW="annotationCF + annotationTopic 1.1" 4. When the test completes, run 'imqcmd list dst' to see any messages in the 2 Queues and use 'imqcmd list/query msg' (a GlassFish MQ unofficial feature) to examine each message's SEND_HOW property in the Queues [also the original test case should specify the interfaceName in JMSConnectionFactoryDefinition with a permitted value, see http://docs.oracle.com/javaee/7/api/javax/jms/JMSConnectionFactoryDefinition.html] After 1-4 steps, the result indicated following (see details below) sendMessage11/20 operations are not enrolled in the transaction, whereas other sendMessage11/20 operations are rolled back as expected. sendMessage11(annotationCF, annotationQueue, "annotationCF + annotationQueue 1.1"); sendMessage11(annotationCF, resourcesQueue, "annotationCF + resourcesQueue 1.1"); sendMessage20CreateContext(annotationCF, annotationQueue, "annotationCF + annotationQueue + created context 2.0"); sendMessage20CreateContext(annotationCF, resourcesQueue, "annotationCF + resourcesQueue + created context 2.0"); sendMessage20(annotationInjectedContext, annotationQueue, "annotationInjectedContext + annotationQueue 2.0"); sendMessage20(annotationInjectedContext, resourcesQueue, "annotationInjectedContext + annotationQueue 2.0"); ========'imqcmd list/query msg' outputs after the test, notices the SEND_HOW property values imqcmd list msg -t q -n annotationQueue -u admin -pw admin -nocheck Listing messages for the destination ------------------------------------ Destination Name Destination Type ------------------------------------ annotationQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 ------------------------------------------------------------------------------------------------ Message # Message IDs Priority Body Type ------------------------------------------------------------------------------------------------ 0 ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749 4 TextMessage 1 ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874 4 TextMessage 2 ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889 4 TextMessage Successfully listed messages. imqcmd query msg -t q -n annotationQueue -msgID "ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749" -nocheck Querying message: ----------------------------------------------------------- Message ID ----------------------------------------------------------- ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749 In the destination ------------------------------------ Destination Name Destination Type ------------------------------------ annotationQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 -------------------------- Message Header Information -------------------------- Message ID ID:189-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374749 Correlation ID Destination Name annotationQueue Destination Type Queue Delivery Mode PERSISTENT (2) Priority 4 Redelivered false Timestamp 2/26/14 10:09:34 PM Type Expiration 12/31/69 4:00:00 PM ReplyTo Destination Name ReplyTo Destination Type ------------------------------ Message Properties Information ------------------------------ SEND_HOW annotationCF + annotationQueue 1.1 ------------------------ Message Body Information ------------------------ Body Type TextMessage (1) Successfully queried message. imqcmd query msg -t q -n annotationQueue -msgID "ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874" -nocheck Querying message: ----------------------------------------------------------- Message ID ----------------------------------------------------------- ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874 In the destination ------------------------------------ Destination Name Destination Type ------------------------------------ annotationQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 -------------------------- Message Header Information -------------------------- Message ID ID:219-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374874 Correlation ID Destination Name annotationQueue Destination Type Queue Delivery Mode PERSISTENT (2) Priority 4 Redelivered false Timestamp 2/26/14 10:09:34 PM Type Expiration 12/31/69 4:00:00 PM ReplyTo Destination Name ReplyTo Destination Type ------------------------------ Message Properties Information ------------------------------ SEND_HOW annotationCF + annotationQueue + created context 2.0 ------------------------ Message Body Information ------------------------ Body Type TextMessage (1) Successfully queried message. imqcmd query msg -t q -n annotationQueue -msgID "ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889" -nocheck Querying message: ----------------------------------------------------------- Message ID ----------------------------------------------------------- ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889 In the destination ------------------------------------ Destination Name Destination Type ------------------------------------ annotationQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 -------------------------- Message Header Information -------------------------- Message ID ID:249-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374889 Correlation ID Destination Name annotationQueue Destination Type Queue Delivery Mode PERSISTENT (2) Priority 4 Redelivered false Timestamp 2/26/14 10:09:34 PM Type Expiration 12/31/69 4:00:00 PM ReplyTo Destination Name ReplyTo Destination Type ------------------------------ Message Properties Information ------------------------------ SEND_HOW annotationInjectedContext + annotationQueue 2.0 ------------------------ Message Body Information ------------------------ Body Type TextMessage (1) Successfully queried message. imqcmd list msg -t q -n resourcesQueue -nocheck Listing messages for the destination ------------------------------------ Destination Name Destination Type ------------------------------------ resourcesQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 ------------------------------------------------------------------------------------------------ Message # Message IDs Priority Body Type ------------------------------------------------------------------------------------------------ 0 ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764 4 TextMessage 1 ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878 4 TextMessage 2 ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890 4 TextMessage Successfully listed messages. imqcmd query msg -t q -n resourcesQueue -msgID "ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764" -nocheck Querying message: ----------------------------------------------------------- Message ID ----------------------------------------------------------- ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764 In the destination ------------------------------------ Destination Name Destination Type ------------------------------------ resourcesQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 -------------------------- Message Header Information -------------------------- Message ID ID:203-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374764 Correlation ID Destination Name resourcesQueue Destination Type Queue Delivery Mode PERSISTENT (2) Priority 4 Redelivered false Timestamp 2/26/14 10:09:34 PM Type Expiration 12/31/69 4:00:00 PM ReplyTo Destination Name ReplyTo Destination Type ------------------------------ Message Properties Information ------------------------------ SEND_HOW annotationCF + resourcesQueue 1.1 ------------------------ Message Body Information ------------------------ Body Type TextMessage (1) Successfully queried message. imqcmd query msg -t q -n resourcesQueue -msgID "ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878" -nocheck Querying message: ----------------------------------------------------------- Message ID ----------------------------------------------------------- ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878 In the destination ------------------------------------ Destination Name Destination Type ------------------------------------ resourcesQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 -------------------------- Message Header Information -------------------------- Message ID ID:233-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374878 Correlation ID Destination Name resourcesQueue Destination Type Queue Delivery Mode PERSISTENT (2) Priority 4 Redelivered false Timestamp 2/26/14 10:09:34 PM Type Expiration 12/31/69 4:00:00 PM ReplyTo Destination Name ReplyTo Destination Type ------------------------------ Message Properties Information ------------------------------ SEND_HOW annotationCF + resourcesQueue + created context 2.0 ------------------------ Message Body Information ------------------------ Body Type TextMessage (1) Successfully queried message. imqcmd query msg -t q -n resourcesQueue -msgID "ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890" -nocheck Querying message: ----------------------------------------------------------- Message ID ----------------------------------------------------------- ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890 In the destination ------------------------------------ Destination Name Destination Type ------------------------------------ resourcesQueue Queue On the broker specified by: ------------------------- Host Primary Port ------------------------- localhost 7676 -------------------------- Message Header Information -------------------------- Message ID ID:255-10.133.184.56(be:d9:f1:7e:86:f3)-55441-1393481374890 Correlation ID Destination Name resourcesQueue Destination Type Queue Delivery Mode PERSISTENT (2) Priority 4 Redelivered false Timestamp 2/26/14 10:09:34 PM Type Expiration 12/31/69 4:00:00 PM ReplyTo Destination Name ReplyTo Destination Type ------------------------------ Message Properties Information ------------------------------ SEND_HOW annotationInjectedContext + annotationQueue 2.0 ------------------------ Message Body Information ------------------------ Body Type TextMessage (1) Successfully queried message. =============================================================
          Hide
          Nigel Deakin added a comment -

          We confirm that there is a bug when a connection factory is defined using the @JMSConnectionFactory annotation which prevents resources being enlisted in the Java EE transaction. Many thanks for reporting this.

          Show
          Nigel Deakin added a comment - We confirm that there is a bug when a connection factory is defined using the @JMSConnectionFactory annotation which prevents resources being enlisted in the Java EE transaction. Many thanks for reporting this.
          Hide
          Nigel Deakin added a comment -

          There is a workaround which is to create the connection factory the "old" way, which is to define it in glassfish-resources.xml, or using the GlassFish admin console or asadmin, and then inject it into the application using @Resource.

          Since there is a workaround this is a "major bug" rather than a "blocker". Adjusting priority accordingly.

          Show
          Nigel Deakin added a comment - There is a workaround which is to create the connection factory the "old" way, which is to define it in glassfish-resources.xml , or using the GlassFish admin console or asadmin, and then inject it into the application using @Resource . Since there is a workaround this is a "major bug" rather than a "blocker". Adjusting priority accordingly.
          Hide
          David Zhao added a comment -

          The property "org.glassfish.connector-connection-pool.transaction-support=XATransaction" is required for annotated JMS ConnectionFactory being enlisted. Otherwise, it will not participate to EE transaction.

          @JMSConnectionFactoryDefinition(
                  name = "java:module/jms/annotationCF",
                  maxPoolSize = 30,
                  minPoolSize = 20,
                  interfaceName = "javax.jms.TopicXAConnectionFactory",
                  properties = {
                      "addressList=mq://localhost:7676",
                      "reconnectEnabled=true",
                      "org.glassfish.connector-connection-pool.transaction-support=XATransaction"
                  }
          )
          

          To be consistent to the JMS ConnectionFactory created by asadmin or admin gui, the property of annotated JMS ConnectionFactory might be better to default to XATransaction.

          Show
          David Zhao added a comment - The property "org.glassfish.connector-connection-pool.transaction-support=XATransaction" is required for annotated JMS ConnectionFactory being enlisted. Otherwise, it will not participate to EE transaction. @JMSConnectionFactoryDefinition( name = "java:module/jms/annotationCF" , maxPoolSize = 30, minPoolSize = 20, interfaceName = "javax.jms.TopicXAConnectionFactory" , properties = { "addressList=mq: //localhost:7676" , "reconnectEnabled= true " , "org.glassfish.connector-connection-pool.transaction-support=XATransaction" } ) To be consistent to the JMS ConnectionFactory created by asadmin or admin gui, the property of annotated JMS ConnectionFactory might be better to default to XATransaction.
          Hide
          David Zhao added a comment -

          Fixed it by revision 63256. Make XATransaction to be the default value of annotated jms connection factory.

          Show
          David Zhao added a comment - Fixed it by revision 63256. Make XATransaction to be the default value of annotated jms connection factory.

            People

            • Assignee:
              David Zhao
              Reporter:
              pranahata
            • Votes:
              3 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: