The publish function is asynchronous, and after sending, it may not have finished yet. The issue is when the producer should close the connection. It is necessary to modify publish to be synchronous, so that it confirms the message has been sent before returning.
The publish function is asynchronous, and after sending, it may not have finished yet. The issue is when the producer should close the connection. It is necessary to modify publish to be synchronous, so that it confirms the message has been sent before returning.