<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Important addendum: <span id="summary_alias_container"> <span
        id="short_desc_nonedit_display">channel calls are *not*
        thread-safe for confirmations</span></span>: The channel
    interface is thread-safe now, except for counting confirms and
    checking!<br>
    <br>
    There is an outstanding bug to review this, and the problems
    associated with the fact that publishing and receiving a seqno is
    not an atomic operation.<br>
    <br>
    Anyway - you *may* wish to share a Channel between threads or not,
    but if you're using confirms then you should *not* share a Channel
    between multiple threads. I'll make sure the javadoc changes reflect
    this state of affairs.<br>
    <br>
    Cheers,<br>
    Tim<br>
    <br>
    On 10/23/2012 11:29 AM, Tim Watson wrote:
    <blockquote cite="mid:508671A5.6050007@rabbitmq.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      Actually, that's not quite right. Channels *are* thread safe in
      the java-client, and can be shared across multiple threads if you
      wish. As the Java client API documentation (<a
        moz-do-not-send="true" class="moz-txt-link-freetext"
        href="http://www.rabbitmq.com/api-guide.html">http://www.rabbitmq.com/api-guide.html</a>)
      states however:<br>
      <br>
      "<span class="code ">Channel</span> instances are safe for use by
      multiple threads. Requests into a <span class="code ">Channel</span>
      are serialized, with only one thread being able to run a command
      on the <span class="code ">Channel</span> at a time. Even so,
      applications should prefer using a <span class="code ">Channel</span>
      per thread instead of sharing the same <span class="code ">Channel</span>
      across multiple threads."<br>
      <br>
      In other words, because the transmission of AMQP commands via a
      given Channel is serialised, there is probably little or no
      benefit in sharing the channel between threads.<br>
      <br>
      Unfortunately, whilst we've updated the documentation on the
      website to reflect this change (which was merged in September 2011
      and released in 2.7.0) we appear to have missed the javadocs for
      the Channel class - I will get that fixed asap so as to avoid any
      further confusion!<br>
      <br>
      Cheers,<br>
      Tim<br>
      <br>
      On 10/23/2012 02:08 AM, Laurent Vauthrin wrote:
      <blockquote
cite="mid:CAM8Y7yCLUSV9ker3OWqENkKEFEWPoppos0k3jehWb3-8wqyPaA@mail.gmail.com"
        type="cite"><font color="#333333"><font face="tahoma,sans-serif">Thanks

            for clearing that up!<br>
          </font></font><br>
        <div class="gmail_quote">On Mon, Oct 22, 2012 at 3:46 PM,
          Michael Klishin <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:michael.s.klishin@gmail.com" target="_blank">michael.s.klishin@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
            <br>
            <div class="gmail_quote">
              <div class="im">2012/10/22 Laurent Vauthrin <span
                  dir="ltr">&lt;<a moz-do-not-send="true"
                    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 face="tahoma, sans-serif" color="#333333">My

                      questions are:</font></div>
                  <div><font face="tahoma, sans-serif" color="#333333">1.

                      Should we be using a channel per thread
                      considering that we're synchronizing the
                      basicPublish call anyway?</font></div>
                </blockquote>
                <div><br>
                </div>
              </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 class="im">
                <div>&nbsp;</div>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div><font face="tahoma, sans-serif" color="#333333">2.

                      Can we just share one channel across all threads
                      and not synchronize the call to basicPublish?</font></div>
                </blockquote>
              </div>
            </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't be able to tell how to reconstruct your
              messages.</div>
            <span class="HOEnZb"><font color="#888888">-- <br>
                MK<br>
                <br>
                <a moz-do-not-send="true"
                  href="http://github.com/michaelklishin"
                  target="_blank">http://github.com/michaelklishin</a><br>
                <a moz-do-not-send="true"
                  href="http://twitter.com/michaelklishin"
                  target="_blank">http://twitter.com/michaelklishin</a><br>
                <br>
              </font></span><br>
            _______________________________________________<br>
            rabbitmq-discuss mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
            <a moz-do-not-send="true"
href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss"
              target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
rabbitmq-discuss mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a>
</pre>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rabbitmq-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a>
<a class="moz-txt-link-freetext" href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>