Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

Consumer shutdown signal exception #46

Merged
merged 3 commits into from
Feb 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/non_rails_app/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../../
specs:
rabbit_feed (2.4.1)
rabbit_feed (2.4.2)
activemodel (>= 3.2.0, < 5.0.0)
activesupport (>= 3.2.0, < 5.0.0)
avro (>= 1.5.4, < 1.8.0)
Expand Down
2 changes: 1 addition & 1 deletion example/rails_app/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../../
specs:
rabbit_feed (2.4.1)
rabbit_feed (2.4.2)
activemodel (>= 3.2.0, < 5.0.0)
activesupport (>= 3.2.0, < 5.0.0)
avro (>= 1.5.4, < 1.8.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/rabbit_feed/consumer_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def consume &block
end

sleep # Sleep indefinitely, as the consumer runs in its own thread
rescue SystemExit, Interrupt
rescue SystemExit, Interrupt, SignalException
RabbitFeed.log.info {{ event: :unsubscribe_from_queue, queue: RabbitFeed.configuration.queue }}
ensure
(cancel_consumer consumer) if consumer.present?
Expand Down
2 changes: 1 addition & 1 deletion lib/rabbit_feed/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RabbitFeed
VERSION = '2.4.1'
VERSION = '2.4.2'
end
28 changes: 28 additions & 0 deletions spec/lib/rabbit_feed/consumer_connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,34 @@ module RabbitFeed

context 'when an exception is raised' do

context 'when the exception is' do
[SystemExit.new, Interrupt.new, SignalException.new('SIGTERM')].each do |exception|
context exception.to_s do
let!(:logger) do
test_logger_string_io = StringIO.new
logger = Logger.new test_logger_string_io
logger.formatter = RabbitFeed::JsonLogFormatter
old_logger = RabbitFeed.log
RabbitFeed.log = logger
test_logger_string_io
end

before { allow(subject).to receive(:handle_message).and_raise(exception) }

it 'does not re-raise error' do
expect { subject.consume { } }.to_not raise_error
end

it 'logs unsubscribe_from_queue' do
subject.consume { }

expect(logger.string).to match /unsubscribe_from_queue/
end

end
end
end

context 'when consumer_exit_after_fail is true' do
before { allow(RabbitFeed.configuration).to receive(:consumer_exit_after_fail).and_return(true) }

Expand Down