[rabbitmq-discuss] HA - queues do not move?

John Jeffers john.jeffers at gmail.com
Thu Sep 1 19:11:34 BST 2011


Thank you Marek! This is exactly what I needed to know.  I changed the
code I was using to create queues and publish messages, and now the
persistent messages are failing over.  For anyone who might need this
in the future, here is the code that is working for me (using the .NET
API, RabbitMQ version 2.5.1).

// Create the Exchange and Queue with Durable flags set to True.
using (IConnection connection =
connectionFactory.CreateConnection())  // Assumes that you have a
ConnectionFactory object instantiated.
{
    using (IModel model = connection.CreateModel())
    {
        model.ExchangeDeclare("exchangeName", ExchangeType.Direct,
true);
        model.QueueDeclare("queueName", true, false, false, null);

        model.QueueBind("queueName", "exchangeName", "routingKey",
null);

        IBasicProperties basicProperties =
model.CreateBasicProperties();
        basicProperties.DeliveryMode = 2; // Message persistence --
required for failover.
        model.BasicPublish("exchangeName", "routingKey",
basicProperties, Encoding.UTF8.GetBytes("message"));
    }
}


On Aug 31, 8:36 am, Marek Majkowski <maje... at gmail.com> wrote:
> On Mon, Aug 29, 2011 at 21:31, John Jeffers <john.jeff... at gmail.com> wrote:
> > (I'm new to Rabbit, so please forgive me if this is a dumb question)
>
> > I followed the instructions athttp://www.rabbitmq.com/pacemaker.html
> > to build a two-node HA environment.  My nodes are RabbitMQ 2.5.1 on
> > CentOS 6 64-bit, and I'm using a network share for shared storage
> > instead of DRBD.
>
> > The nodes failover just fine, and most things seem to be working as
> > expected, however, I've noticed that when I take Node 1 down and it
> > fails over to Node 2, the queues and messages on Node 1 do not move to
> > Node 2.  Is this expected behavior?  I expected that the point of the
> > shared storage would be so that messages would not be lost in the
> > event of a failover, but maybe my expectations are incorrect?
>
> Have you set 'persistenece' flag on the queues and 'durability' flag
> on messages?
>
> Chees,
>   Marek
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list