1
votes

I'm creating a pretty basic application using RabbitMQ for messaging. Messages are published on one server, then a second server downstream will have a long-running process that consumes messages. Right now, I have it set up as follows:

Publisher:

  1. Declares direct exchange myexchange
  2. Publish message to myexchange exchange with routing key payload.routingkey

Consumer program:

  1. Declares direct exchange myexchange
  2. Declares queue my-specific-queue-name (with option durable set to true)
  3. Bind my-specific-queue-name queue to myexchange exchange
  4. Consume messages from my-specific-queue-name

I've got this process working well. The situation I'm running into is that if my consumer program dies, it seems that new messages published to myexchange will be lost, as no queue will be bound to the exchange. Is there a configuration where even if the consumer program goes away, messages can still be queued so that when a consumer program comes back online, the messages will still be able to be received?

1
Which language are you using for writing clients?cantSleepNow
@cantSleepNow Using perl for both clients. I'm using the Net::RabbitMQ module.Devin
Check what is the default value of the "exclusive" parameter when declaring a queue. Since you are putting the "durable" to true, it could be that if "exclusive" is true the queue gets deleted once the consumer disconnects or diescantSleepNow

1 Answers

0
votes

As I was writing this question, I seemed to realize an answer, published below. Of course if this is a bad idea or you have another suggestion, fire away.

If you use the default exchange (exchange with an empty string as the name), you can declare a queue and it will automatically be bound to this default exchange (see Default Exchange). So you can declare your my-specific-queue-name queue on the publisher and then redeclare it and start consuming from it in your consumer script. In AMQP/RabbitMQ, you can redeclare things multiple times, they'll only get created if they don't already exist. Because you're declaring the queue on the publisher, it won't matter if there are any other systems listening for messages from it.