2 Replies Latest reply on Jul 21, 2004 1:45 PM by abalanescu

    Problems receiving JMS-Message in MDB

    abalanescu

      -I want to test a simple queue-example without changing any jboss-/jms-configuration files.
      -The message seems to be sent - the client/caller proceeds runtime without exceptions, see below "console-output" on 6. info-item.
      -But the MDB's onMessage()-method isn't entered - even while ConnectionReceiverOILClient seems to be connected, see below "server.log-output" on 6. info-item.

      What is wrong in my configuration/code?

      I attach the following infos:

      1. ejb-jar.xml

      <enterprise-beans>
       <message-driven>
       <display-name>SalesFinalizerMDB</display-name>
       <ejb-name>SalesFinalizerMDB</ejb-name>
       <ejb-class>com.media_saturn.mdbtest.server.SalesFinalizer_MDB</ejb-class>
       <message-selector></message-selector>
       <transaction-type>Bean</transaction-type>
       <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
       <resource-env-ref>
       <resource-env-ref-name>queue/testQueue</resource-env-ref-name>
       <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
       </resource-env-ref>
       </message-driven>
       </enterprise-beans>


      2. jboss-xml

      <enterprise-beans>
       <message-driven>
       <ejb-name>SalesFinalizerMDB</ejb-name>
       <configuration-name>Standard Message Driven Bean</configuration-name>
       <destination-jndi-name>queue/testQueue</destination-jndi-name>
       <resource-env-ref>
       <resource-env-ref-name>queue/testQueue</resource-env-ref-name>
       <jndi-name>queue/testQueue</jndi-name>
       </resource-env-ref>
       </message-driven>
       </enterprise-beans>


      3. Client/Caller (POJO)

      package com.media_saturn.mdbtest.client;
      
      import java.util.Properties;
      
      import javax.naming.*;
      import javax.jms.*;
      
      
      public class SalesFinalizer_Caller {
      
       private static Context context;
      
       public static void main(String[] args)
       {
       setupENV();
       String s = "ConnectionFactory";
       System.out.println(s);
      
       QueueConnectionFactory fact = (QueueConnectionFactory) context.lookup(s);
       QueueConnection conn = null;
       QueueSession session = null;
       QueueSender sender = null;
       try
       {
       conn = fact.createQueueConnection();
       session = conn.createQueueSession(true, QueueSession.AUTO_ACKNOWLEDGE);
       Message message = session.createMapMessage();
       message.setStringProperty("paymenttype", "cash");
       Queue queue = (Queue) context.lookup("queue/testQueue");
       sender = session.createSender(queue);
       sender.send(message);
       }
       catch (Exception e)
       {
       e.printStackTrace();
       }
       finally
       {
       if (sender != null) sender.close();
       if (session != null) session.close();
       if (conn != null) conn.close();
       fact = null;
       }
       System.out.println("FINISHED CALL!");
       }
      
       private static void setupENV()
       {
       try
       {
       Properties properties = new Properties();
      
       properties.put(Context.INITIAL_CONTEXT_FACTORY,
       "org.jnp.interfaces.NamingContextFactory");
       properties.put(Context.PROVIDER_URL,"jnp://localhost:1099");
      
       context = new InitialContext(properties);
       }
       catch (Exception e)
       {
       e.printStackTrace();
       }
       }
      
      }
      


      I've tried the messaging also with all explicit Connectionfactory-types (e.g. RMI, OIL/2, UIL/2), but no success.

      4. MDB

      package com.media_saturn.mdbtest.server;
      
      import javax.ejb.*;
      import javax.jms.*;
      
      public class SalesFinalizer_MDB implements
       MessageDrivenBean, MessageListener {
       private transient MessageDrivenContext ctx;
       public void setMessageDrivenContext(MessageDrivenContext ctx)
       { this.ctx = ctx; }
       public void ejbCreate() {}
       public void ejbRemove() { this.ctx = null; }
      
       public void onMessage(Message inMessage) {
       System.out.println("ENTERED onMessage!");
       ....


      5. Jmx-console

      -MDB is deployed (but is shown wrongly as EntityBean?!)
      EJBModule=mdbtest.jar,J2EEApplication=null,J2EEServer=Local,j2eeType=EntityBean,name=SalesFinalizerMDB

      -One Receiver is registered for queue/testQueue
      [org.jboss.mq.Subscription{connection=SpyDistributedConnection:ID:1/4d33289e6b666991fbe44ba40e733fa4 subscriptionId=-2147483648 destination=QUEUE.testQueue messageSelector=null Local Create}]


      6. Further Infos

      -The MDB is packed into a mdbtest.jar, which is deployed as singular JAR/EAR on this jboss-instance
      -The console-output is:
      ConnectionFactory
       FINISHED CALL!

      -The server.log-output is:
      2004-07-21 15:25:40,801 DEBUG [org.jboss.mq.il.oil.OILClientIL] ConnectionReceiverOILClient is connecting to: 172.16.15.123:2158
      2004-07-21 15:25:40,803 INFO [TxConnectionManager] getManagedConnection returning unassociated connection
      2004-07-21 15:25:40,805 INFO [TxConnectionManager] getManagedConnection returning unassociated connection




      Thanks in advance for your help.

      Alexander R. Balanescu (a.balanescu@gmx.net)
      I'm working at the moment for the german client "Media Saturn Systemzentrale" (balanescu@media-saturn.com)