Solved

Selectively pulling messages off of a JMS Queue in Spring

Posted on 2008-06-18
5
977 Views
Last Modified: 2013-11-15
I am using Spring to interface with an asynchronous JMS queue. The Spring listeners that I have created pull all of the messages off of the queue as soon as they are placed there. I am trying to figure out how to find a particular message then retrieve it manually. I want the messages to sit on the queue then when I am ready I want to find a particular message then retrieve it. Does anyone know how to do this?    
0
Comment
Question by:texastemplar
  • 3
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 21820241
If you are retrieving the messages using the receive() method I am afraid you will have to read them before you can decide if the messages are the ones you want. Maybe the API you ar using has methods to do what you ask for but I can't think of any solution using the standard JMS APIs.
0
 

Author Comment

by:texastemplar
ID: 21824210
What about JMSTemplate.receiveSelected(String messageSelector) method? According to the docs Ive read I can provide a string that will determine which messages this listener will receive. Im thinking about using the jmsmessageid header to pull the messages.

ex.  receiveSelected("jmsmessageid = 1234")
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 500 total points
ID: 21853794
You can use this but this reads messages synchronously. It will block the queue until the message becomes available (or timeout has expired).
0
 

Author Comment

by:texastemplar
ID: 21868363
I figured it out. I added properties ( using message.setStringProperty() ) to each message that enables me to uniquely identify each message. Then I used receiveSelected( "property = value" ) to retrieve the message.
0
 

Author Comment

by:texastemplar
ID: 21878071
ok
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question