This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes  Doubts on MDB's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark " Doubts on MDB Watch " Doubts on MDB New topic
Author

Doubts on MDB's

B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Got a few questions on MDB's this time !!

1. What tag do you use in the DD of an MDB to say which queue / topic you are listening to / subscribing to? The HFEJB book just talks about the tag <message-driven-destination> with the <destination-type> sub-element that says whether this bean listens to a topic or queue. How do you say WHICH queue / topic you are listening to? If it's a topic, what tag do you use to say whether your subscription is durable / non-durable. Surprised that this is not covered in the HFEJB

2. Is it possible for the same MDB to subscribe to many topics / listen to many queues?

3. Are the message acknowledgement rules the same for topics and queues? ie for CMT beans, message acknowledgement is tied to the transaction status and for BMT beans, message acknowledgement is tied to the method completion status. Does this hold good for topics as well? What about the <acknowledge-mode> tag for BMT beans with Auto-acknowledge and Dups-ok-acknowledge values? Does that hold good for topics as well? The HFEJB book talks only about message acknowledement related to queues.
Ramakrishnan Viswanathan
Ranch Hand

Joined: Aug 24, 2005
Posts: 90
#1) This is done to make MDBs portable across app servers. The DD only states if the destination is a queue or a topic but does not state the specific queue/topic. The actual names of the topics/queues deployed into the JMS server are app-server specific and therefore the mapping of the container to a specific JMS destination happens in the app-server specific deployment descriptor.

#2) Deploy the MDB multiple times � once as a consumer of Queue1 and once as a consumer of Queue2.

#3) Queue and Topic are message destinations for the point-to-point and publish-subscribe message delivery models respectively. The mode of acknowledgement applies not only to Queues but also to Topics. Topics have an additional facility of stating the durability of the subscription.


Regards<br />Ram<br /> <br />SCJP 1.4, SCBCD 1.3, (SCEA)
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Thanks Ram, that sounds reasonable

1. Is the message-driven-destination tag optional or mandatory in the ejb-jar.xml? The spec said that the bean provider may tell the deployer whether the bean in using a topic or a queue. I guess, it should be optional, just wanted to confirm.

2. I read in the spec that if the subscription-durability is not specified for an MDB subscribing to a topic, the default is non-durable. I am a bit surprised about this. Should the default not be durable? Can someone think of a reason why the spec designers decided to keep the default as non-durable, given the fact that mostly durable topic subscriptions are used?

Thanks
Ramakrishnan Viswanathan
Ranch Hand

Joined: Aug 24, 2005
Posts: 90
#1) The <message-driven-destination> is optional - however if mentioned, then <destination-type> is mandatory.

#2) I do not know the answer to this. My only guess here is that a durable subscription has an overhead due to the increased reliability that it provides. So if you really dont mind about messages getting missed, you wouldn't make the subscription durable. If someone could give a better explanation, it would really help.
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Great, that clears up the MDB chapter for me !
 
Consider Paul's rocket mass heater.
 
subject: Doubts on MDB's