On 01/22/2014 10:41 PM, HellKnight wrote:
I want to set a unique guid for each message in message head , then if I want
, I could delete a specific message if I want to.  Is there any api in NMS
could help me deleting the message ? I am using ActiveMQ 5.9.0 and NMS 1.6.1
Thanks in advance.



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Yes, although only if that destination has no active consumers. You can do something like this:

        protected static void DeleteDestination()
        {
IConnectionFactory factory = new ConnectionFactory(ReplaceEnvVar(connectionURI));

using (Connection connection = factory.CreateConnection() as Connection)
            {
                using (ISession session = connection.CreateSession())
                {
                    IQueue queue = session.GetQueue(testQueueName);
                    try
                    {
                        connection.DeleteDestination(queue);
                    }
                    catch
                    {
                    }
                }
            }
        }


--
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.b...@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply via email to