Ok, I think I've found the solution to this.

I want to treat the period from recv to send to be transactional.  So
here's what I've got:

pn_messenger_t * pMessenger...
pn_message_t * pMessage(pn_message());

... recv side ...

/* Set incoming window to 1 message */
pn_messenger_set_incoming_window(pMessenger, 1);
/* Fetch up to 1 message */
pn_messenger_recv(pMessenger, 1);
/* Pull the message into application space */
pn_messenger_get(pMessenger, pMessage);
/* Extract the body */
pn_data_t * pBody = pn_message_body(pMessage);
pn_data_next(pBody);
pn_bytes_t bytes = pn_data_get_bytes(pBody);

... process the data ...

.. send side ...

address and populate message body...
/* Put message into the send queue */
pn_messenger_put(pMessenger, pMessage);
/* Send everything in the queue */
pn_messenger_send(pMessenger, -1);
/* Acknowledge the receive window, expunging the received message from the
recv queue */
pn_messenger_accept(pMessenger, pn_messenger_incoming_tracker(pMessenger),
PN_CUMULATIVE);


Tested it and it seems to be working as expected!  Much respect for the
v0.6 proton API.

Reply via email to