Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that connecting to Rabbit is threadsafe
When there are competing publisher threads, there is a chance that the publisher has not been initialized when Hutch is registered as connected. The following diagram should shed some light on the race condition: ``` Thread 1 Hutch Thread 2 -------- ------- --------- t1 Hutch.publish() ---> connected? (FALSE) |-> open_connection! t2 connected? (TRUE) <--- Hutch.publish() @broker.publish() |-> NoMethodError (@publisher) t3 |-> declare_publisher! PUBLISHED <-| @broker.publish() ``` Wrapping the `Hutch.connect` call should resolve this issue.
- Loading branch information