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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: