[rabbitmq-discuss] RabbitMQ erlang client documentation
Sylvain Hellegouarch
sh at defuze.org
Fri Dec 4 21:51:11 GMT 2009
Vlad Alexandru Ionescu a écrit :
> Sylvain,
>
>> 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?
>
> I think you're better off keeping the channel open as well, and using
> it (just one channel) for all your requests, since you're sending only
> basic.publish (which is an async method). This way you can avoid the
> delay of sending channel.open and then waiting for channel.open_ok for
> every request.
> Nagle is turned off in the Erlang client so the methods are sent
> promptly.
> Also, I suggest you use amqp_channel:cast/3 rather than
> amqp_channel:call/3. The cast function returns a bit quicker than the
> call function (lets your process continue quicker).
>
>
> Vlad.
>
>
Thanks Vlad.
Before your reply I had opted for a pool of channels opened on one
connection. That pool is created once when I start my process and passed
along. Each time I publish I just get one random channel from that pool.
It has been working great, anything in particular against this idea?
Since I need to get the actual result of the publish op, I thought I
needed to use call rather than cast (as a per my gen_server expectation
anyway).
- Sylvain
More information about the rabbitmq-discuss
mailing list