[rabbitmq-discuss] basic public-subscribe model with erlang-client

Ben Hood 0x6e6562 at gmail.com
Mon Mar 31 22:33:10 BST 2008


Joe,

On 31 Mar 2008, at 22:05, joe lee wrote:

> Anyone knows how to do a basic publish (asynchronous method, no  
> syncing with broker) using erlang-client, either in amqp mode or  
> erlang mode?

If I understand you correctly, if you want to publish a message, you  
can do the following:

BasicPublish = #'basic.publish'{ticket = Ticket, exchange = X,
                                     routing_key = RoutingKey,
                                     mandatory = Mandatory,
                                     immediate = Immediate},
Content = #content{class_id = 60,
          properties = amqp_util:basic_properties(), %% either 'none',  
or a decoded record/tuple
          properties_bin = 'none', %% either 'none', or an encoded  
properties amqp_util:binary
          %% Note: at most one of properties and properties_bin can be  
'none' at once.
          payload_fragments_rev = [Payload] %% list of binaries, in  
reverse order (!)
         },
amqp_channel:cast(Channel, BasicPublish, Content),

This code is taken from the setup_publish/3 function in the test_util  
module of the Erlang client.

The cast/3 function in amqp_channel sends the message asynchronously  
irrespective of whether you are using the TCP variant or native Erlang  
messaging.

BTW, what do you mean when you say "amqp mode or erlang mode"?

> I have a queue and need to send message to the queue asynchronously  
> and consumer will come along and process it.  If you are doing  
> publish-subscribe, do you define a queue like you do for  
> sysnchronous method?

I'm not quite sure I follow. Which synchronous method are you  
referring to?

HTH,

Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080331/ef3f29c1/attachment.htm 


More information about the rabbitmq-discuss mailing list