in order to ensure that the message is sent successfully, based on the principle of base , the message is sent in two steps:
first, process the business logic and generate messages, which are stored in the library, which is a transaction.
this transaction is based on the database. Like mysql.
second, read the message and send it to the message queue [rabbitmq]. This is a business.
The message will have a status field. The steps are as follows: read the message and send the message. Based on the rabbitmq ack feature, ack will have several states:
1, send the ack, callback function successfully, and ack_function, delete the database message to ensure the deletion is successful.
2, the nack, callback function that failed to be sent is not handled by nack_function,. Waiting for the next transmission.
3, after sending, no exchange, or matching queue is available for message queuing. Execute the callback function, and return_function, does not do any processing
the question is, why do I set up mandatory=true, to execute ack_function after return_function is executed?
if ack_function. is called This logic is confused.
is it incorrect to use rabbitmq in this way under the guidance of experts? What is the correct way to use it?