开发者

Annotate StatelessBean with @Depends to HornetQ-JMS Queue

I have a simple definition of a JMS-Queue in the file my-hornetq-jms.xml:

<configuration xmlns="urn:hornetq"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
      <queue name="my.test.queue">  
        <entry name="/queue/myTest"/>  
      </queue>  
</configuration>

The queue is activated correctly and now I want to add a dependency in my @Stateless Bean. This question is similar to How can I ensure that the hornet queues are there when my webapp starts in JBOSS 6.0?, but I want to define the dependency with an annotation. I tried this (in several permutations), but didn't find the right way:

@Depends(value="org.hornetq:module=JMS,type=Queue,name=my.test.queue")

I always get errors like this:

Dependency "<UNKNOWN jboss.j2ee:jar=my.war,name=MyBean,service=EJB3>"
(should be in state "Installed", but is actually in state "** UNRESOLVED Demands
'org.hornetq:module=JMS,name=my.test.queue,type=Queue' **")

BTW: In JBoss-5 I have defined it l开发者_如何学编程ike this: @Depends(value = "jboss.messaging.destination:service=Queue,name=my.test.queue")


You should be able to define the dependency using this Bean name:

org.hornetq:module=JMS,type=Topic,name="YOUR-TOPIC-NAME"

or

org.hornetq:module=JMS,type=Queue,name="YOUR-TOPIC-NAME"

For more information, look at implementation of org.hornetq.api.core.management.ObjectNameBuilder, since the deployers are using methods here to define the names.

Also: This dependency between MBeans will only work on AS6 or EAP 5.1.1+. This won't work with AS5 or any other manual installation since the AS deployers are not installed on the manual installation.

Also: AS7 has a different injection dependency. This won't probably work on AS7 either. (I believe it's not needed, since you can just inject the JNDI name directly. i.e. it's done in a better way at AS7)


The errors described above occurred because I imported the wrong @Depends:

import org.jboss.ejb3.annotation.Depends; //WRONG
import org.jboss.beans.metadata.api.annotations.Depends; //CORRECT
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜