[rabbitmq-discuss] RabbitMQ 1.6 persistence?
Wilson Ke
wilson.ke at wealthcraft.com
Wed Jul 15 03:01:22 BST 2009
Hi chris,
I meet same question with you. I solute as below:
1. When you declare queue, please announce it to durable.
private int DecalreQueue(string [] args)
{
string serverAddress = args[0];
string inputQueueName = args[1];
bool durable=true;
using (IConnection conn = new ConnectionFactory().CreateConnection(serverAddress))
{
using (IModel ch = conn.CreateModel())
{
string finalName = ch.QueueDeclare(inputQueueName, false,
durable, false, false,
false, null);
Console.WriteLine("{0}\t{1}", finalName, durable);
return 0;
}
}
}
2. Declare exchange with durable , when send message, bind the queue to the exchange.
private int SendString(string message)
{
try
{
string serverAddress = "192.168.1.87";
string exchange = "yourexchange";
string exchangeType = ExchangeType.Topic;
string routingKey = "key";
using (IConnection conn = new ConnectionFactory().CreateConnection(serverAddress))
{
using (IModel ch = conn.CreateModel())
{
if (exchange != "")
{
ch.ExchangeDeclare(exchange, exchangeType,true,false,false,false,false,null);
}
ch.QueueBind("subscriptionqueue", exchange, routingKey, false, null);
ch.BasicPublish(exchange,
routingKey,
null,
Encoding.UTF8.GetBytes(message));
return 0;
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return 2;
}
}
Good luck!
Best Regards,
wilson
________________________________
From: rabbitmq-discuss-bounces at lists.rabbitmq.com [mailto:rabbitmq-discuss-bounces at lists.rabbitmq.com] On Behalf Of Chris Wiegand
Sent: 2009年7月15日 7:00
To: rabbitmq-discuss at lists.rabbitmq.com
Subject: [rabbitmq-discuss] RabbitMQ 1.6 persistence?
We were trying out RabbitMQ (1.6, just downloaded it last week), and while it’s throughput is great compared to ActiveMQ, I’m finding that if the erlang session dies (like say if I kill it, or try to pump in 1 million messages and it runs out of memory), and then I re-start the RabbitMQ server it takes a rather long time to load the persistence stuff, but then just clears out the queues, and the file (rabbit_persister.LOG) just gets truncated and the messages were not persisted.
Am I misunderstanding how RabbitMQ implements persistence? I expected that if the broker stops, and then gets relaunched that it would reload the last saved state for the queues, etc.., but that doesn’t seem to be taking place. We’re running it under Windows, under the most recent version of erlang (also just downloaded last week), in case that would affect anything. I’ll try this under Linux and OpenSolaris here soon, in case that makes a difference.
I’m using the .Net bindings, and setting the BasicProperties’ DeliveryMode to 2 for persistence, is there anything else I have to do to make a queue persist?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090715/0e75af85/attachment.htm
More information about the rabbitmq-discuss
mailing list