This article might help you.  Take special note of peeklock and 
receiveanddelete mode.

http://blogs.msdn.com/b/servicebus/archive/2014/12/16/using-service-bus-with-the-proton-c-client.aspx

-----Original Message-----
From: Jorge Sáez Gómez [mailto:[email protected]] 
Sent: Wednesday, March 18, 2015 3:28 AM
To: [email protected]
Subject: Messages not deleted from queue

Hello everyone,

I'm using qpid on C++ to receive messages from a remote Azure Service Bus. 
I'm capable of getting all incoming messages, but don't get removed from the 
queue. As I result, I keep getting them continuously. This is the code I'm 
running, which gets executed inside a larger, infinite loop:

void cloudRecv(const char* address, char* buffer, size_t buffer_length) {
    pn_messenger_t* messenger = pn_messenger(NULL);
    
    pn_messenger_start(messenger);
    check(messenger);
    
    pn_messenger_subscribe(messenger, address);
    check(messenger);

    pn_message_t* message = pn_message();
    
    pn_messenger_recv(messenger, 1);
    check(messenger);
            
    pn_messenger_incoming(messenger);

    pn_messenger_get(messenger, message);
    check(messenger);

    pn_data_t *body = pn_message_body(message);
    
    pn_data_format(body, buffer, &buffer_length);
    
    pn_tracker_t tracker = pn_messenger_incoming_tracker(messenger);

    pn_message_free(message);
    
    pn_messenger_stop(messenger);
    pn_messenger_free(messenger);
}

I actually need to re-create a fresh messenger at every iteration since, if I 
don't, when my code has processed all messages within the queue, it detaches 
from the queue and blocks the thread until the connection times out. 
I have been experimenting with the following functions, without any success so
far:

pn_messenger_set_rcv_settle_mode()
pn_messenger_accept()
pn_messenger_settle()

I'm already pretty much out of ideas. Any help would be appreciated. Thank you 
all in advance.

Regards,

Jorge.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional 
commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to