File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Dynamically Configuring MDB Message Selectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Dynamically Configuring MDB Message Selectors" Watch "Dynamically Configuring MDB Message Selectors" New topic

Dynamically Configuring MDB Message Selectors

John Pritchard
Ranch Hand

Joined: Nov 15, 2002
Posts: 49
Hello All-
I've got a system I am designing where a set of several JMS topics exist. Clients would like to subscribe to one or more of these topics anbd provide some filtering criteria as part of the subscription request. The MDB Message Selector semed like an alternative but it doesn't seem that it is dynamically configurable, e.g. specifying the selector at runtime. Any suggestions on a design solution that helps minimize traffic back to the client?

John Pritchard<br />If a JTree falls in the woods, is it Observable
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Unfortunately, message selectors are not dynamically configurable in a standard way. Some J2EE Servers might support this (I honestly don't know) but I wouldn't count on this functionality.
I really don't have enough context on the problem to suggest a good solution. However, if you really think you need this functionality then you could always create a MessageListener for each client and specify the message selector at creation time. Alternately you could set up some type of artificial filter code in your MDB which serves a similar purpose to message selector yet it is configurable at runtime. Again, I am not sure if either of those solutions fits your situation.
Probably, the best bet is to write back and explain your problem in greater detail and maybe one of us can come up with a better solution.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
The only way to configure a message selector dynamically is to do so with a MessageListener, not an MDB. However, due to restrictions in the J2EE specification (which are not enforced by all vendors -- but should be) this will only work in an application container.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
John Pritchard
Ranch Hand

Joined: Nov 15, 2002
Posts: 49
Thanks for the replies Chris and Kyle. I essentially have a vey large pub/sub architecture where various events are being published to a set of JMS Topics. Our clients would like to pull specific information (messages) off of the topics by using some filter criteria they specify at subscription time. I'm trying to define a mechanism where I can take a client's subscription request and filter criteria and have the filtering occur on the server side to minimize traffic back to the clients. Server side componenets would then asycnronously update the clients when a message did meet their filter criteria.
Appreciate the help.
I agree. Here's the link:
subject: Dynamically Configuring MDB Message Selectors
It's not a secret anymore!