[rabbitmq-discuss] Erlang Consumer Example

anton prokofiev a.d.prokofiev at gmail.com
Sun Jul 29 21:59:46 BST 2012

On Sunday, 29 July 2012 21:21:06 UTC+2, anton prokofiev wrote:
> Hello, All!
> I tried to create  a consumer in Erlang for RabbitMQ and get into big 
> troubles.
> Looks like examples that are available in RabbitMQ website did not work.
> I have found an old post here
> https://groups.google.com/forum/?hl=en&fromgroups#!topicsearchin/rabbitmq-discuss/$20{function_clause,[{amqp_channel,build_content,/rabbitmq-discuss/WttoYWjFweU
> unfortunately it is not to clear to me what to do.
> Could somebody provide me with a full example of consumer?
> Thanks a lot in advance.
> Looks like I have found a correct solution:

1. I have implemented simple gen_server, that just print all messages to 
the stdout.

2. And  to like this:
  {ok,Connection} = amqp_connection:start(ConnectionParams), % open 
connection with predefined params.
  {ok,Pid} =  test_srv:start_link(),    % Start our own consumer.
  {ok,Channel}  = amqp_connection:open_channel(Connection,none,*

Then subscribe to the massages as described in the documentation.

In this cases all messages (basic.consume, basic.consume_ok,basic.deliver) 
are received through  handle_info method call of test_srv.

Now the question: 
Would it be better to create my own implementation of consume behavior, or 
handle them thought the message_info as it is now?
Any recommendations?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120729/87b3a7b3/attachment.htm>

More information about the rabbitmq-discuss mailing list