0 Replies Latest reply on Apr 16, 2010 7:47 AM by dimitarn

    Processing messages from topics through statless beans + MDB

    dimitarn

      Hi

      I have active mq consumers(each subscribed for a topic) which receives messages.

       

       

      public class ActiveMQConsumer implements ExtendedMessageListener {
      
          private static final Logger logger = Logger.getLogger(ActiveMQConsumer.class);
      
          IProcessor processor;
      
          public ActiveMQConsumer(IProcessor processor) {
          this.processor = processor;
          }
      
          @Override
          public void onMessage(Message jmsMessage) {
          System.out.println("ActiveMQConsumer " + jmsMessage.getClass() + " "  + jmsMessage);
          if (jmsMessage instanceof TextMessage) {
              try {
              processor.process(((TextMessage) jmsMessage).getText());
              } catch (JMSException e) {
              logger.error("ActiveMQConsumer::onMessage ", e);
              }
          }
          }
      
          @Override
          public void onException(JMSException e) {
          logger.error("ActiveMQConsumer::onException ", e);
          }
      
      }
      

       

      After the jmsMessage comes it send it to a processor which is stateless bean.

      My warnings are:

      1) Can the

      ActiveMQConsumer, which is not a statless bean, be overrheaded by the messages.Should i do is a statless bean? 
      2)In the processor statless bean i intend to send all messages which comes from all consumers to a queue and
      a MDB will consume the messages there to do operations with them? Is this a good aproach, taking the fakt that
      statless bean do not execute method asynchroniously? Or it will be just fine if i do the operations in the
      statless bean processor?