| Author |
JMS - How to receive old messages stored on a Queue ?
|
hildich kilal
Ranch Hand
Joined: Aug 25, 2008
Posts: 44
|
|
Hi,
I have a requirement where I have a standalone java program which will run daily at around 11 PM. Now my code (which runs daily at 11 PM) has following logic.
- Connect to JMS
- Start listening asynchronously on the queues. (using MessageListener)
Once I am done getting all messages I properly close / shut down all JMS connections, listeners etc.
Now here is the issue.
The other program which puts the messages on queue can start before 11 PM. So whats happening is that the messages which came before my program started , are never fetched by my code. They remain on Queue forever.
I read about durable consumers also but it looks like I have to mandatory start listening , register as durable consumer, before I can get such missed messages.
Any pointers how to handle this scenario?
Thanks
hildich
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8142
|
|
I read about durable consumers also but it looks like I have to mandatory start listening , register as durable consumer, before I can get such missed messages.
That's only applicable when listening to a Topic and does not apply to a Queue.
Based on what you describe, you should be able to receive those messages from the queue even if they were posted earlier and assuming that they were persisted and weren't delivered to some other consumer.
What JMS vendor do you use? And what does the send/receive code look like?
|
[My Blog] [JavaRanch Journal]
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
Messages which are sent to Queue are delivered only once and durable subscribers are applicable only to Topic.
You have to register your client as a durable subscriber of particular Topic.
|
SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
|
 |
 |
|
|
subject: JMS - How to receive old messages stored on a Queue ?
|
|
|