Clients as a Message listener

Discussions

General J2EE: Clients as a Message listener

  1. Clients as a Message listener (1 messages)

    We are having a design discussion surrounding Message listeners as clients an I was wondering if anyone else has encountered this before or have any suggestions.

    The situation is that we have many clients (~800) who need to receive messages from a central server (implemented as a Session bean). Each client has its own unique identifier so that messages for it are retrieved upon request. The clients send a 'get' message to the SessionBean, which looks on a Queue for the message. If not there, it waits for a short time, and then returns.
    the problem is that it is taking longer than it needs to, often there are no messages for the client, and it ties up server resources.
    Question:
    We were thinking on implementing this having the clients be a message listener (pub/sub model), but we don't want every client receiving every message and filtering out its own, and I do not think we want each client to have its own topic.

    Any thoughts?

    Thanks,
    Mike

    Threaded Messages (1)

  2. JMS??[ Go to top ]

    With JMS, the Message object can have properties. So, for example a simple text message could be created, and then some "query-able" properties are added to the Message object. The publisher then puts the message in the topic.

    The TopicSession class has a method to get a TopicSubscriber with a "messageSelector" query string. It is much like an sql string on the properties of a message.

    See the javax.jms.Message class that details how that works.