3 Replies Latest reply on Jun 2, 2008 11:42 AM by jonathanztaub

    MDB does not consume messages

    jonathanztaub Newbie

      I'm using JBoss 4.2.2 on a Windows XP.
      I was able to configure JMS settings and am now able to send JMS messages to a queue and I can see the messages stored in my MySQL database. The problem is that the MDB does not seem to consume any messages.

      Here are snippets from the ejb-jar.xml (EJB 3) deployment descriptor (I make minimal usage of annotations):

      <?xml version="1.0"?>

      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
      version="3.0">

      <enterprise-beans>

      <message-driven>
      <ejb-name>ServiceProcessorBean</ejb-name>
      <ejb-class>com.mobilexl.server.ejb.ServiceProcessorBean</ejb-class>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <activation-config>

      <activation-config-property>
      <activation-config-property-name>destinationType</activation-config-property-name>
      <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
      </activation-config-property>

      <activation-config-property>
      <activation-config-property-name>messageSelector</activation-config-property-name>
      <activation-config-property-value>MessageFormat = 'Version 3.4'</activation-config-property-value>
      </activation-config-property>

      <activation-config-property>
      <activation-config-property-name>acknowledgeMode</activation-config-property-name>
      <activation-config-property-value>Auto-acknowledge</activation-config-property-value>
      </activation-config-property>

      <activation-config-property>
      <activation-config-property-name>destination</activation-config-property-name>
      <activation-config-property-value>queue/ServiceRequest</activation-config-property-value>
      </activation-config-property>

      </activation-config>

      </message-driven>

      </enterprise-beans>

      </ejb-jar>

      I know that the application server examines this because if I omit the destintation property, I'm getting errors.

      The jboss.xml looks like:

      <?xml version="1.0"?>

      <jboss xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
      version="3.0">

      <enterprise-beans>
      <message-driven>
      <ejb-name>ServiceProcessorBean</ejb-name>
      <destination-jndi-name>queue/ServiceRequest</destination-jndi-name>
      </message-driven>

      </enterprise-beans>



      The jboss-destinations-service.xml looks like:


      <!-- Destination without a configured SecurityManager or without a
      a SecurityConf will default to role guest with read=true, write=true, create=false.
      -->


      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
      queue/ServiceRequest




      (if I remove the queue defintions from here, upon startup, JBoss issues a warn level log statement saying that the queue cannot be found and it creates one).

      Using the JMS console, I'm able to see the queue and my message driven bean. The code for the message driven bean is:

      ...
      ...
      public class ServiceProcessorBean implements MessageListener
      {
      private static final Logger logger = Logger.getLogger(ServiceProcessorBean.class);


      public ServiceProcessorBean()
      {
      logger.info("------- in MDB's constructor -------");
      System.out.println("------- in MDB's constructor ------ sysout");

      }



      public void onMessage(Message message)
      {
      logger.fatal("----------- onMessage ------------");
      try
      {
      TextMessage textMessage = (TextMessage)message;
      logger.info("In MDB: " + textMessage.getText());
      }
      catch(JMSException e)
      {
      logger.error("Failed to process request.", e);
      }
      }
      }

      I put logging on the onMessage and in the constructor just to see if an object is being instantiated and whether the MDB consumes messages. NON of these is happening.

      In the JMX console, under jboss.j2ee, I see:
      ear=mobile-xl-server-1.0-SNAPSHOT.ear,jar=ejb-1.0-SNAPSHOT.jar,name=ServiceProcessorBean,service=EJB3

      I was able to get over the configuration part and it seems like messages are stored correctly (I omitted all session bean related code that sends the messages for brevity). However, I cannot figure out why the message driven bean is not activated/instantiated.

        • 1. Re: MDB does not consume messages
          jonathanztaub Newbie

          If it matters, the timer service is not installed.
          The log message is:

          WARN [JBossTimerServiceFactory] TIMER SERVICE IS NOT INSTALLED

          Though I don't believe it matters.

          • 2. Re: MDB does not consume messages
            jaikiran pai Master

            How about removing this message selector part and running your application again? Probably the messages sent to the queue do not match this selector and hence the MDB is not picking it up.

            <activation-config-property>
            <activation-config-property-name>messageSelector</activation-config-property-name>
            <activation-config-property-value>MessageFormat = 'Version 3.4'</activation-config-property-value>
            </activation-config-property>


            P.S:While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

            • 3. Re: MDB does not consume messages
              jonathanztaub Newbie

               

              "jaikiran" wrote:
              How about removing this message selector part and running your application again? Probably the messages sent to the queue do not match this selector and hence the MDB is not picking it up.

              <activation-config-property>
              <activation-config-property-name>messageSelector</activation-config-property-name>
              <activation-config-property-value>MessageFormat = 'Version 3.4'</activation-config-property-value>
              </activation-config-property>


              P.S:While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted


              I actually figured this out yesterday and meant to post a reply about it.
              Yes, that was the gotch! I copied everything from an example and ended up matching it against various sample xml I found on the web.
              Thanks.