<div>I&#39;ve been working on a Ruby/EventMachine AMQP client over the past few days and I have a simple client up and running:<br></div><div><br></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;def receive_data data</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp;Frame.extract(data).each do |frame|<br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# log &#39;got a frame&#39;, frame</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case method = frame.payload</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;when Protocol::Connection::Start</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send Protocol::Connection::StartOk.new({:platform =&gt; &#39;Ruby/EventMachine&#39;,</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:product =&gt; &#39;AMQP&#39;,</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:information =&gt; &#39;<a href="http://github.com/tmm1/amqp">http://github.com/tmm1/amqp</a>&#39;,</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:version =&gt; &#39;0.0.1&#39;},</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;AMQPLAIN&#39;,</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {:LOGIN =&gt; &#39;guest&#39;,</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:PASSWORD =&gt; &#39;guest&#39;},</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;en_US&#39;)</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;when Protocol::Connection::Tune</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send Protocol::Connection::TuneOk.new :channel_max =&gt; 0,</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:frame_max =&gt; 131072,</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:heartbeat =&gt; 0</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send Protocol::Connection::Open.new :virtual_host =&gt; &#39;/&#39;,</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:capabilities =&gt; &#39;&#39;,</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:insist =&gt; false</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;when Protocol::Connection::OpenOk</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send Protocol::Channel::Open.new, :channel =&gt; 1</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp; &nbsp;end</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">&nbsp;&nbsp; &nbsp;end</span></div>
<div><br></div><div>Feedback and ideas for a higher-level queue/exchange/binding API are welcome.</div><div><br></div><div>&nbsp;&nbsp;Aman Gupta</div></div>