-
Notifications
You must be signed in to change notification settings - Fork 31
Fix for NoMethodError: undefined method `emit' for nil:NilClass error… #45
base: master
Are you sure you want to change the base?
Conversation
…s with bunny 2.6.4 when exiting fluentd
lib/fluent/plugin/in_amqp.rb
Outdated
router.emit(parse_tag(delivery, meta), parse_time(meta), payload) | ||
unless router.nil? | ||
router.emit(parse_tag(delivery, meta), parse_time(meta), payload) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end at 84, 8 is not aligned with unless at 82, 1.
lib/fluent/plugin/in_amqp.rb
Outdated
@@ -79,7 +79,9 @@ def start | |||
q.subscribe do |delivery, meta, msg| | |||
log.debug "Recieved message #{@msg}" | |||
payload = parse_payload(msg) | |||
router.emit(parse_tag(delivery, meta), parse_time(meta), payload) | |||
unless router.nil? | |||
router.emit(parse_tag(delivery, meta), parse_time(meta), payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 (not 9) spaces for indentation.
lib/fluent/plugin/in_amqp.rb
Outdated
@@ -79,7 +79,9 @@ def start | |||
q.subscribe do |delivery, meta, msg| | |||
log.debug "Recieved message #{@msg}" | |||
payload = parse_payload(msg) | |||
router.emit(parse_tag(delivery, meta), parse_time(meta), payload) | |||
unless router.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tab detected.
Inconsistent indentation detected.
Use safe navigation (&.) instead of checking if an object exists before calling the method.
Should we perhaps unsubscribe explicitly in the shutdown method so that the block is terminated cleanly. Or at least return before parsing the payload to save CPU cycles? Do you always see this error ? |
I'm concerned that this implementation will result in message loss during shutdown as the message will have been consumed off the broker, and as we dont use ack'd message handling if the router.nil? is fired it'd silently drop the event (andperhaps others if there are other circumstances where router is nil... Perhaps shutting down the broker connection before the router can become nil, or implementing a brief nack/ack handler for the router.emit might be solve that? |
Fix for NoMethodError: undefined method `emit' for nil:NilClass errors with bunny 2.6.4 when exiting fluentd