0

I have two message driven beans in my project. Which one will be called by ejb container when a message is sent to queue. Where is it configured which bean to invoke. What is use of ejb-jar.xml and ibm-ejb-jar-bnd. Xml. Please explain

2 Answers2

0

A Message driven bean (MDB) is associated with a JMS queue (or topic) through deployment descriptors or Java annotations. The simplest form as from EE7 is with the use of annotations as follows:

@MessageDriven(mappedName = "myQueue")

public class MyMDB implements MessageListener {

@Override public void onMessage(Message message) {

....

The mappedName attribute specifies the JNDI name of the JMS destination of the queue.

garfield
  • 571
  • 9
  • 21
  • Thanks garfield , can you let me know where and how it is configured which bean to invoke when a msg is sent to queue. How it is configured in deployment descriptor as I am using java 6 .. pls help – user6070183 Sep 20 '16 at 02:38
0

If you have two MDBs driven by the same queue, only one of the MDBs will process any given message, and you cannot know in advance which one of the MDBs it will be.

John Donn
  • 1,718
  • 2
  • 19
  • 45
  • Thanks John, if there are gng to be processed by different queue , then where are we configuring it . I am using java 6 . Please help – user6070183 Sep 20 '16 at 02:36
  • see the other answer; if you have difficulties, I suggest you look for a working example on github for your particular server. – John Donn Sep 20 '16 at 08:06