Class: LogStash::Outputs::Stomp

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/stomp.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



68
69
70
71
# 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) ⇒ Object

def close



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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

#registerObject



54
55
56
57
58
59
60
61
62
63
64
65
# 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