This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes A question about clustering and jms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "A question about clustering and jms" Watch "A question about clustering and jms" New topic
Author

A question about clustering and jms

Burton Wynne
Greenhorn

Joined: Jan 20, 2010
Posts: 2
I have deployed a jee application to a JBoss 4.2 cluster. The application basically adds messages to a topic. mdbs(ejb 3.0) then subscribe to the topic and process the messages. I am using ha-jms( port 1100 ) on JBoss AS. Right now when it appears that the mdbs that I wrote are being called on both members of the cluster (currently there are only two members of the cluster). Is this the correct behavior for the mdbs? Should the all of the mdbs on all of the clusters receive the message from the cluster or should only the mdbs on one node of the cluster act on the message.

The desired behavior that we want is to only have one node's mdbs. Is this a misconfiguration problem or an architectural issue?

Thanks in Advance!
Jeremiah Orr
Greenhorn

Joined: Jan 20, 2010
Posts: 6
I'm not familiar with the JBoss environment, but I don't think the cluster has anything to do with how the topic works. When using a topic, any subscriber will receive the message, regardless of location. This is the case whether you're working with a cluster or with multiple subscribers in completely different environments.

I wonder if a queue is what you're looking for, though it won't help you if you want multiple MDBs in the same node to get the message. If that's what you need (many subscribers in a node, but only one node in the cluster should get a given message), then you might just want to have a topic for each node.
Burton Wynne
Greenhorn

Joined: Jan 20, 2010
Posts: 2
Jeremiah Orr wrote:I'm not familiar with the JBoss environment, but I don't think the cluster has anything to do with how the topic works. When using a topic, any subscriber will receive the message, regardless of location. This is the case whether you're working with a cluster or with multiple subscribers in completely different environments.

I wonder if a queue is what you're looking for, though it won't help you if you want multiple MDBs in the same node to get the message. If that's what you need (many subscribers in a node, but only one node in the cluster should get a given message), then you might just want to have a topic for each node.


I guess I should be more specific. I have multiple mdbs deployed that subscribe to the topic (lets just say A,B,C). I want all of the different mdbs to be called but not the same mdb to be called across servers. When a new message is added to the topic I want A,B,C to be called. I just only want one instance of A,B and C to processed such that only A.x, B.y and C.z are called where x,y and z lie within the bounds of {1-n} and where n is the number of servers.

Thanks for the response...
Jeremiah Orr
Greenhorn

Joined: Jan 20, 2010
Posts: 6
I don't know of any "standard" way to accomplish what you're looking for by using a single topic. Perhaps JBoss provides some functionality that is appropriate for the clustered environment, but I'm not aware of anything like that.

An alternative approach: what about setting up a queue for each "type" of MDB? Using your example, you could set up a queue for A, a queue for B, and a queue for C. This would accomplish your end goal of having only one MDB of each "type" handle the message. Of course, it puts the burden on the message producer to know that it has to publish the message to 3 different queues. Not ideal.

A more complex approach that takes the burden off the message producer would be something like this:

- Set up queue "QD", which handles messages from the "source" producer.
- Create MDB "D", which will consume messages from QD. It can be clustered or not, doesn't matter.
- Create queues "QA", "QB", and "QC". When D receives consumes the "source" messages from QD, it will send them on to QA, QB, and QC.
- MDB A will subscribe to QA, B will subscribe to QB, and C will subscribe to QC.

Thus, when a message comes in to QD, MBD will send it on to QA, QB, and QC, and only a single instance each of MDBs A, B, and C will get a message. Not particularly clean, but it accomplishes your goal, I think.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

The MDB on each node would receive a copy of the message from a Topic in a clustered environment. If you dont want that to happen, you should reconsider your design.

ram.

Edit : You can deploy the mdb only on node in the cluster and have your fail over policy adjusted so that if the mdb on one node fails, it starts up on another. Google for ha-singleton or check out this link - http://onjava.com/pub/a/onjava/2003/08/20/jboss_clustering.html

ram.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A question about clustering and jms
 
Similar Threads
setMessageListener not permitted?? Why??
JMS cluster in Weblogic
Load Balancing in Websphere 6.x through MDB's
Clustering JMS
Need messge to be consumed once by MDB deployed in a glassfish cluster?