go-rabbitmq: Consumer won't reconnect

Hi,

Somehow when network got disconnected for a minutes or so and then network up again, I got a log

gorabbit: rabbit consumer goroutine closed

After that, consumer stops receiving new message. Why wont it reconnect?

I’m using version 0.6.2, and my code is (more or less) like this

rabbitmqConsumer, err := rabbitmq.NewConsumer(config.constructURL(), amqp.Config{}, rabbitmq.WithConsumerOptionsLogging)
...
rabbitmqConsumer.StartConsuming(
  func(message rabbitmq.Delivery) bool {
    return true
  },
  "",
  []string{""},
  func(options *rabbitmq.ConsumeOptions) {
    options.QueueExclusive = true
    options.ConsumerExclusive = true
    options.QueueDurable = true
    options.BindingExchange = &rabbitmq.BindingExchangeOptions{
      Name:    "my_rabbitmq_topic",
      Kind:    "fanout",
      Durable: true,
    }
  },
)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 31 (16 by maintainers)

Most upvoted comments

I’m sorry I’m not able to reproduce this. Are you guys sure you aren’t missing some logging, and that messages are actually being sent?

This is my test process. Let me know what to do differently to see what you’re seeing:

  1. Start example consumer connected to local rabbitmq
  2. Close local rabbit server
  3. Watch consumer auto reconnect
  4. Start publisher, watch the consumer consume the messages
  5. Close cleanly both the publisher and consumer

Note that this is not my use case. My case is:

  1. Start remote server
  2. Start local consumer
  3. Watch consumer receive messages
  4. …long period of inactivity…
  5. See message gorabbit: rabbit consumer goroutine closed in the consumer log
  6. Publish more messages
  7. messages are not picked up by consumer
  8. Stop local consumer
  9. Start new local consumer
  10. Messages are received

So it seems like the consumer gets bored and drops the connection and does not reconnect.