Skip to content

Commit

Permalink
Disconnect on 'close'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewvc committed Sep 17, 2015
1 parent 1a42252 commit d8feb79
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/logstash/outputs/rabbitmq.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "logstash/devutils/rspec/spec_helper"
require "logstash/pipeline"
require "logstash/plugin_mixins/rabbitmq_connection/common"
require "logstash/plugin_mixins/rabbitmq_connection"

module LogStash
module Outputs
class RabbitMQ < LogStash::Outputs::Base
include LogStash::PluginMixins::RabbitMQConnection::Common
include LogStash::PluginMixins::RabbitMQConnection

# Key to route to by default. Defaults to 'logstash'
#
Expand Down Expand Up @@ -34,8 +34,6 @@ def publish(event, message)
raise ArgumentError, "No exchange set in HareInfo!!!" unless @hare_info.exchange
@hare_info.exchange.publish(message, :routing_key => event.sprintf(@key), :properties => { :persistent => @persistent })
rescue MarchHare::Exception, IOError, com.rabbitmq.client.AlreadyClosedException => e
return if terminating?

@logger.error("Error while publishing. Will retry.",
:message => e.message,
:exception => e.class,
Expand All @@ -44,6 +42,11 @@ def publish(event, message)
sleep_for_retry
retry
end

def stop
super
close_connection
end
end
end
end

0 comments on commit d8feb79

Please sign in to comment.