[英]Configuring an MDB to listen to multiple queues
我正在使用 EJB 3.1,我想配置一个 MDB 来监听多个队列。
我更喜欢通过 XML 定义队列名称,但通过注释定义其他定义。
这可以做到吗?
实例化后,MDB 只能侦听其目标 ActivationConfigProperty 中指定的资源,但是您可以创建具有不同目标(在您的情况下为队列)的同一 MDB 的多个实例。
在您的 ejb-jar.xml 中创建两个条目,它们具有不同的目标和 ejb-name 属性,但具有相同的 ejb-class。
使用 ejb-jar.xml 代替 ibm-ejb-jar-bnd.xml
<message-driven>
<ejb-name>MessageDrivenBean1</ejb-name>
<ejb-class>com.sample.MessageDrivenBean</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
<message-driven>
<ejb-name>MessageDrivenBean2</ejb-name>
<ejb-class>com.sample.MessageDrivenBean</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
'@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.