amqp icon indicating copy to clipboard operation
amqp copied to clipboard

same channel hadler in many go routiens

Open rkr-rakesh opened this issue 4 years ago • 1 comments

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?

rkr-rakesh avatar Aug 06 '20 14:08 rkr-rakesh

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.

bombsimon avatar Sep 01 '20 20:09 bombsimon