Inlined:<div><br></div><div>-Alan<br><br><div class="gmail_quote">On Thu, Mar 15, 2012 at 9:57 AM, Artsiom <span dir="ltr"><<a href="mailto:u2.storm@gmail.com">u2.storm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
I some questions concerning multithreading and using multiple
channels within single connection.<br>
<br>
Is structure amqp_connection_state_t is thread-safe?<br>
Can I share connection between threads and at the same time<br>
use separate channel for each thread in producer app? and in
consumer app?<br></div></blockquote><div><br></div><div>The amqp_connection_state_t object is not synchronized. In order to use it from multiple threads you would have to synchronize its use across threads (provide some external mutual exclusion when calling any amqp_* function that uses a common amqp_connection_state_t).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<br>
The second part of the question(about consumer) is needed to be
explained.<br>
When I looked at API, I didn't find any difficulties to use many
channels within single connection<br>
in producer app, because each method (declare queue\exchange, bind,
publish & etc) has<br>
"channel" parameter.<br>
<br>
But in consumer app, where it is needed to receive messages (or
frames as shown in example .c-files),<br>
we have to call wait_for_single_frame method, which is lack of
"channel" method.<br>
Could you give an advice how to organize "multichannel" message
fetch from<br>
one queue?<br></div></blockquote><div><br></div><div>The API for consuming messages is pretty low-level at this point. In order to consume from multiple channels you need to read messages from all the channels using amqp_simple_wait_frame, then provide your own logic to handle messages from different channels appropriately.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<br>
<br>
<b>OR</b><br>
It is better to use separate connection for each thread and have no
problems? :)<br>
<br></div></blockquote><div>That would the the easiest way to get started. </div></div><br></div>