普通网友
2017-03-06 13:23
浏览 2.4k
已采纳

如何使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条回答 默认 最新

相关推荐 更多相似问题