Exchange bindings aren't recovered #410

Closed
camelpunch opened this Issue Jun 3, 2016 · 1 comment

Projects

None yet

1 participant

@camelpunch
Contributor
camelpunch commented Jun 3, 2016 edited

I was reading the code in channel.rb and believe that exhange bindings don't get recovered. An initial exploratory test seems to back this up.

Example session output (worth checking the steps here):

irb(main):001:0> require 'bunny'
=> true
irb(main):002:0> s=Bunny.new
=> #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>
irb(main):004:0> s.start
=> #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>
irb(main):005:0> ch=s.create_channel
=> #<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>
irb(main):006:0> q=ch.queue('asdf')
=> <Bunny::Queue:0x7ff6728dca78 @name="asdf" channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>> @durable= @auto_delete= @exclusive= @arguments=>
irb(main):007:0> e=ch.direct('bob')
=> #<Bunny::Exchange:0x007ff6728cfbc0 @channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>, @name="bob", @type=:direct, @options={:queue=>"bob", :nowait=>false}, @durable=nil, @auto_delete=nil, @internal=nil, @arguments=nil>
irb(main):008:0> f=ch.direct('fred')
=> #<Bunny::Exchange:0x007ff6738510a8 @channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>, @name="fred", @type=:direct, @options={:queue=>"fred", :nowait=>false}, @durable=nil, @auto_delete=nil, @internal=nil, @arguments=nil>
irb(main):009:0> f.bind(e)
=> #<Bunny::Exchange:0x007ff6738510a8 @channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>, @name="fred", @type=:direct, @options={:queue=>"fred", :nowait=>false}, @durable=nil, @auto_delete=nil, @internal=nil, @arguments=nil>
irb(main):010:0> q.bind(f)
=> <Bunny::Queue:0x7ff6728dca78 @name="asdf" channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>> @durable= @auto_delete= @exclusive= @arguments=>
irb(main):011:0> e.publish('foobar')
=> #<Bunny::Exchange:0x007ff6728cfbc0 @channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>, @name="bob", @type=:direct, @options={:queue=>"bob", :nowait=>false}, @durable=nil, @auto_delete=nil, @internal=nil, @arguments=nil>
irb(main):012:0> q.pop
=> [{:delivery_tag=>#<Bunny::VersionedDeliveryTag:0x007ff67218a220 @tag=1, @version=0>, :redelivered=>false, :exchange=>"bob", :routing_key=>"", :channel=>#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>}, {:content_type=>"application/octet-stream", :delivery_mode=>2, :priority=>0}, "foobar"]
irb(main):013:0> E, [2016-06-03T09:46:40.042549 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: Exception in the reader loop: AMQ::Protocol::EmptyResponseError: Empty response received from the server.
E, [2016-06-03T09:46:40.042612 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: Backtrace:
E, [2016-06-03T09:46:40.042649 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>:  /Users/pivotal/.gem/ruby/2.2.2/gems/amq-protocol-2.0.1/lib/amq/protocol/frame.rb:60:in `decode_header'
E, [2016-06-03T09:46:40.042673 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>:  /Users/pivotal/.gem/ruby/2.2.2/gems/bunny-2.3.1/lib/bunny/transport.rb:245:in `read_next_frame'
E, [2016-06-03T09:46:40.042691 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>:  /Users/pivotal/.gem/ruby/2.2.2/gems/bunny-2.3.1/lib/bunny/reader_loop.rb:68:in `run_once'
E, [2016-06-03T09:46:40.042734 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>:  /Users/pivotal/.gem/ruby/2.2.2/gems/bunny-2.3.1/lib/bunny/reader_loop.rb:35:in `block in run_loop'
E, [2016-06-03T09:46:40.042771 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>:  /Users/pivotal/.gem/ruby/2.2.2/gems/bunny-2.3.1/lib/bunny/reader_loop.rb:32:in `loop'
E, [2016-06-03T09:46:40.042791 #2617] ERROR -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>:  /Users/pivotal/.gem/ruby/2.2.2/gems/bunny-2.3.1/lib/bunny/reader_loop.rb:32:in `run_loop'
W, [2016-06-03T09:46:40.042822 #2617]  WARN -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: Recovering from a network failure...
W, [2016-06-03T09:46:45.043673 #2617]  WARN -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: Retrying connection on next host in line: 127.0.0.1:5672
W, [2016-06-03T09:46:45.044084 #2617]  WARN -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: Could not establish TCP connection to 127.0.0.1:5672: Connection refused - connect(2) for 127.0.0.1:5672
W, [2016-06-03T09:46:45.044174 #2617]  WARN -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: TCP connection failed, reconnecting in 5.0 seconds
W, [2016-06-03T09:46:55.048704 #2617]  WARN -- #<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>: Retrying connection on next host in line: 127.0.0.1:5672

irb(main):014:0* e.publish('bazqux')
=> #<Bunny::Exchange:0x007ff6728cfbc0 @channel=#<Bunny::Channel:70348230310000 @id=1 @connection=#<Bunny::Session:0x7ff6721d8178 guest@127.0.0.1:5672, vhost=/, addresses=[127.0.0.1:5672]>>, @name="bob", @type=:direct, @options={:queue=>"bob", :nowait=>false}, @durable=nil, @auto_delete=nil, @internal=nil, @arguments=nil>
irb(main):015:0> q.pop
=> [nil, nil, nil]
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 12, 2016
@camelpunch camelpunch Re-enable recovery tests in CI
Prep for fixing #410
0a41896
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 12, 2016
@camelpunch camelpunch Remove unused let
Issue #410
38d1304
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Extract Method to replace Comment
Issue #410
0e52284
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Move spec helpers to bottom of spec file
Having the interesting stuff at the top makes the test more readable.

Issue #410
7a9352d
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Remove unnecessary begin/end
Issue #410
ce94a6a
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Inline helper in broken exchange example
This allows us to read the example without 'bouncing' to the helper
definition.

Issue #410
1809e38
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Remove commented debug code
Issue #410
c67d123
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch require amq/protocol from exchange.rb
This is needed in order to load exchange.rb in solitude e.g. from a unit
test.

Issue #410
6eea36e
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Recover exchanges and their bindings
Introduce test helper in recovery spec to expect loss, then recovery of
a predicate.

Issue #410
ee31af6
@camelpunch camelpunch added a commit to camelpunch/bunny that referenced this issue Jun 13, 2016
@camelpunch camelpunch Rework recovery test
- Wait for state changes on HTTP API, with timeouts. This is about 3x
  faster than the previous constant sleeps on my machine.
- Silence log output
- Pend out an example that was incorrectly passing
  (attempt limits: ruby-amqp#408)

Issue #410
1ca321b
@camelpunch
Contributor
@camelpunch camelpunch closed this Jun 20, 2016
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Re-enable recovery tests in CI
Prep for fixing #410
2dd27bc
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Remove unused let
Issue #410
d222229
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Extract Method to replace Comment
Issue #410
cf08b1c
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Move spec helpers to bottom of spec file
Having the interesting stuff at the top makes the test more readable.

Issue #410
6bb744c
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Remove unnecessary begin/end
Issue #410
a8602e5
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Inline helper in broken exchange example
This allows us to read the example without 'bouncing' to the helper
definition.

Issue #410
7e9109f
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Remove commented debug code
Issue #410
37ae885
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin require amq/protocol from exchange.rb
This is needed in order to load exchange.rb in solitude e.g. from a unit
test.

Issue #410
ff023e6
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Recover exchanges and their bindings
Introduce test helper in recovery spec to expect loss, then recovery of
a predicate.

Issue #410
63b64d3
@michaelklishin michaelklishin added a commit that referenced this issue Jun 22, 2016
@camelpunch @michaelklishin camelpunch + michaelklishin Rework recovery test
- Wait for state changes on HTTP API, with timeouts. This is about 3x
  faster than the previous constant sleeps on my machine.
- Silence log output
- Pend out an example that was incorrectly passing
  (attempt limits: #408)

Issue #410
6247c42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment