9 Replies Latest reply on Jan 2, 2012 2:16 AM by jaikiran

    no response in message-driven bean!

    aupres

      I try to execute message-driven bean by using jboss 7 and eclipse indigo.

      First, I inserted a few codes into standalone.xml. The codes are

       

      .......

      <extension module="org.jboss.as.messaging"/>

      .......

      <subsystem xmlns="urn:jboss:domain:messaging:1.0">

                  <persistence-enabled>

                      false

                  </persistence-enabled>

      ..........

                  <connectors>

                      <netty-connector name="netty" socket-binding="messaging"/>

                      <netty-connector name="netty-throughput" socket-binding="messaging-throughput">

                          <param key="batch-delay" value="50"/>

                      </netty-connector>

                      <in-vm-connector name="in-vm" server-id="0"/>

                  </connectors>

      ..........

                  <jms-destinations>

                      <jms-queue name="testQueue">

                          <entry name="queue/testQueue"/>

                      </jms-queue>

                      <jms-topic name="testTopic">

                          <entry name="topic/test"/>

                      </jms-topic>

                  </jms-destinations>

              </subsystem>

      ............

      <socket-binding name="messaging" port="5445"/>

      <socket-binding name="messaging-throughput" port="5455"/>

      .....

       

      When executing Jboss 7, console shows the message queue was deployed.

       

      17:29:14,250 정보    [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) HornetQ Server version 2.2.7.Final (HQ_2_2_7_FINAL_AS7, 121) [532fd29a-3077-11e1-b630-90e6bab7cd02] started

      17:29:14,250 정보    [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) trying to deploy queue jms.queue.testQueue

      17:29:14,453 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-3) Bound messaging object to jndi name java:/queue/testQueue

      17:29:14,453 정보    [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.topic.testTopic

      17:29:14,468 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-1) Bound messaging object to jndi name java:/topic/test

      17:29:14,485 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-2) Bound messaging object to jndi name java:/ConnectionFactory

      17:29:14,485 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-4) Bound messaging object to jndi name java:/RemoteConnectionFactory

       

      And I made message-driven bean with Message Driven Bean Wizard of eclipse indigo.

      Value of Destination Name is queue/testQueue and Destination Type is Queue. Transaction type is Bean.

       

      Generated codes are like below :

       

      package com.aaa.jms;

       

      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.MessageDriven;
      import javax.jms.Message;
      import javax.jms.MessageListener;

       

      @MessageDriven(
        activationConfig = { @ActivationConfigProperty(
          propertyName = "destinationType", propertyValue = "javax.jms.Queue"
        ) },
        mappedName = "queue/testQueue")

      public class JMSBean implements MessageListener {

       

          public JMSBean() {
              // TODO Auto-generated constructor stub
          }

      public void onMessage(Message message) {
              // TODO Auto-generated method stub
           System.out.println("I got Message"); // No response !!
          }

      }

       

      Client is jsp file

       

      <body>

      <%

      try {

          Context ctx = new InitialContext();

          QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("/ConnectionFactory");

          Queue queue = (Queue) ctx.lookup("queue/testQueue");

          QueueConnection conn = qcf.createQueueConnection();

          QueueSession qs = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);

          conn.start();

          TextMessage msg = qs.createTextMessage();

          msg.setText("hello");

          MessageProducer producer = qs.createProducer(queue);

          producer.send(msg);

          out.println("Done"); 

          producer.close();

          qs.close();

          conn.close();

      } catch (Exception e) {

        out.println(e.getMessage());

      }

      %>

      </body>

       

      Client threw no exception.But No response either! It seems queue doesn't send recieved-message to Message driven bean.

      I have no idea what process I missed. Pls, inform me.

       

      Best Regards!

        • 1. Re: no response in message-driven bean!
          jaikiran

          The mappedName on the MessageDrivenBean will not be used as the target queue/topic. You'll need the "destination" activation config property like here https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagedrivencontext/SimpleMDB.java#L48

          • 2. Re: no response in message-driven bean!
            jaikiran

            I'm actually a bit surprised that the MDB deployed fine without that "destination" activation config property. Are you sure the EJB jar is being deployed?

            • 3. Re: no response in message-driven bean!
              aupres

              Thank you for your reply. I already use that annotation like below

               

              @MessageDriven(
                activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                                @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
                                @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
              public class MDBean implements MessageListener {

                

                 @Resource(mappedName="java:jboss/datasources/MySqlDS")
                  DataSource ds;

                  public MDBean() {
                      // TODO Auto-generated constructor stub
                  }

                  /**
                   * @see MessageListener#onMessage(Message)
                   */
                  public void onMessage(Message message) {
                      // TODO Auto-generated method stub
                   TextMessage m = (TextMessage) message;
                  
                   try {
                    System.out.println(m.getText());
                .....

               

              But the message-driven bean shows no response nor no exception. I can't understand why.

              These Beans without "destination" attribute are deployed well. The codes are generated by Eclipse Indigo Message-Driven Bean wizard.

              • 4. Re: no response in message-driven bean!
                sfcoy

                Th connection factory /ConnectionFactory that you're using does not work.

                 

                Try java:/JmsXA instead.

                • 5. Re: no response in message-driven bean!
                  aupres

                  Thank you for your reply, Stephen!

                   

                  I changed /ConnectionFactory to java:/jmsXA. But result was the same - no response and no exception.

                  I guess the message publishing part works well.

                  I think the problem is that message-driven bean which is generated by eclipse indigo can't handle the message of deployed queue.

                  Kindly inform me..

                  • 6. Re: no response in message-driven bean!
                    sfcoy

                    Try

                    @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/queue/test") 

                    instead.

                    • 7. Re: no response in message-driven bean!
                      sfcoy

                      Also, there's a demo app posted in http://community.jboss.org/thread/176701?tstart=0 which is known to work.

                      • 8. Re: no response in message-driven bean!
                        aupres

                        I think you are right, jaikiran. The message-driven bean I created in eclipse indigo seems not to be deployed, so client message can't not be shown!

                        Only jar project is deployed, not message-driven bean

                        This is the console message :

                         

                        10:03:58,313 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "JMSTestEAR.ear"
                        10:03:58,363 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "JMSTestWeb.war"
                        10:03:58,363 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) Starting deployment of "JMSTestEJB.jar"
                        10:03:58,423 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api dependency to JMSTestEAR.ear
                        10:03:58,423 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) added javax.persistence.api dependency to JMSTestWeb.war
                        10:03:58,423 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api dependency to JMSTestEJB.jar
                        10:03:58,653 INFO  [org.jboss.web] (MSC service thread 1-3) registering web context: /JMSTestWeb
                        10:03:58,653 INFO  [org.jboss.as] (MSC service thread 1-3) JBoss AS 7.0.2.Final "Arc" started in 3929ms - Started 164 of 229 services (65 services are passive or on-demand)
                        10:03:58,694 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "JMSTestEAR.ear"

                         

                        How can I make the jboss 7 message queue connected to message-driven bean?

                        • 9. Re: no response in message-driven bean!
                          jaikiran

                          10:03:58,653 INFO  [org.jboss.as] (MSC service thread 1-3) JBoss AS 7.0.2.Final "Arc" started in 3929ms - Started 164 of 229 services (65 services are passive or on-demand)

                          Are you sure the standalone profile that you are using doesn't have lite=true for the EJB3 subsystem? Or you could try this against the recently released 7.1.0.CR1 or even the latest nightly builds. It's even supposed to work with 7.0.2 (everything distribution and standalone-preview.xml profile). Try running it outside the IDE and see if that works.