Transferred from: http://www.cnblogs.com/lucifer1997/p/9438186.html
After AMQP and Mqtt (up to one time) are implemented, multiple queues are used to topic Exchange to listen to the same topic (topic) with the same switch, and find that the situation is different and feel a bit interesting, so it is recorded.
Use 2 Mqtt (A, B), 2 amqp (respectively, C, D) while listening for a topic,
Then send 4 messages to this topic as MQTT (1, 2, 3, 4, respectively),
Then send 4 messages in AMQP mode (5, 6, 7, 8, respectively),
The results are as follows:
A:1, 2, 3, 4, 5, 6, 7, 8;
B:1, 2, 3, 4, 5, 6, 7, 8;
C:1, 3, 5, 7;
D:2, 4, 6, 8.
Note that AMQP is roughly the same as MQTT when it is sent in encapsulation, and there are differences in reception.
AMQP receives messages in the form of polling, while Mqtt can receive them all.
As I continue to explore whether there is an interplay between the two, I find some interesting phenomena:
1. When AMQP and Mqtt are online at the same time, the two sides do not affect each other.
2. When only AMQP is online, a message is received, and an MQTT starts listening, and MQTT does not receive the message.
3. Receive a message when MQTT is online only, and then an AMQP starts listening, and AMQP can receive messages.
According to 2, 3 I launched: MQTT cannot read offline messages in the queue, the queue message is not deleted after reading online, and AMQP can read offline messages in the queue, and messages are deleted after the message is read.
Then, based on 1, I suspect that Mqtt reads the message before AMQP (not knowing right).
Turn: The similarities and differences between AMQP and MQTT messaging in RABBITMQ implementations