aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JMS - How to receive old  messages stored on a Queue ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS - How to receive old  messages stored on a Queue ?" Watch "JMS - How to receive old  messages stored on a Queue ?" New topic
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: 10210
    
166


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
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS - How to receive old messages stored on a Queue ?