Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically Configuring MDB Message Selectors

 
John Pritchard
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Thanks,
john
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
John Pritchard
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic