Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMS - How to receive old messages stored on a Queue ?

 
hildich kilal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic