RabbitMQ common problems of repeated consumption

Scenes

First of all, make it clear that the message queue has a retry mechanism.

For example, the document service consumes the message of the form service, but an error occurs in the process of generating the word document.

Now that the form service re-sent a message, the problem is coming. The document service has a problem before, and now there is no problem in consuming this information, but the ES service is okay. If it consumes it again, isn't there an extra data?

Solution

Simply put, just make a judgment.

If it has been processed, no operation is performed; if it has not been processed, then it is operated.

Judgment logic writing:

Take the unique ID of the business in your project and make a judgment. The only ID in my project is the form ID. When the listener listens to the message, first judge whether the ID has been processed, ignored it, and perform the corresponding operation if it has not been processed.

Guess you like

Origin blog.csdn.net/numbbe/article/details/109291940