[英]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.