0 Replies Latest reply on Nov 22, 2007 5:53 AM by a b

    Dynamic Listener creation?

    a b Newbie

      Hello, im building a functionality where a person connects to the server, sends a request. the server then starts some business logic which produces jms messages for him. The user then connects to the sockect and receives that information through a stream from a message listener with a selector.

      The socket part is implemented as fllows:
      User ----[socket]----> Service Mbean ----[local]----> Stateless Session Bean ----[delegate]----> POJO -----[create]----> JMS Message Listener

      My problem is - i cant find a satisfying way to dynamically create and destroy message listeners...

      Tried creating message consumers with jmstemplate, but i get no messages :/

       jmsTemplate.execute(new SessionCallback() {
       public Object doInJms(Session session) throws JMSException {
       MessageConsumer mc = session.createConsumer(
       incomingQueue, "id='" + id + "'"
       return null;

      I tried both - keeping the message consumer and suspending a thread on wait() inside the session callback - to no avail. Im running out of ideas and hits in google :)

      I chose this approach because this way the jms queue can manage the message lifetime and distribution for me, i only register listeners with an appropriate selector... Is this a good approach or should i message driven pojo and manage incoming messages (their distribution and lifetime) manually? (which seems tedious and error-prone)