Skip to content

Sharing Channels Between Threads Using Locks #667

Closed Answered by michaelklishin
jorgasto asked this question in Q&A
Discussion options

You must be logged in to vote

This code assumes that Bunny::Channel#exchange calls cannot result in any kind of interleaving of frames on the wire. Right now this is generally true, and exchange.declare is a single protocol frame, and Bunny writes frames to the socket with synchronisation.

However, what's the point of declaring exchanges if you are not going to publish anything? And Bunny::Channel#publish produces two or more frames, depending on message size:

[basic.publish] [content header] [body]*

So even with synchronised writes of individual frames, you have to be really careful about not ending up with a sequence like this

[basic.publish 1] [basic.publish 2] [content header 2] [body 2]* [content header 1] [body…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@michaelklishin
Comment options

@sanghyukkang
Comment options

@michaelklishin
Comment options

@sanghyukkang
Comment options

@michaelklishin
Comment options

Answer selected by jorgasto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants