JMS Topic Multiple Subscribers Question!!!


General J2EE: JMS Topic Multiple Subscribers Question!!!

  1. JMS Topic Multiple Subscribers Question!!! (4 messages)

    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.
  2. JMS Topic Multiple Subscribers Question!!![ Go to top ]

    Your topic subscriber programs need not be message-driven EJBs. If they don't need to be EJBs for some other reasons, then you can simply make them normal Java objects that happen to be MessageListeners.
  3. JMS Topic Multiple Subscribers Question!!![ Go to top ]

    Thanks Ray 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 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 an instance of MDB 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? MDB's are automatically configured in deployment descriptors and act as Message Consumers.

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

    Appreciate your ideas.
  4. When using MDBs with topics, only one MDB in the pool gets the message since an MDB pool represents a single, logical subscription.

    If you want to make a web application of some kind showing transactions for many different users, you should make some kinda cache (JCache?) of the transactions and share them across Servlet requests. e.g. put the one inbound transaction message into whatever caches required for the current user population.

    Another option is to have a JMS consumer for the duration of the HTTP Session for each users's view on the world, storing the users transactions in the HttpSession

  5. BTW we do something like the 2nd option I described in our Ajax support in ActiveMQ...

    which allows users to subscribe, over Ajax, to the stocks they want so that they can have a real time Ajax trading portfolio