Try using a messageHandler.
ClientConsumer consumer = session.createConsumer(...); consumer.setMessageHandler(handler);
But the consumer will be other class different to the class que send the message
Maybe there is a language issue here.
If you think your question sounds as generic as going to the meat market and asking can I have a piece of meat here? That's probably why nobody has answered you properly.
Please, read the documentation and also look at the examples and maybe after you did that come back and ask a more specific question. That's basically what a messaging is supposed to do:
Send and receive messages.
My question is:
I have a class what send messages. Once the class sends the message, i want to have other class that receive messages.
Is there any way to run a class when a message arrives at the queue?