Injecting queue in EJB and using it
zecas Mar 21, 2011 1:20 PMHi,
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.