[rabbitmq-discuss] RabbitMQ erlang client documentation

Sylvain Hellegouarch sh at defuze.org
Thu Dec 3 19:49:53 GMT 2009


Hi Vlad,

>
>
> I will try to answer your questions.

Thanks for your swift reply.

>
>> it seems things have quite changed since
>> September
> As far as I know, apart from replacing the amqp_connection:start with 
> start_direct and start_network and the new approach with 
> #amqp_params{}, the API remained the same.
> Yes, there has been a lot of refactoring behind the scenes, but we 
> didn't touch the API.
>
>> For instance the test suite seems to suggest one should be using
>> amqp_connection:start(Params) to create a new connection but, unless I'm
>> mistaken, that function doesn't exist and you must use directly either
>> start_network or start_direct.
> The right way of starting a connection is using either of the 
> functions start_network or start_direct in amqp_connection. The start 
> function has been removed quite some time ago.

Thanks for clarifying this. I think there is one of the test module 
which might need some updates then.

>
>> Also, it's unclear whether or not you can safely reuse Connections 
>> across
>> several erlang nodes concurrently or if there are some issues in 
>> doing so.
>> Can I use one connection and cretae as many channels as I want? Should
>> channel be on a per erlang process basis?
> As far as I am aware both the connection and the channel processes 
> have been designed to be used from multiple processes. They are in 
> fact gen_server's.
> Not only that creating a single connection with as many channels as 
> you like is possible, but it is also the recommended style. The 
> maximum number of channels is 65535 I think, unless it is specified 
> otherwise by the server (RabbitMQ server doesn't specify another 
> limit). That should probably be more than enough.

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

>
>
>> I have a gen_server where I direct all my AMQP calls (publish, etc.) and
>> within that gen_server I create a pool of connections. Should this pool
>> reside in its own gen_server so that each connection belongs to one 
>> single
>> supervised erlang process? Currently I keep the pool within the
>> gen_server's state. But this means I'm concurrently using the same
>> connection for different channels. Is that safe?
> As answered above, you don't need to worry about using the connection 
> from different processes. The connection process itself is a 
> gen_server, and what you get with amqp_connection:start_network() is 
> just the pid of the spawned connection process, that you can use from 
> anywhere (any process) in your application.
> I'm not sure about your exact use case, but I think using a gen_server 
> to interface with the RabbitMQ Erlang client is unnecessary.

Meaning I don't need a connection pool I suppose. Cool.


Thanks Vlad,
- Sylvain




More information about the rabbitmq-discuss mailing list