activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gomes <jgo...@apache.org>
Subject Re: How to delete message in queue?
Date Wed, 10 Apr 2013 20:43:25 GMT
Hi Colin,

(I'm moving this to the Users list, instead of the Dev list)

I think using a selector should accomplish what you want.  Here's an
example.

IDestination dest = GetDestination();  // Get the destination interface
IMessageConsumer msgConsumer = session.CreateConsumer(dest, "MYPROP =
'thevalue'");

IMessage msg = msgConsumer.ReceiveNoWait();

if(null != msg)
{
    // Do something with the message.
    session.Commit();
}
else
{
    session.Rollback();
}


This will retrieve a message from the queue only if it has the specified
property value.  You may not even need to use transactions.  Hope that
helps.

Best,
Jim



On Wed, Apr 10, 2013 at 3:06 AM, colin_lee <neyeng@nhn.com> wrote:

> Hello all,
>
> when i used ActiveMQ, i met a problem, how to delete message according the
> property what i set?
>
>
> currently, i didn't find method to do it. so i used transaction to do it. i
> will loop my messages in queue, if property does not equal with what i
> wanted, i commit that session. so the message will be removed from queue to
> dequeue. if property does not equal with what i wanted, i will rollback
> transaction. But when i do this kind of operations for multiple times,
> message also will be removed from queue whatever i rollback or not.
>
>
> anybody knows what's the reason? do you know how to delete message
> accordind
> to the property??? or others
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/How-to-delete-message-in-queue-tp4665801.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message