[rabbitmq-discuss] Ruby-AMQP with Federation doesn't work?

Roman Gaufman hackeron at gmail.com
Mon Jul 2 21:19:03 BST 2012


Just an update, I have created a repository that shows exactly what I'm
trying to do:

https://github.com/hackeron/ruby-amqp-federation-example

The maintainer of Ruby-AMQP has been helping me with this a great deal
(thank you!) and I'm finally able to get federated messaged :) - only error
now is if the message rate is higher than around 1 message/sec, I get:

E, [2012-07-02T21:06:54.126367 #4399] ERROR -- : [amqp] Detected missing
server heartbeats

A workaround is explicitly setting the
heartbeat: AMQP.start('amqp://guest:guest@localhost:25672', :heartbeat => 0)

Hope others struggling to get Federation working with Ruby-AMQP will find
this useful,

Roman


On 2 July 2012 02:09, Roman Gaufman <hackeron at gmail.com> wrote:

> I'm trying to get the Ruby-AMQP gem working with RabbitMQ's federation
> plugin.
>
> I have a federation set up as following:
>
> {rabbitmq_federation,
>    [ {exchanges, [[{exchange,     "xanview"},
>                    {virtual_host, "/"},
>                    {type,         "topic"},
>                    {durable,      true},
>                    {auto_delete,  false},
>                    {internal,     false},
>                    {upstream_set, "my-upstreams"}]
>                  ]},
>
> It appears in the web interface as:
>
> Type    x-federation
> Parameters   arguments: upstream-set:   my-upstreams
>                                                 type:   topic
>                          durable:   true
>
> I try to use it in Ruby in a consumer like this:
>
> exchange = AMQP::Exchange.new(channel, "x-federation", "my-exchange", :durable => true)
>
> However in the RabbitMQ config I get this error:
>
> connection <0.16597.1>, channel 2 - error:
> {amqp_error,precondition_failed,
>             "inequivalent arg 'type'for exchange 'xanview' in vhost '/': received none but current is the value 'topic' of type 'longstr'",
>             'exchange.declare'}
>
> It seems something in the Ruby-AMQP gem is preventing me from using an
> exchange type "x-federation"?
>
> Also when I try to consume messages sent to a federated exchange using
> your typical:
>
> AMQP.start('amqp://guest:guest@localhost:25672') do |connection, open_ok|
>   channel  = AMQP::Channel.new(connection)
>   channel.queue("", :durable => true) do |queue|
>     queue.bind('xanview', :routing_key => '#')
>     queue.subscribe do |metadata, payload|
>       puts "Recieved message: #{payload.inspect}."
>     end
>   end end
>
> I get this exception for the first message received:
>
> /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/table.rb:89:in `decode': NotImplementedError (NotImplementedError)    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/table_value_decoder.rb:144:in `decode_hash'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/table_value_decoder.rb:46:in `decode_array'
>     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/table.rb:99:in `decode'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/client.rb:1560:in `block in decode_properties'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/client.rb:1543:in `each'
>     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/client.rb:1543:in `decode_properties'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/frame.rb:142:in `decode_payload'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-protocol-0.9.3/lib/amq/protocol/frame.rb:115:in `body_size'
>     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-client-0.9.3/lib/amq/client/async/adapter.rb:675:in `content_complete?'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-client-0.9.3/lib/amq/client/async/adapter.rb:667:in `frameset_complete?'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-client-0.9.3/lib/amq/client/async/adapter.rb:518:in `receive_frame'
>     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amq-client-0.9.3/lib/amq/client/async/adapters/event_machine.rb:327:in `receive_data'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
>     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/amqp-0.9.6/lib/amqp/connection.rb:38:in `start'    from client1.rb:7:in `<main>'
>
> Any advice would be greatly appreciated. Maybe someone has an example of
> using RabbitMQ Federation with the Ruby-AMQP gem?
>
> Thank you,
>
> Roman
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120702/d766f157/attachment.htm>


More information about the rabbitmq-discuss mailing list