Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Mapping MDB JMS references to different queues using descriptors

Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic