<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Joe,<div><br><div><html>On 31 Mar 2008, at 22:05, joe lee wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite">Anyone knows how to do a basic publish (asynchronous method, no syncing with broker) using erlang-client, either in amqp mode or erlang mode?<br></blockquote><div><br></div><div>If I understand you correctly, if you want to publish a message, you can do the following:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: #966400">BasicPublish</span> <span style="color: #32325a">=</span> <span style="color: #32325a">#</span>'basic.publish'<span style="color: #32325a">{</span>ticket <span style="color: #32325a">=</span> <span style="color: #966400">Ticket</span><span style="color: #32325a">,</span> exchange <span style="color: #32325a">=</span> <span style="color: #966400">X</span><span style="color: #32325a">,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> routing_key <span style="color: #32325a">=</span> <span style="color: #966400">RoutingKey</span><span style="color: #32325a">,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> mandatory <span style="color: #32325a">=</span> <span style="color: #966400">Mandatory</span><span style="color: #32325a">,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> immediate <span style="color: #32325a">=</span> <span style="color: #966400">Immediate</span><span style="color: #32325a">},</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: #966400">Content</span> <span style="color: #32325a">=</span> <span style="color: #32325a">#</span>content<span style="color: #32325a">{</span>class_id <span style="color: #32325a">=</span> <span style="color: #5a5ab4">60</span><span style="color: #32325a">,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> properties <span style="color: #32325a">=</span> amqp_util<span style="color: #32325a">:</span>basic_properties<span style="color: #32325a">(),</span> <span style="color: #007300">%% either 'none', or a decoded record/tuple</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(0, 115, 0); "><span style="color: #000000"> properties_bin </span><span style="color: #32325a">=</span><span style="color: #000000"> 'none'</span><span style="color: #32325a">,</span><span style="color: #000000"> </span>%% either 'none', or an encoded properties amqp_util:binary</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(0, 115, 0); "><span style="color: #000000"> </span>%% Note: at most one of properties and properties_bin can be 'none' at once.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(0, 115, 0); "><span style="color: #000000"> payload_fragments_rev </span><span style="color: #32325a">=</span><span style="color: #000000"> </span><span style="color: #32325a">[</span><span style="color: #966400">Payload</span><span style="color: #32325a">]</span><span style="color: #000000"> </span>%% list of binaries, in reverse order (!)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> <span style="color: #32325a">},</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(150, 100, 0); "><span style="color: #000000">amqp_channel</span><span style="color: #32325a">:</span><span style="color: #000000">cast</span><span style="color: #32325a">(</span>Channel<span style="color: #32325a">,</span><span style="color: #000000"> </span>BasicPublish<span style="color: #32325a">,</span><span style="color: #000000"> </span>Content<span style="color: #32325a">),</span></div></div><div><br></div>This code is taken from the setup_publish/3 function in the test_util module of the Erlang client.</div><div><br></div><div>The cast/3 function in amqp_channel sends the message asynchronously irrespective of whether you are using the TCP variant or native Erlang messaging.</div><div><br></div><div>BTW, what do you mean when you say "amqp mode or erlang mode"?</div><div><br><blockquote type="cite">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? <br></blockquote></div><br></div><div>I'm not quite sure I follow. Which synchronous method are you referring to?</div><div><br></div><div>HTH,</div><div><br></div><div>Ben</div></body></html>