Solved

Selectively pulling messages off of a JMS Queue in Spring

Posted on 2008-06-18
5
975 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the best cd/dvd burning software available? 8 57
replace a word with other 1 40
mobile app idea 17 57
arguments to jar 5 15
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This video shows how use content aware, what it’s used for, and when to use it over other tools.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now