[rabbitmq-discuss] AMQP ruby client

Alexis Richardson alexis.richardson at cohesiveft.com
Fri Jul 18 09:24:09 BST 2008


Aman

Congrats on your Ruby API for RabbitMQ :-)

On Fri, Jul 18, 2008 at 2:57 AM, Aman Gupta <rabbitmq at tmm1.net> wrote:
> I've just finished a simple high level api, and committed several examples
> showing off direct, topic, fanout and rpc style messaging over rabbitmq:
>   http://github.com/tmm1/amqp/tree/master/examples/pingpong.rb
>   http://github.com/tmm1/amqp/tree/master/examples/clock.rb
>   http://github.com/tmm1/amqp/tree/master/examples/stocks.rb
>   http://github.com/tmm1/amqp/tree/master/examples/hashtable.rb

Thanks so much for this, those examples are really useful.


> The API revolves around an MQ object, which corresponds 1:1 with an AMQP
> channel. An AMQP connection is created automatically by the MQ class (on
> demand), so you don't have to worry about connection, channel or sessions.
> In the simplest case, MQ objects allow publishing to exchanges and reading
> from queues:
>   amq = MQ.new
>   amq.queue('queue_name').subscribe{ |msg|
>     puts "i got a message: #{msg}"   # msg == "hello world"
>   end
>   amq.direct.publish('hello world', :key => 'queue_name')

Cool.  This a great base API.

So .. I guess what we are finding when talking about RabbitMQ with
folks from the Ruby and RoR community is that there are quite a few
different approaches to messaging.  In fact many people find messaging
to be unfamiliar and in need of explanation and use cases.

For example: http://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue

For some people, a cache / hashtable type approach, where everything
looks like a 'get' or a 'set' feels intuitive.  Others like
ActiveMessaging.  Do you have a view on whether higher level APIs, eg
defaulting to a subset of all behaviours, would be of interest to
people?

And - generally - what do folks on the list think?

Cheers,

alexis








>   Aman Gupta
>
> On Sat, Jul 12, 2008 at 2:45 AM, Aman Gupta <rabbitmq at tmm1.net> wrote:
>>
>> I've been working on a Ruby/EventMachine AMQP client over the past few
>> days and I have a simple client up and running:
>>
>>     def receive_data data
>>       Frame.extract(data).each do |frame|
>>         # log 'got a frame', frame
>>
>>         case method = frame.payload
>>         when Protocol::Connection::Start
>>           send Protocol::Connection::StartOk.new({:platform =>
>> 'Ruby/EventMachine',
>>                                                   :product => 'AMQP',
>>                                                   :information =>
>> 'http://github.com/tmm1/amqp',
>>                                                   :version => '0.0.1'},
>>                                                  'AMQPLAIN',
>>                                                  {:LOGIN => 'guest',
>>                                                   :PASSWORD => 'guest'},
>>                                                  'en_US')
>>         when Protocol::Connection::Tune
>>           send Protocol::Connection::TuneOk.new :channel_max => 0,
>>                                                 :frame_max => 131072,
>>                                                 :heartbeat => 0
>>           send Protocol::Connection::Open.new :virtual_host => '/',
>>                                               :capabilities => '',
>>                                               :insist => false
>>         when Protocol::Connection::OpenOk
>>           send Protocol::Channel::Open.new, :channel => 1
>>         end
>>       end
>>     end
>> Feedback and ideas for a higher-level queue/exchange/binding API are
>> welcome.
>>   Aman Gupta
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>




More information about the rabbitmq-discuss mailing list