[rabbitmq-discuss] [RUBY-AMQP GEM] How do we can retry publish message on errors?
Loganathan Sellapa
loganathan.ms at gmail.com
Mon Apr 28 12:16:53 BST 2014
HI Michael,
Thanks, but I need some more clarification. Right now I have durable
exchange and auto delete is set to false for the queue. So I assumed that
RabbitMq will re-publish the message automatically, whenever RabbitMq
recovered from failover case. My question is how can I make publish the
message(from producer to RabbitMq broker), when some exceptions occurred
while publishing the message to rabbitMq channel. Below is my sample code
for it.
*ch1 = AMQP::Channel.new($connection)*
*@ns_x = ch1.direct(ns_exchange, :durable => true)*
*@ns_queue = ch1.queue(ns_queue, :auto_delete => false)*
*@ns_queue.bind(@ns_x, :routing_key => @ns_queue.name
<http://ns_queue.name>).subscribe(:ack => true,
&method(:handle_ns_message))*
*## How can I redo this whenever some exceptions/failure occurred*
*@ns_x.publish(payload, :routing_key =>@ns_queue.name
<http://ns_queue.name>, :headers => headers, :mandatory => true) *
regards,
Loganathan
Mob: +91 7760780741 | +91 9944414388
Skype: loganathan.sellappa
ViewMe <http://vizualize.me/loganathan>
On Mon, Apr 28, 2014 at 4:00 PM, Michael Klishin <mklishin at gopivotal.com>wrote:
> On 28 April 2014 at 11:44:52, Loganathan Sellapa (loganathan.ms at gmail.com)
> wrote:
> > > I would like to know how the error handling is done for "publish
> > message". I want to retry the publish message when some exception/failure
> > occurred on RabbitMq? I checked the examples on ruby amqp gem
> > but unable to find the proper example for republishing the message
> > on error.
>
> http://www.rabbitmq.com/confirms.html
> http://rubyamqp.info/articles/rabbitmq_extensions/
>
> https://github.com/ruby-amqp/amqp/blob/master/examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
> --
> MK
>
> Software Engineer, Pivotal/RabbitMQ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140428/4178175a/attachment.html>
More information about the rabbitmq-discuss
mailing list