Kraiss
Kraiss

Reputation: 999

Define queue on multiple node on RabbitMQ

We are working with a cluster of two RabbitMQ nodes and we are using RabbitMQ Java driver to interact with the nodes. We are using a "headers" exchange which transmit messages to queues based on header bindings and persistent queues.

The thing is, queues are defined for one node. If this node crash for some reason, messages that should arrive in queues of this node are lost.

Is there a way to tell RabbitMQ to change queue home node when it detects that another node that hold them is unreachable and so, ensure messages are transmitted to the queue ? And to recover messages when the node comes up again ?

For now, we are using high available queues to solve this problem but performance are pretty bad. We don't need mirroring features it provides, as it is fine for us to only recover messages when node comes up again

Upvotes: 0

Views: 822

Answers (1)

cantSleepNow
cantSleepNow

Reputation: 10202

You need to make messages persistent bu setting the delivery_mode to 2 and declare queues durable. In that way the queues are back when the nodes are restarted and the messages are saved. More in the second tutorial. Actually I don't see in the tutorial how to it in java, but it's there in phyton, so you'd need to look up in javadoc, probably also a parameter in the 'publish' method.

Upvotes: 1

Related Questions