Skip to content

Commit

Permalink
Closes #518
Browse files Browse the repository at this point in the history
Bunny::Channel#basic_get uses a separate conitnuation data structure, so
if a timeout hits any pending channel-level exceptions won't be thrown
without some extra effort.
  • Loading branch information
michaelklishin committed Sep 23, 2017
1 parent bb7d615 commit d24e601
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/bunny/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,12 @@ def basic_get(queue, opts = {:manual_ack => true})
# we implement them). So we return a triple of nils immediately which apps should be
# able to handle anyway as "got no message, no need to act". MK.
last_basic_get_response = if @connection.open?
wait_on_basic_get_continuations
begin
wait_on_basic_get_continuations
rescue Timeout::Error => e
raise_if_continuation_resulted_in_a_channel_error!
raise e
end
else
[nil, nil, nil]
end
Expand Down
24 changes: 24 additions & 0 deletions spec/higher_level_api/integration/basic_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,27 @@
end
end
end


describe Bunny::Channel, "#basic_get" do
let(:connection) do
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
automatically_recover: false, continuation_timeout: 3000)
c.start
c
end

after :each do
connection.close if connection.open?
end

context "with a non-existent queue" do
it "throws a NOT_FOUND" do
ch = connection.create_channel

expect do
ch.basic_get "non_existent_#{rand.to_s}"
end.to raise_error(Bunny::NotFound)
end
end
end

0 comments on commit d24e601

Please sign in to comment.