<br><br><div class="gmail_quote">2012/10/22 Laurent Vauthrin <span dir="ltr">&lt;<a href="mailto:lvauthrin@gmail.com" target="_blank">lvauthrin@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><font color="#333333" face="tahoma, sans-serif">My questions are:</font></div><div><font color="#333333" face="tahoma, sans-serif">1. Should we be using a channel per thread considering that we&#39;re synchronizing the basicPublish call anyway?</font></div>

</blockquote><div><br></div><div>Yes. Channels are just integer on the wire and a little bit of memory allocated on the JVM heap. They are very cheap</div><div>for all intents and purposes and you are much more likely to max out your OS and hardware resources (assuming 1 channel per JVM thread) before</div>

<div>you run into issues with channel objects.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><font color="#333333" face="tahoma, sans-serif">2. Can we just share one channel across all threads and not synchronize the call to basicPublish?</font></div></blockquote></div><br><br clear="all"><div>No. The real issue with shared channels is that large messages will result in multiple protocol frames being sent</div>

<div>for a single basicPublish operation. When publishing on the same channel from multiple threads, this may result</div><div>in frames being delivered out of order:</div><div><br></div><div>T1 =&gt; basicPublish =&gt; [Frame11] [Frame12] [Frame13]</div>

<div>T2 =&gt; basicPublish =&gt; [Frame21] [Frame22] [Frame23]</div><div><br></div><div>may result in the following delivery order, all on the same channel:</div><div><br></div><div>[Frame11][Frame21][Frame12][Frame13][Frame22][Frame23]</div>

<div><br></div><div>and because all frames are on the same channel, RabbitMQ won&#39;t be able to tell how to reconstruct your messages.</div>-- <br>MK<br><br><a href="http://github.com/michaelklishin" target="_blank">http://github.com/michaelklishin</a><br>

<a href="http://twitter.com/michaelklishin" target="_blank">http://twitter.com/michaelklishin</a><br><br>