qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Sim <g...@redhat.com>
Subject Re: Subscribe cancel release question cpp broker
Date Thu, 12 Feb 2009 12:37:35 GMT
Canceling a subscription does not release any unaccepted messages. I 
think therefore that what is happening is that your local queue is 
receiving all the messages from the brokers queue and they are not 
released, preventing the second subscription from seeing them.

You also need to set auto stop on the subscription manager _before_ 
calling start or it has no effect.

The following modifications work for me:

Adam Chase wrote:
>       SubscriptionManager subscriptions(session);
>       // Create a listener and subscribe it to the queue named "message_queue"
>       Listener listener(subscriptions);
>       // Receive messages until the subscription is cancelled
>       // by Listener::received()
>       LocalQueue lq;

         //you have to set auto stop before you call start or it
         //has no effect
         subscriptions.setAutoStop(false);

>       subscriptions.start();


>       SubscriptionSettings settings;
>       settings.completionMode = COMPLETE_ON_ACCEPT;
>       settings.acceptMode = ACCEPT_MODE_EXPLICIT;
>       settings.autoAck = 0;
>       settings.flowControl = FlowControl::unlimited();
> 
>       Subscription sub1 = subscriptions.subscribe(lq, "message_queue",
> settings, "lq");
>       Message m = lq.pop();
>       sub1.cancel();

         SequenceSet released;
         do {
             released.add(m.getId());
         } while (lq.get(m, 1*qpid::sys::TIME_SEC));
         session.messageRelease(released);

>       sleep(5);
> 
>       subscriptions.subscribe(listener, "message_queue", "listener");
>       subscriptions.wait();
> 
> 
> When I do this I get no messages on my listener and subscriptions just
> exits.  If I do a while(sleep) instead of the wait, I still never see
> my message.  Even if I make 2 connections and 2 sessions and 2
> subscriptionManagers and run them both I still don't see messages on
> the listener.
> 
> Am I doing something wrong?



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Mime
View raw message