mq
  1. mq
  2. MQ-264

Async receiver does not receive the message

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Here is a trivial MessageSender:

      @Stateless
      public class MessageSender {
      
          @Inject
          JMSContext context;
      
          @Resource(lookup = "java:global/jms/myQueue")
          Queue queue;
      
          public void sendMessage(String message) {
              context.createProducer().send(queue, message);
          }
      }
      

      The following message receiver works fine:

      @Stateless
      public class MessageReceiverSync {
      
          @Inject
          private JMSContext context;
      
          @Resource(lookup = "java:global/jms/myQueue")
          Queue myQueue;
      
          public String receiveMessage() {
              String message = context.createConsumer(myQueue).receiveBody(String.class, 1000);
              return "Received " + message;
          }
      }
      

      But the following one does not receive the message:

      @MessageDriven(mappedName = "java:global/jms/myQueue")
      public class MessageReceiverAsync implements MessageListener {
      
          @Override
          public void onMessage(Message message) {
              try {
                  TextMessage tm = (TextMessage) message;
                  System.out.println("Message received: " + tm.getText());
              } catch (JMSException ex) {
      Logger.getLogger(MessageReceiverAsync.class.getName()).log(Level.SEVERE, null, ex);
              }
          }
      } 
      

      The destination definition is defined as:

      @JMSDestinationDefinition(name = "java:global/jms/myQueue",
              resourceAdapterName = "jmsra",
              className = "javax.jms.Queue",
              destinationName="java:global/jms/myQueue",
              description="My Queue")
      @WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"})
      public class TestServlet extends HttpServlet {
      

        Issue Links

          Activity

          arungupta created issue -
          Nigel Deakin made changes -
          Field Original Value New Value
          Description Here is a trivial MessageSender:

          @Stateless
          public class MessageSender {

              @Inject
              JMSContext context;

              @Resource(lookup = "java:global/jms/myQueue")
              Queue queue;

              public void sendMessage(String message) {
                  context.createProducer().send(queue, message);
              }
          }


          The following message receiver works fine:

          @Stateless
          public class MessageReceiverSync {

              @Inject
              private JMSContext context;

              @Resource(lookup = "java:global/jms/myQueue")
              Queue myQueue;

              public String receiveMessage() {
                  String message = context.createConsumer(myQueue).receiveBody(String.class, 1000);
                  return "Received " + message;
              }
          }

          But the following one does not receive the message:

          @MessageDriven(mappedName = "java:global/jms/myQueue")
          public class MessageReceiverAsync implements MessageListener {

              @Override
              public void onMessage(Message message) {
                  try {
                      TextMessage tm = (TextMessage) message;
                      System.out.println("Message received: " + tm.getText());
                  } catch (JMSException ex) {
          Logger.getLogger(MessageReceiverAsync.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
          }

          The destination definition is defined as:

          @JMSDestinationDefinition(name = "java:global/jms/myQueue",
                  resourceAdapterName = "jmsra",
                  className = "javax.jms.Queue",
                  destinationName="java:global/jms/myQueue",
                  description="My Queue")
          @WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"})
          public class TestServlet extends HttpServlet {
              
          Here is a trivial MessageSender:

          {noformat}
          @Stateless
          public class MessageSender {

              @Inject
              JMSContext context;

              @Resource(lookup = "java:global/jms/myQueue")
              Queue queue;

              public void sendMessage(String message) {
                  context.createProducer().send(queue, message);
              }
          }
          {noformat}

          The following message receiver works fine:

          {noformat}
          @Stateless
          public class MessageReceiverSync {

              @Inject
              private JMSContext context;

              @Resource(lookup = "java:global/jms/myQueue")
              Queue myQueue;

              public String receiveMessage() {
                  String message = context.createConsumer(myQueue).receiveBody(String.class, 1000);
                  return "Received " + message;
              }
          }
          {noformat}

          But the following one does not receive the message:

          {noformat}
          @MessageDriven(mappedName = "java:global/jms/myQueue")
          public class MessageReceiverAsync implements MessageListener {

              @Override
              public void onMessage(Message message) {
                  try {
                      TextMessage tm = (TextMessage) message;
                      System.out.println("Message received: " + tm.getText());
                  } catch (JMSException ex) {
          Logger.getLogger(MessageReceiverAsync.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
          }
          {noformat}

          The destination definition is defined as:

          {noformat}
          @JMSDestinationDefinition(name = "java:global/jms/myQueue",
                  resourceAdapterName = "jmsra",
                  className = "javax.jms.Queue",
                  destinationName="java:global/jms/myQueue",
                  description="My Queue")
          @WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"})
          public class TestServlet extends HttpServlet {
          {noformat}
          Ed Bratt made changes -
          Assignee Ed Bratt [ ebratt ] amyk [ amyk ]
          amyk made changes -
          Affects Version/s 5.0 [ 10173 ]
          amyk made changes -
          Affects Version/s 5.0 [ 10173 ]
          Nigel Deakin made changes -
          Link This issue duplicates GLASSFISH-19492 [ GLASSFISH-19492 ]
          amyk made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Duplicate [ 3 ]

            People

            • Assignee:
              amyk
              Reporter:
              arungupta
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: