Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is necessary to modify publish to be synchronous #84

Open
lorentz-wu opened this issue Nov 29, 2024 · 2 comments
Open

It is necessary to modify publish to be synchronous #84

lorentz-wu opened this issue Nov 29, 2024 · 2 comments

Comments

@lorentz-wu
Copy link

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.

@pmorelli92
Copy link
Owner

Correct me if I am wrong, but the underlying amqp library does async publishes either way, so there is no way to force that.

https://pkg.go.dev/github.com/rabbitmq/amqp091-go#hdr-Asynchronous_Events
https://pkg.go.dev/github.com/rabbitmq/amqp091-go#Channel.Publish

What I can suggest you is to use the outbox sub module instead, so that the messages are stored in a db table and sent eventually, so no matter if the application stops it will eventually send the message.

https://github.com/pmorelli92/bunnify/tree/main/outbox
https://microservices.io/patterns/data/transactional-outbox.html

@lorentz-wu
Copy link
Author

Could you expose the interface for confirming the publish so that I can control and respond to it externally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants