Repeat Consumption rabbitmq (five), the message

Ensure that key messages are not repeated consumption is to ensure that the message queue idempotency, the problem for the business scenarios to answer the following points:

One, for example, do you get this message insert the database. It would be easy to give this message to make a unique primary key, even if the situation repeated consumption occurs, it will lead to a primary key conflict, to avoid the database appear dirty data.

Second, another example, do you get the news operation set the redis, it would be easy, not solve, because you set several times whether the results are the same, even if the power had set the operation and other operations.

3. If the above two cases is not enough, the big move. Prepare a third-party media, do consumer records. In redis example, a global id assigned to the message, as long as the message consumer through the <id, message> redis written in the form of KV. Before consumers start spending it, go redis there is no consumption record query can be.

Guess you like

Origin www.cnblogs.com/dwxblogs/p/10951380.html