take a look at the message selector examples in the distro
I am looking through the distribution examples.
There is no message selector there.
Only queue selector and topic selector which aren't applicable in my case.
yes, both the topic and queue selector demonstrate how to use message selectors, maybe you mean something different.
as I constantly say: Be Careful with the Store-and-retrieve anti-pattern.
If you are expecting a specific message, it probably means you are using the message system as a storage system. You should probably use a database for that. Message systems are to send/receive messages in a disconnected way. I'm not saying this is what you're doing.. just that when I see people expecing specific message it usually means that.
I am not using subscription model, so topic selector is not for me as consumed message must be removed from the queue.
I am not sure how queue selector can be used as this example uses listeners for a specific selector, i.e. it is sitting and waiting for a specific message to consume.
What I need is to create a generic consumer that receives a REST service call - "give me a message that matches my processing capabilities".
It is then suppose to retrieve such message and return it to the REST client. It is doing something else but that is beyond the point of discussion.
It is the same API basically.. I'm not sure what's your issue.
Anyway.. that's pretty much covered by the JMS tutorial.
It might be easy for you. For me JMS tutorial is absolutely useless in that regard.
Maybe I am looking at the different tutorial. Can you post a link to a proper page if you know it.
1 of 1 people found this helpful
This is pretty much what you have to do:
Session session = ... something that creates the session...
Queue queue = session.createQueue("queueName"); // this will just lookup the queue
// Notice that Session can take either queue or a topic
MessageConsumer consumer = defaultSess.createConsumer(queue, "messageProperty=3");
if you were using Topics and wanted to use a durable subscription you would be able to add another property with the subscription name.
Then everything else is just the same as any other message consumer.. there are plenty of examples.
You should be able to do it that way. let me know if it helps.
Does HornetQ supports bitwise operations in the selector? I.e. if I have a message IntProperty with the value = 1, can I have
MessageConsumer consumer = defaultSess.createConsumer(queue, "messageProperty & 3");
Will that work?
no, but it seems a nice feature to be added
you could raise a JIRA if you like... or even better.. if you have some knowledge on antlr.. you could implement it on FilterParser.jj and submit a PR.
I'd love to but my manager is cracking the whip over my head to deliver on the project that should have not just me but at least 3 developers.