[rabbitmq-discuss] Publisher Confirms support in Rabbitmq-c client.

Alan Antonuk alan.antonuk at gmail.com
Wed Jul 18 05:04:00 BST 2012


rabbitmq-c does support publisher confirms, its not as easy to use as on
the other clients.

On the channel you want to turn on confirms (error handling elided):
amqp_channel_t channel = 1;
amqp_channel_open(conn, channel);
amqp_confirm_select(conn, channel);

Then to handle the publish confirms:
amqp_basic_publish(...);
// You then need to wait for either a basic.ack or then a basic.return
followed by a message, followed by basic.ack in the case of a delivery
failure:

amqp_frame_t frame;
amqp_simple_wait_frame(conn, &frame);
// Check that frame is on channel 1
if (frame.method == AMQP_BASIC_ACK)
{
  // Message successfully delivered
}
else
{
 // Read properties
 amqp_simple_wait_frame(conn, &frame);
 // Check that frame is on channel 1, and that its a properties type
 uint64_t body_size = frame.properties.body_size;

 uint64_t body_read = 0;
 // Read body frame
 while (body_read < body_size)
 {
   amqp_simple_wait_frame(conn, &frame);
   // Check frame is on channel 1, and that is a body frame
   body_read += frame.body_fragment.len;
 }

 // Read basic.ack
 amqp_simple_wait_frame(conn, &frame);
 // Check frame is on channel 1, and that its a basic.ack
}


This is used in SimpleAmqpClient, see BasicPublish function for details:
https://github.com/alanxz/SimpleAmqpClient/blob/master/src/Channel.cpp#L287

-Alan

On Tue, Jul 17, 2012 at 6:28 PM, Jerry Kuch <jerryk at rbcon.com> wrote:

> Publisher confirms are a quite recent Rabbit extension to AMQP and the C
> clients tend to lag behind a bit, unfortunately.
>
> I'm not aware of current plans to support them or any existing patches.
>  Anybody else?  What happens at the wire level is pretty straightforward so
> really the work will all be in handling them asynchronously I'd think.
>
>
> Sent from my iPad.
>
> On Jul 17, 2012, at 1:55 PM, rohit <mailrohitp at gmail.com> wrote:
>
> >
> > Hi,
> >
> > After looking in rabbitmq-c client source code, I feel there is no
> > implementation of Publisher confirms in the client. Can someone confirm
> > this?
> > Also does anyone know if it is ever going to be implemented as part of
> the
> > client, or a third party patch to achieve this.
> >
> > Thanks in advance.
> >
> > --Rohit
> >
> > --
> > View this message in context:
> http://rabbitmq.1065348.n5.nabble.com/Publisher-Confirms-support-in-Rabbitmq-c-client-tp20862.html
> > Sent from the RabbitMQ mailing list archive at Nabble.com.
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-discuss at lists.rabbitmq.com
> > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120718/84075fa7/attachment.htm>


More information about the rabbitmq-discuss mailing list