aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JMS Topic Multiple Subscribers Question!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS Topic Multiple Subscribers Question!!!" Watch "JMS Topic Multiple Subscribers Question!!!" New topic
Author

JMS Topic Multiple Subscribers Question!!!

Rajesh Bangalore
Greenhorn

Joined: Jun 17, 2005
Posts: 9
I have configured Topic (Publish - Subscriber Model) in JMS. I have written Message Driven Bean, Configured Deployment Descriptors, Deployed the application onto Application Server ( JMS Server). I have writen client, which sends the messages onto JMS Server. The Message Driven Bean's onMessage() automatically prints the received message from the topic by the client.

The question is how do we write multiple subscribers (Message Receivers) that receives each message sent by client. Do we write multiple Message Driven Beans?

We are writing application, which models Publish-subscriber ( Topic). The client keeps on writing messages onto JMS Topic. On the Server(Receiver) side, we have several application programs that subscribes itself to single topic and read the messages.

Do we write stand alone progams that just implements message listeners or multiple Message Driven Beans? Any ideas will be appreciated.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Let's say you have a Customer topic. You can have many message-driven bean types which subscribe to that topic, eg SalesBean and MarketingBean. Upon receipt of a message, the container will pull one instance of SalesBean and one instance of MarketingBean from their pools to service that message.

You could certainly write multiple message listeners, but I prefer MDBs if possible. They are, of course, listeners as they must implement the javax.jms.MessageListener interface.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Rajesh Bangalore
Greenhorn

Joined: Jun 17, 2005
Posts: 9
Thanks Roger for the reply.

I have written multiple POJO's, which implements MessageListerners. These are working fine. I am trying to implement Message Driven Beans version for our application.

we are developing an application that writes transaction messages onto the Topic. There are several client graphical User Interfaces , which connects to the Topic, subscribes itself and keeps on displaying the transactions on user interface as and when the transaction happens.

This is my Question: I have written one Message Driven Bean, configured Deployment Descriptor, Deployed and it works fine for one MDB(It prints transaction in onMessage()).

Let us say, we have a pool of 20 MDB's. As soon as Message is published, Container takes one MDB from pool and assigns to perform the task.

I am thinking of having each MDB that subscribes itself and start displaying
transactions, when Graphical User Interface is opened by user. How do you get instance of MDB from the pool, when the user interfaces starts up?

Let us say, 10 users have opened 10 screens. DO we have 10 instances of same MDB that display all transactions in 10 screens? Does MDB's fit in this kind of scenario?

Appreciate your ideas.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The container will process each message as it arrives. So, if 10 messages arrive, then they will all be processed. As the container is multithreaded, then there should be no delay in processing the messages as each will typically be processed in a separate thread by an MDB instance.
Rajesh Bangalore
Greenhorn

Joined: Jun 17, 2005
Posts: 9
Thanks for the reply Roger again.

I am clear that each message will be processed in a separate thread by MDB instance. But In our case, each message(Publish-subscriber model) is being simultaneously displayed by 10 clients(screens) at same time. How does 10 clients subscribe simultaneously and get the same message at same time using Message Driven Bean?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS Topic Multiple Subscribers Question!!!