This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMS Topic Multiple Subscribers Question!!!

 
Rajesh Bangalore
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajesh Bangalore
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic