简体   繁体   English

EJB-消息驱动的Bean配置

[英]Ejb - message driven bean configuration

I have two message driven beans in my project. 我的项目中有两个消息驱动的bean。 Which one will be called by ejb container when a message is sent to queue. 将消息发送到队列时,ejb容器将调用哪一个。 Where is it configured which bean to invoke. 它在哪里配置要调用的bean。 What is use of ejb-jar.xml and ibm-ejb-jar-bnd. ejb-jar.xml和ibm-ejb-jar-bnd的用途是什么。 Xml. Xml。 Please explain 请解释

A Message driven bean (MDB) is associated with a JMS queue (or topic) through deployment descriptors or Java annotations. 消息驱动bean(MDB)通过部署描述符或Java注释与JMS队列(或主题)相关联。 The simplest form as from EE7 is with the use of annotations as follows: EE7中最简单的形式是使用注释,如下所示:

@MessageDriven(mappedName = "myQueue") @MessageDriven(mappedName =“ myQueue”)

public class MyMDB implements MessageListener { 公共类MyMDB实现MessageListener {

@Override public void onMessage(Message message) { @Override public void onMessage(消息){

.... ....

The mappedName attribute specifies the JNDI name of the JMS destination of the queue. mappingName属性指定队列的JMS目标的JNDI名称。

如果您有两个由同一队列驱动的MDB,则只有一个MDB将处理任何给定的消息,并且您无法事先知道它将是哪个MDB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM