qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fraser Adams <fraser.ad...@blueyonder.co.uk>
Subject Re: Selective message acknowledgment in Java client (and C++ broker)?
Date Sat, 14 Apr 2012 13:41:43 GMT
Hi Pavel/Jakub/Rajith
I posted ages back (March 2011) that I didn't believe that JMS Message 
Selectors were behaving correctly:

My observations concur with the observations of Pavel and Jakob namely 
I'd expect any unselected messages to remain on the queue, but not the 
messages that matched the selector.

For info guys one approach that just may be useful is that the 
"internal" filter class is fairly easily accessibly so I had code that 
looks like.

import org.apache.qpid.filter.JMSSelectorFilter;
import org.apache.qpid.client.message.AbstractJMSMessage;

private JMSSelectorFilter filter;
// Then roundabouts where you'd create a consumer using a message 
selector do..
// Clearly just an example but this selects a header called 
amqp-delivery with the value fadams
// any selector could be used.
filter = new JMSSelectorFilter("amqp-delivery = 'fadams'");
// Later in say onMessage(Message message)
if (filter.matches((AbstractJMSMessage)message)) {
// Logic for matching message.


Clearly the code above isn't ideal as it isn't pure JMS and also it uses 
internal classes that could change, but it's the closest approximation 
that I could get to using message selectors that gave me some finer control.

Hope this helps you guys. I'd really like to see selectors behaving in a 
way that acknowledges selected messages and leaves unselected messages 
on the queue, this is what I'd intuitively expect to happen.

If that's not possible at the least it would be nice to have the 
JMSSelectorFilter exposed as an "official" Qpid API so it could be used 
without fear of it suddenly disappearing.

I'd be interested in thoughts on this, I've been meaning to bring it up 
again but have been distracted on other things.


On 13/04/12 08:55, Jakub Scholz wrote:
> Hi Rajith,
> I was playing with the JMS selectors last week. While they do work and
> really select the messages based on the filter, it seemed to me that
> it switched off the acknowledgments completely. The Java application
> was getting only the selected messages, but I was unable to
> acknowledge them and they stayed in the queues. This may be OK in some
> situations, but in my case I wanted to get the messages really
> acknowledged and removed from the queues on the broker.
> Then I considered to try the same trick as Pavel did - read all
> messages and filter them manually. But unlike in the C++ API, I didn't
> found any methods for acknowledging specific message as well as for
> releasing or rejecting a message.
> Regards
> Jakub
> On Fri, Apr 13, 2012 at 07:43, Rajith Attapattu<rajith77@gmail.com>  wrote:
>> (Note for C++ broker we do client side selectors, which does exactly what
>> you have described).
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org

To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org

View raw message