When the rabbitmq message is sent and mandatory is ture, why execute ack after return?

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?

Mar.06,2021

Wow, I recently encountered this problem in learning rabbitmq. I have always thought that ack/nack/return is the three mutually exclusive return functions of publisher confirm.
went to stackoverflow and found an answer. I don't know if it is correct (the original answer address https://stackoverflow.com/a/5.
is tested according to my own code. The shallow view is that ack/nack will be called immediately after confirm_select is enabled. The scenario depends on whether broker correctly receives the information of Publisher, while in the case of mandatory=true, it is added to exchange- > queue, that is, whether it is routed correctly to the queue (whether exchange has binding queue or exchange routing_key cannot find the corresponding queue.. In addition, if exchange does not exist, Publish reports wrong directly.
that is, in the case of publish confirm, ack/nack is bound to choose one of the two, while return is only related to mandatory, ack/nack is mutually exclusive, and return and the former two are not

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2c11b-2b33a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2c11b-2b33a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?