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

same channel hadler in many go routiens #468

Open
rkr-rakesh opened this issue Aug 6, 2020 · 1 comment
Open

same channel hadler in many go routiens #468

rkr-rakesh opened this issue Aug 6, 2020 · 1 comment

Comments

@rkr-rakesh
Copy link

I am having single channel handler to publish message and this handler is passed to multiple go routine at same time.
Are channel handlers thread safe?

@bombsimon
Copy link
Contributor

bombsimon commented Sep 1, 2020

Yes.

EDIT: But should you do it? Please see #327 and follow the links from that issue to read about thread safety, concurrent publish, concurrent read/publish, single point of IO to the broker etc.

It's also worth mentioning that even though this code is thread safe in a sense that it won't panic it might result in an issue on the server side. I've personally only used this package with a single go routine managing the publishing on the channel. See here for example.

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