jms-spec
  1. jms-spec
  2. JMS_SPEC-100

Allow Java EE components other than MDBs to consume messages asynchronously

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      This proposal suggests the addition of the following annotation: @MessageSelector, to be used on a @MessageDriven bean consumimng a Queue or as Topic Subscriber.

      Example:

      package sample;
      
      // imports
      
      @MessageDriven(mappedName = "jms/queue0")
      public class MessageSelectorBean implements MessageListener {
      
        @Resource(lookup = "jms/connectionFactory")
        ConnectionFactory connectionFactory;
      
        @MessageSelector("(StockSector = 'Technology')")
        public void onMessage(Message message) {
          try (JMSContext context = connectionFactory.createContext()) {
            String request = ((TextMessage)message).getText();
            Destination replyDestination = message.getJMSReplyTo();
            TextMessage replyMessage = context.createTextMessage("Reply to: "+request);
            context.createProducer().send(replyDestination, replyMessage);
         } catch (JMSException ex) {
           // log an error here
         }
        }
      }
      

        Issue Links

          Activity

          Bruno Borges created issue -
          John D. Ament made changes -
          Field Original Value New Value
          Tags jms21-forreview-major
          Nigel Deakin made changes -
          Affects Version/s 2.0 [ 14692 ]
          Description This proposal suggests the addition of the following annotation: @MessageSelector, to be used on a @MessageDriven bean consumimng a Queue or as Topic Subscriber.

          Example:

          package sample;

          // imports

          @MessageDriven(mappedName = "jms/queue0")
          public class MessageSelectorBean implements MessageListener {

            @Resource(lookup = "jms/connectionFactory")
            ConnectionFactory connectionFactory;

            @MessageSelector("(StockSector = 'Technology')")
            public void onMessage(Message message) {
              try (JMSContext context = connectionFactory.createContext()) {
                String request = ((TextMessage)message).getText();
                Destination replyDestination = message.getJMSReplyTo();
                TextMessage replyMessage = context.createTextMessage("Reply to: "+request);
                context.createProducer().send(replyDestination, replyMessage);
             } catch (JMSException ex) {
               // log an error here
             }
            }
          }
          This proposal suggests the addition of the following annotation: @MessageSelector, to be used on a @MessageDriven bean consumimng a Queue or as Topic Subscriber.

          Example:

          {noformat}
          package sample;

          // imports

          @MessageDriven(mappedName = "jms/queue0")
          public class MessageSelectorBean implements MessageListener {

            @Resource(lookup = "jms/connectionFactory")
            ConnectionFactory connectionFactory;

            @MessageSelector("(StockSector = 'Technology')")
            public void onMessage(Message message) {
              try (JMSContext context = connectionFactory.createContext()) {
                String request = ((TextMessage)message).getText();
                Destination replyDestination = message.getJMSReplyTo();
                TextMessage replyMessage = context.createTextMessage("Reply to: "+request);
                context.createProducer().send(replyDestination, replyMessage);
             } catch (JMSException ex) {
               // log an error here
             }
            }
          }
          {noformat}
          John D. Ament made changes -
          Link This issue depends on EJB_SPEC-60 [ EJB_SPEC-60 ]
          Nigel Deakin made changes -
          Summary Support for Annotation @MessageSelector on MessageDriven bean Allow Java EE components other than MDBs to consume messages asynchronously
          Nigel Deakin made changes -
          Link This issue is related to JMS_SPEC-134 [ JMS_SPEC-134 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Bruno Borges
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: