<div>I'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: 'courier new', monospace;"> def receive_data data</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> Frame.extract(data).each do |frame|<br></span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> # log 'got a frame', frame</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> </span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> case method = frame.payload</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> when Protocol::Connection::Start</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> send Protocol::Connection::StartOk.new({:platform => 'Ruby/EventMachine',</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :product => 'AMQP',</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :information => '<a href="http://github.com/tmm1/amqp">http://github.com/tmm1/amqp</a>',</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :version => '0.0.1'},</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> 'AMQPLAIN',</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> {:LOGIN => 'guest',</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :PASSWORD => 'guest'},</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> 'en_US')</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> when Protocol::Connection::Tune</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> send Protocol::Connection::TuneOk.new :channel_max => 0,</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :frame_max => 131072,</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :heartbeat => 0</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> send Protocol::Connection::Open.new :virtual_host => '/',</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :capabilities => '',</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> :insist => false</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> when Protocol::Connection::OpenOk</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> send Protocol::Channel::Open.new, :channel => 1</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> end</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> end</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> 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> Aman Gupta</div></div>