[rabbitmq-discuss] Starting RabbitMQ-Server and message storage
tonyg at lshift.net
Wed Nov 7 12:58:13 GMT 2007
joe lee wrote:
> When I start the server on the command line with "rabbitmq-server",
> will the messages be kept in memory or disk? Is there a way to
> specify type of message storage at the command line?
The server makes available both in-memory and on-disk storage to
clients. Which is used depends on both (a) the "durability" setting of
the queue concerned, and (b) the "delivery mode" property of Basic messages.
Messages will be stored in memory if EITHER the queue is declared with
"durable" set false OR the message is published with "delivery mode"
missing or set to non-persistent (= 1).
Messages will be stored on disk if BOTH the queue is declared with
"durable" set true AND the message is published with "delivery mode"
present and set to persistent (= 2).
Here's an example of publishing a persistent message to a durable queue,
using RabbitMQ's Java API:
// The "true" below makes the queue durable.
myChannel.queueDeclare(ticket, "queuename", true);
// The MessageProperties.PERSISTENT_TEXT_PLAIN is a useful
// preallocated BasicProperties instance that has a text/plain
// content-type and a delivery mode of 2 (== persistent).
myChannel.basicPublish(ticket, "", "queuename",
> On the dos prompt, if I do ctrl+c, does it mean all the messages will
> be lost when the server restarted at some point?
Only those in memory. Also, all non-durable queues will be lost. Durable
queues, however, should survive server restarts, as should persistent
messages held by durable queues.
 Tony Garnock-Jones | Mob: +44 (0)7905 974 211
 LShift Ltd | Tel: +44 (0)20 7729 7060
  http://www.lshift.net/ | Email: tonyg at lshift.net
More information about the rabbitmq-discuss