[rabbitmq-discuss] Durable queues and high availability (broker failage)

Wilson Ke wilson.ke at wealthcraft.com
Wed Jul 29 02:51:55 BST 2009

Hi Matthias,

I declare exchange and queue are durable, and met all what you said. Now I post my code lines to below,

and the attachment is the wrapper class of rabbit API, if you have some ideas in my code lines. Please let me know.


//declare exchange

rabbitmqWrapper.ExchangeDeclare(Exchange.ExchangeName, ExchangeType.Topic, false, true, false, false, false, null);

//declare queue

rabbitmqWrapper.QueueDeclare(Queue.QueueName, false, true, false, false, false, null);

//bind queue

rabbitmqWrapper.QueueBind(quename, exchangename,"test",false,null);

//send message

private void SendMessage()


    string xml = GetXml();

    RabbitmqWrapper wrapper =new RabbitmqWrapper();



//function of RabbitmqWrapper class

public void PublishMessage(string exchangeName,string queueName,string returnKey,string xml)


IConnection conn = new ConnectionFactory().CreateConnection(this.rabbitmqHost);    using (IModel ch = conn.CreateModel())


        IBasicProperties props = ch.CreateBasicProperties();

        props.ContentType = "text/plain";

        props.DeliveryMode = 2;

        IStreamMessageBuilder b = new StreamMessageBuilder(ch);

        byte[] byptes = Encoding.UTF8.GetBytes(xml);


        ch.BasicPublish(exchangeName, returnKey,null,byptes);



-----Original Message-----
From: Matthias Radestock [mailto:matthias at lshift.net]
Sent: 2009年7月29日 8:34
To: Wilson Ke
Cc: 'rabbitmq-discuss at lists.rabbitmq.com'
Subject: Re: [rabbitmq-discuss] Durable queues and high availability (broker failage)


Wilson Ke wrote:

> When I restart rabbitmq server,the durable queue had purge all

> messages. I want to remain these messages in the durable queue after

> restart rabbitmq server,how can I do? Btw,I use

> deliverymode=2(persistent) to send messages to the queue.

As long as the queues are marked as durable, are not exclusive or

auto-delete, and the messages are marked as persistent, then the queues

and messages should survive a broker restart.

If all these conditions are met in your setup and the messages still

disappear then please post the code that creates the queues and the code

that sends the messages.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090729/4be3c927/attachment.htm 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: RabbitmqWrapper.cs
Url: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090729/4be3c927/attachment.txt 

More information about the rabbitmq-discuss mailing list