Of alibaba, there’s a phrase in “the code of effective”, says the technology to do, should have two qualities, it is a love, two is excellence, doing things like alone are not enough, depends on toughness and resistance to depend, only love is not like marriage, have to face daily necessities, contradiction between the tolerance when friction, but if there is no love, also not line, a few years ago to hear a joke, Development programmers not object-oriented development, but for money, said is very interesting, the beginning of things is dependent on the material, but after things developed, we even more is the spirit, or how to build spiritual civilization, the ashes of the idealism of red brick wall paints without love, finally must be boring.
There are pros and cons to RabbitMq, but you can’t do anything about it. The product manager is the one who provides better product solutions to users, the programmer is the one who provides better solutions to technical problems.
Several issues, repeated consumption, message loss, sequential consumption
1. Repeated consumption
This problem is caused by network problems. For example, the client clearly consumes successfully, but the network has a problem. As a result, the server thinks that the client does not consume, causing repeated push of messages.
The solution
1) Strong check
We can create a table on the server to store which messages have been consumed successfully, and then verify which messages have been consumed without processing.Copy the code
2) Weak check
Store consumed messages in Redis and set expiration time for verificationCopy the code
2 Message Loss
1) Producer messages are lost
A return value is all that is needed after this setting is successfully sentCopy the code
2) Queue messages are lost
Do a persistent to hard disk processingCopy the code
3) Message loss on the client
Also set a return value after receiving the messageCopy the code
3 Sequential consumption
To ensure that the order of the queue is in order, and that the client is multithreaded to ensure the order of messages, you can use locks.Copy the code