Response inlined:<div><br></div><div>-Alan<br><br><div class="gmail_quote">On Thu, Feb 16, 2012 at 7:13 AM, Eric J. Holtman <span dir="ltr"><<a href="mailto:eric@holtmans.com">eric@holtmans.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've been hoping to get rabbitmq integrated into some<br>
of my applications. I've read a few books and web<br>
articles. I've wrangled the source into compiling and<br>
working under Windows. The examples run fine.<br>
<br>
I'm trying to figure out how to run under a multithreaded<br>
environment. As I understood it, the whole point of having<br>
a multiplexed connection was so that I didn't have to<br>
burn an actual TCP connection for every channel.<br>
<br>
However, that doesn't seem to be how rabbitmq-c is<br>
set up.<br>
<br>
In fact, a recent question from the archives, answered<br>
by Alan says:<br>
<br>
> You have interpreted the documentation correctly:<br>
><br>
> amqp_connection_state_t, its socket, and all associated amqp_channel_t's<br>
> must not be shared between threads. Its ok to have separate instances of<br>
> these objects used in different threads.<br>
<br>
So, if I want to consume on 4 queues, and the natural<br>
solution would be to have 4 threads doing a blocking<br>
wait (like "run" in the amqp_consumer example), I have<br>
to have a separate TCP connection for each one?<br></blockquote><div><br></div><div>Thats one way to do it. Another would be to a have a "connection thread" that would own the non-thread-safe objects, and would dispatch the messages to the worker threads. It takes a bit more code to accomplish it but its similar to how the Java and .NET clients work, which have a thread that handles events on a connection level, then the Channel objects associated with the Connection object can be on different threads.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Also, I assume if I'm going to use a c++ wrapper like<br>
amqpcpp or rabbitcpp I'm going to have the same issue,<br>
since they're using rabbitmq-c as the lower layer?<br></blockquote><div><br></div><div>Having not used either of those C++ wrappers I believe your assumption is correct, unless the implement their own event-loop or thread that dispatches consumed messages.</div>
<div><br></div><div>As a self-less plug, if you're looking for a C++ wrapper - I'd encourage you to checkout SimpleAmqpClient <a href="https://github.com/alanxz/SimpleAmqpClient">https://github.com/alanxz/SimpleAmqpClient</a>, which is Yet Another rabbitmq-c wrapper. It won't necessarily solve your threading question though.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
<br>
Eric<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a 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>
</blockquote></div><br></div>