3 Replies Latest reply on Jul 29, 2004 9:56 AM by vijaygrk

    MDB -Problems Recieving Messages

    vijaygrk

      I have a Simple MDB which logs the message from a queue. When i deploy the bean, it looks like its ignoring the destination i have given and it creates a temporary queue and listens for messages from the queue.

      The MDB
      public class AFMessageProcessorBean implements MessageDrivenBean, MessageListener{
       private final static Logger log = Logger.getLogger("com.vfa.assetfusion.queue.AFMessageProcessor");
       private MessageDrivenContext ctx = null;
      
       public void setMessageDrivenContext(MessageDrivenContext ctx){
       this.ctx = ctx;
       }
      
      
       public void ejbCreate(){
       }
       public void ejbRemove(){
       this.ctx = null;
       }
      
       public void onMessage(Message msg){
       log.debug("onMessage");
       try{
       TextMessage tm = (TextMessage) msg;
       String text = tm.getText();
       log.debug("I am from the MDB");
       }
       catch(JMSException e){
       log.error("onMessage error", e);
       }
       }
      }


      Jboss.xml
      <?xml version="1.0"?>
      <enterprise-beans>
       <message-driven>
       <ejb-name>AFMessageProcessorEJB</ejb-name>
       <destination-jndi-name>queue/test</destination-jndi-name>
       </message-driven>
      </enterprise-beans>


      ejb-jar.xml
      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar
       PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
       "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>
       <message-driven>
       <ejb-name>AFMessageProcessorEJB</ejb-name>
       <ejb-class>com.vfa.assetfusion.queue.AFMessageProcessorBean</ejb-class>
       <message-selector>MessageFormat = 'Version 3.4'</message-selector>
       <transaction-type>Container</transaction-type>
       <acknowledge-mode>auto-acknowledge</acknowledge-mode>
      
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
       </message-driven>
       </enterprise-beans>
      </ejb-jar>


        • 1. Re: MDB -Problems Recieving Messages

          Jboss creates a temporary destination only if the queue does not exist at the time the MDB is deployed. Are you sure queue/test is created first? In which file are you declaring it?

          Also, you can add a depends tag in your jboss.xml to depend on the Queue's MBean.

          Regards,

          Stephane

          • 2. Re: MDB -Problems Recieving Messages
            vijaygrk

            I modified jboss-destinations-service.xml to add my queue. Here is log.
            Take look at the timestamp. The queue gets deployed before the bean. But still it looks for the wrong destination and throwing an exception

            09:01:56,437 INFO [vfa] Bound to JNDI name: queue/vfa
            09:01:56,437 INFO [vfa] Started jboss.mq.destination:service=Queue,name=vfa

            09:01:56,997 INFO [EjbModule] Deploying AFMessageProcessorEJB
            09:01:57,168 WARN [JMSContainerInvoker] destination not found: queue/AFMessageProcessorEJB reason: javax.naming.NameNotFoundException: AFMessageProcessorEJB not bound
            09:01:57,168 WARN [JMSContainerInvoker] creating a new temporary destination: queue/AFMessageProcessorEJB
            09:01:57,178 INFO [AFMessageProcessorEJB] Bound to JNDI name: queue/AFMessageProcessorEJB
            09:01:57,178 INFO [AFMessageProcessorEJB] Started jboss.mq.destination:service=Queue,name=AFMessageProcessorEJB
            09:01:57,258 INFO [DLQHandler] Started null
            09:01:57,258 INFO [JMSContainerInvoker] Started jboss.j2ee:binding=message-driven-bean,jndiName=local/AFMessageProcessorEJB,plugin=invoker,service=EJB
            09:01:57,258 INFO [MessageDrivenInstancePool] Started jboss.j2ee:jndiName=local/AFMessageProcessorEJB,plugin=pool,service=EJB
            09:01:57,258 INFO [MessageDrivenContainer] Started jboss.j2ee:jndiName=local/AFMessageProcessorEJB,service=EJB
            09:01:57,258 INFO [EjbModule] Started jboss.j2ee:module=afmsgproc.jar,service=EjbModule
            09:01:57,258 INFO [EJBDeployer] Deployed: file:/C:/TEMP/jboss-3.2.3/server/all/deploy/afmsgproc.jar
            09:01:57,308 INFO [MainDeployer] Deployed package: file:/C:/TEMP/jboss-3.2.3/server/all/deploy/afmsgproc.jar

            • 3. Re: MDB -Problems Recieving Messages
              vijaygrk

              Fixed it. jboss.xml was not in the right format.
              It was missing the jboss tag at the start
              Thanks everyone for your replies