This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
An Jms object is listening to a queue and is receiving message using the onMessage() method. What happens if I have a reference to this object and want to call my own method i.e. refresh() , but the queue the object is listening to has 1000 pending messages to process . Will these messages have to be processed before my method is invoked ?At what time does the queue tell the listener that there is a message? ,is it when the queue first retrieves the message or when the message is ready to be sent to the listener .The reason I ask is that, I wish to have some control over my JMS object (pause , stop , refresh etc). Thanks
I am not quite sure that I got your question. Are you listening to the message from the queue by using an MDB? If so, then the onMessage method comes into work after it recieves the message. So whatever you do in onMessage method is done on the server side and has no effect on the performance of the queue.
Joined: Feb 01, 2002
No I’m not using a MDB. I have a normal Java class the implements the Messagelistener interface . When this object is first initialized it reads data from the database for configuration information . The data in the database can change , but I don’t what the class to check the data on every onMessage() .So I want to be able to control this object and call other methods on it , like refresh() . My worry is that if the queue the object is listening to , has 1000+ message to process ,that these messages have to be processed before my method is invoked ? I hope that’s made it a bit clearer Thanks Jim
Originally posted by Kyle Brown: Message processing runs on its own thread. If you call refresh() from another thread they will run simultaneously. Kyle
Does that also mean if I have multiple objects that implements the Messagelistener interface , with each object listening to a different queue , that each object can process there messages concurrently. Or do does each class need to extend the Runnable interface and treat as a separate thread? Thanks Jim
Joined: Aug 10, 2001
Originally posted by jimmy coyne:
Does that also mean if I have multiple objects that implements the Messagelistener interface , with each object listening to a different queue , that each object can process there messages concurrently.
I believe it depends on the messaging vendor, but I'm pretty sure that the answer for all vendors I know of is yes.
Or do does each class need to extend the Runnable interface and treat as a separate thread? Thanks Jim