2 Replies Latest reply on Mar 22, 2011 2:24 PM by zecas zecas

    Injecting queue in EJB and using it

    zecas zecas Newbie

      Hi,

       

       

      I need some help, as I'm getting very frustrated with JBoss.

       

       

      I'm developing an application in JBoss, that will run on Websphere. I'm trying to inject a queue into an EJB, but I can't seem to make it work.

       

       

      My queue definition in MyIN-service.xml, on JBoss deploy directory:

       

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <server>

          <mbean xmbean-dd="xmdesc/Queue-xmbean.xml" name="jboss.messaging.destination:service=Queue,name=MyInput" code="org.jboss.jms.server.destination.QueueService">

              <attribute name="JNDIName">MyIN</attribute>

              <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

              <depends>jboss.messaging:service=PostOffice</depends>

          </mbean>

      </server>

       

       

      My EJB:

       

       

      @Stateless(name="my-proc")

      public class MyProc implements MyProcRemote, MyProcLocal {

       

       

                @Resource(mappedName="ConnectionFactory") QueueConnectionFactory factory;

                @Resource(mappedName="queue/MyInput") Queue destinationQueue;

       

       

          /**

           * Default constructor.

           */

          public MyProcessor() {

          }

       

       

          /**

           * {@inheritDoc}

           */

          @TransactionAttribute(TransactionAttributeType.REQUIRED)

                public void log(String message) {

                          System.out.println("Received Message: [" + message + "]");

                }

       

       

      }

       

       

      The problem is, it freezes when calling the EJB ... if I comment the Queue resource injection, it works fine, if I leave it as above, it just doesn't give any exception, the code just freezes on lookup, like if it can't inject the resource.

       

       

      I've already tried with "queue/MyIN" with same result.

       

       

      I'm struggling to define this behaviour in JBoss, without proprietary config files nor specific JBoss code, because I want to make it easy to port to Websphere.

       

       

      Need some help understanding how to define, and how it works. Also how can I find info about the queue in JMX console? I can find a "jboss.messaging.destination -> name=MyInput,service=Queue" but no info that tells me I must reference it with "queue/MyInput" ... I also thought that I should have something in my web.xml, but I have nothing.

       

       

      Thanks.

        • 1. Injecting queue in EJB and using it
          Wolf-Dieter Fink Master

          I suppose you are calling the log method, only to test whether the injection work, right?

          I use a similar configuration, difference is that there is a 'clustered' attribute instead of 'JNDIName'.

           

          In your case there is no message to proceed, the log call should work.

          Do you have more information about the JBoss configuration (can you test with a standard JBoss?)

          Maybe you can activate a full TRACE to see what happen?

          Also it would be helpful if you post the JBoss version.

          • 2. Injecting queue in EJB and using it
            zecas zecas Newbie

            Hi,

             

            Finally I found the problem: I need to inject the resource with name "MyIN", as defined in:

             

            <attribute name="JNDIName">MyIN</attribute>

             

            I'm using a log method just for test purposes, it will evolve to a more usefull business method, that will terminate with a message insertion on a queue.

             

            And my JBoss is 5.1.0 GA.

             

             

            Thanks.