class LogStash::Outputs::Stomp
Public Instance Methods
close()
click to toggle source
# File lib/logstash/outputs/stomp.rb, line 68 def close @logger.warn("Disconnecting from stomp broker") @client.disconnect if @client.connected? end
multi_receive(events)
click to toggle source
# File lib/logstash/outputs/stomp.rb, line 73 def multi_receive(events) @logger.debug("stomp sending events in batch", { :host => @host, :events => events.length }) @client.transaction do |t| events.each { |event| headers = Hash.new if @headers @headers.each do |k,v| headers[k] = event.sprintf(v) end end t.send(event.sprintf(@destination), event.to_json, headers) } end end
register()
click to toggle source
# File lib/logstash/outputs/stomp.rb, line 54 def register require "onstomp" @client = OnStomp::Client.new("stomp://#{@host}:#{@port}", :login => @user, :passcode => @password.value) @client.host = @vhost if @vhost # Handle disconnects @client.on_connection_closed { connect } connect end
Private Instance Methods
connect()
click to toggle source
# File lib/logstash/outputs/stomp.rb, line 40 def connect begin @client.connect @logger.debug("Connected to stomp server") if @client.connected? rescue => e @logger.debug("Failed to connect to stomp server, will retry", :exception => e, :backtrace => e.backtrace) sleep 2 retry end end