How to create a temporary jms queue with jboss?

I need to create temporary queues on the fly. How is this possible?

+2


source to share


1 answer


From the Queue / TopicSession jms object: see the QueueSession javadoc .

You need to leave the session open for the timing queue lifecycle.

A typical use is for a client to open a session and place a message on the general processing queue using the temporary queue in the message's response field. for example: (pseudo code)



Queue queue = session.createQueue("shared");
Queue responseQueue = session.createTemporaryQueue();
Message message = session.createMessage();
message.setJMSReplyTo(responseQueue);
...
session.commit();
...
MessageConsumer responseConsumer = session.createConsumer(responseQueue);
Message response = responseConsumer.receive();
...
session.close();

      

The MDB (or the listener that reads the shared process queue) will send the response back to the response queue. If the client is dead for any reason, its session is closed and the queue has ceased to exist.

+3


source







All Articles