doulinduansh14199
doulinduansh14199
2017-03-06 13:23

如何使rabbitmq消费者超时?

  • rabbitmq

I have rabbitmq consuming the queue but once client is subscribed it stays consuming queue forever. Is there a timeout to declare and exit i.e. after queue is empty ?

 msgs, err := ch.Consume(
                q.Name, // queue
                "",     // consumer
                true,   // auto-ack
                false,  // exclusive
                false,  // no-local
                false,  // no-wait
                nil,    // args
        )
for msg := range msgs { 
                log.Printf("Received message with message: %s", msg.Body)
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐