aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Mapping MDB JMS references to different queues using descriptors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Mapping MDB JMS references to different queues using descriptors" Watch "Mapping MDB JMS references to different queues using descriptors" New topic
Author

Mapping MDB JMS references to different queues using descriptors

Kevin Halk
Greenhorn

Joined: Feb 09, 2010
Posts: 10
Hello there,
I'm attempting to create a series of EJB's which will use JMS Queues - they are MDB beans (so they need to listen on a destination) and also they will output their work onto a Queue when they're finished (so they all have out-going Queues as well). We'd like to be able to dynamically configure them so if need be we can put new modules into the pipeline without changing the code (changing the descriptor files is fine).

i.e. Q1 -> MDB1 -> Q2 etc... could change to Q1 -> MDB2 -> Q2 -> MDB1 -> Q3 ...

We are using JBoss 5.1 and EJB3.0.

It appears that (at least with our configuration) that the 'destination' is a required activation-config-property for my MDB (either in annotations or in the ejb-jar.xml).

I figured a good way to achieve our goal would be to set the 'destination' to some sort of logical name (i.e. PreFilter) and configure the queues using the descriptors. I figured I could achieve this by using message-destination-ref tags, which I supposed would map the 'PreFilter' name to some actual Queue instance i.e. 'MyQueue1'

After several days of reading and trying different things I still can't for the life of me quite figure out how to use these things

- What is the effect of putting a <message-destination-link> tag in the MDB <message-driven> section in ejb-jar.xml?
As I mentioned above, the 'destination' property is required, so anything I specify in the 'destination' is where my MDB is listening (not this message-destination-link)


- What is the purpose of filling out a <message-destination-ref> section in the MDB <message-driven> section in the ejb-jar.xml?
I can fill in parameters giving it a mappedName, specifying its type and even point it to a message-destination object - nothing seems to happen (even if I specify this message-destination-ref-name as my message-destination-link above)

I have had success (and by success I mean something at all happened) with putting a message-destination-ref in my jboss.xml file - I specify the message-destination-ref-name and jndi-name and I can see that this is added to my JNDI bindings for my component's java:comp namespace under the env/ (specified as a link to the jndi-name). This seems exactly what I want! Unfortunately I can't reference it through JNDI because it gives me an error that '/env' is not bound (which I don't get).

It seems to me that this message-destination-ref behaviour in my jboss.xml file is exactly what I want (if it actually works) - a method of mapping a logical name to an actual JNDI name. What is the point then of specifying the actual message-destination? What is the point of a message-destination-link?

Does anybody have any thoughts on what I'm doing wrong, or how I can accomplish what I'm trying to do? Also I think I picked up somewhere the idea that using message-destinations will actually create a JMS Queue resource dynamically as needed (as opposed to specifying the mbeans in a separate resource descriptor file). This would be perfect behaviour since, as I described above, we will often have two EJB's pointing to the same Queue (one publishing to it, one reading it) .
Kevin Halk
Greenhorn

Joined: Feb 09, 2010
Posts: 10
As an afterthought - I thought another way I could do this was to give multiple JNDI bindings to a single Queue (i.e. PostCollector and PreFilter), similar to how the ConnectionFactory has multiple entries. That way we could just change the Queue definitions and leave the names the same that the EJB's are pointing to.

Unfortunately I couldn't figure out how to do this either (or even if I can).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Mapping MDB JMS references to different queues using descriptors
 
Similar Threads
Specifying my MDB's destination to a message destination reference instead of a JNDI queue
Problem with JMS queues after upgrading to jboss 5.1.0 GA
JMS on MQSeries via MDBs
how to configure multiple MDB in DD
How to specify an actual queue for a MDB ?