Describe, test and show example of using message acquire from c++
-----------------------------------------------------------------

                 Key: QPID-1379
                 URL: https://issues.apache.org/jira/browse/QPID-1379
             Project: Qpid
          Issue Type: Test
          Components: C++ Client
    Affects Versions: M3
            Reporter: Gordon Sim
            Assignee: Gordon Sim
            Priority: Minor


Attached is a simple example that shows how a subscriber in not-acquired mode 
can received messages and subsequently acquire them. The producer creates 
'tasks' which are processed by one of as many acquirers as you want to have 
running; each of which will attempt to acquire the task before 'processing' it 
for a random amount of time.

Captured here along with some introductory blurb on message acquire (below) for 
later polishing and inclusion into qpid svn tree/wiki in some form.

A message is acquired by calling messageAcquire() on the session. This takes a 
SequenceSet argument which represents a set of message ids that are to be 
acquired (which may just be a single message).

E.g.

SequenceSet ids(message.getId());
MessageAcquireResult result = session.messageAcquire(ids);

You need to check that the acquire was successful. The response to 
messageAcquired is a set of message ids that were successfully acquired. By 
testing whether that includes the particular message you are interested in, you 
can determine whether or not the acquire succeeded.

if (result.getTransfers().contains(message.getId())) {
    //acquire for that id succeeded
} else {
    //that id could not be acquired
}

To use message acquire you should have subscribed in not-acquired mode. At 
present the recommended approach for this is to set the acquire mode to true on 
the subscription manager.

E.g.

SubscriptionManager subscriptions(session);
subscriptions.setAcquireMode(true);
subscriptions.subscribe(worker, "task_queue"); 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to