[rabbitmq-discuss] RabbitMQ erlang client documentation

Sylvain Hellegouarch sh at defuze.org
Fri Dec 4 08:08:43 GMT 2009


Vlad,

>> Should channels be on per process basis? Say I create a channel, can I
>> publish more than once without having to wait for each ack? Or is
>> there a sequential constraint so that the channel knows where to
>> propagate the potential ack from the server
> You can use a channel from more than one process. The channel process
> queues up the calls and sends them to the server one by one (sends one,
> waits for reply, sends the next, waits for reply etc). While a call is
> in the queue to be sent to the server, the (user) process which
> initiated the call is blocked while the methods in front in the queue
> are processed plus the time for our actual call.
> So the channel takes care of serializing the methods and remembers which
> process sent which method so it can reply (return value) to user
> processes accordingly.
> However, due to the synchronous nature of this mechanism, just one
> channel will not utilize the entire bandwidth available (e.g. while the
> channel is waiting for the reply, it does not send the next call). For
> this reason, it is advisable to split tasks that have no relation to
> each other (the order of the events does not matter between tasks) so
> that they use separate channels.
>
> All the above applies to synchronous methods (like basic.get for example).
> Asynchronous methods (like basic.publish) are not queued up. They are
> sent immediately no matter what is in the queue (a call may end up after
> a cast at the server even though the call was made before the cast, if
> the call has to wait in line).
>
> You can use amqp_channel:call/{2,3} for both sync and async methods
> (async methods return 'ok' immediately) and amqp_channel:cast/{2,3} only
> for async methods.
>
>


Thanks for all of this. There is one point I'm uncertain about. In my use
case I'm using mochiweb to push HTTP body requests into AMQP. I've looked
at the rabbitmq-mochiweb project but I couldn't find any point in the
source where they would actually be calling AMQP at all (as teh doc says
it's mainly a placeholder project).

Anyway, currently I have one single connection and I'm opening a channel
for each HTTP request, publishing and immediatly closing that channel. Is
that the most efficient usage of the erlang lib? If not, any hints to
improve it if you don't mind?

Cheers again,
- Sylvain
-- 
Sylvain Hellegouarch
http://www.defuze.org




More information about the rabbitmq-discuss mailing list