You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by colin_lee <ne...@nhn.com> on 2013/04/10 12:06:00 UTC

How to delete message in queue?

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.

Re: How to delete message in queue?

Posted by Jim Gomes <jg...@apache.org>.
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 <ne...@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.
>