Message Queue - a message buffer that RabbitMQ keeps on behalf of the consumer.
无论是发送还是接收前,都需要先queue_declare,不然会发送丢失或接收失败.
Avoid doing a resource-intensive task immediately and having to wait for it to complete.
Consumer对Queue不是独占的,如果有多个Consumer同时消费一个Queue,会以round-robin的方式消费掉所有的消息
默认情况下,当一个消息进入queue后,broker是直接将消息按照round-robin的方式分配到每个consumer. 如果任务之间是不均衡的,有可能出现饥饿的消费者. 解决方法: 在一个consumer发送ack前,不要将消息再发送给此consumer(prefetch=1)
Fan-out的Exchange会出现一个风险,就是当没有队列的时候,如果有消息发送到Exchange,消息会被丢弃掉.
The messages will be lost if no queue is bound to the exchange yet, but that's okay for us; if no consumer is listening yet we can safely discard the message.