logstash-output-rabbitmq 0.1.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +3 -0
- data/LICENSE +13 -0
- data/Rakefile +7 -0
- data/lib/logstash/outputs/rabbitmq.rb +96 -0
- data/lib/logstash/outputs/rabbitmq/bunny.rb +138 -0
- data/lib/logstash/outputs/rabbitmq/hot_bunnies.rb +1 -0
- data/lib/logstash/outputs/rabbitmq/march_hare.rb +143 -0
- data/logstash-output-rabbitmq.gemspec +34 -0
- data/spec/outputs/rabbitmq_spec.rb +1 -0
- metadata +104 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 3d077636bc3938cec6ff586816627df8672759bc
         | 
| 4 | 
            +
              data.tar.gz: 0e17b4216d83ef4478357cdc390ae930d2ab8b51
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: ad4a194dbab8de29976d76b7c8c509941382b28693ef825a86fbedfbe4fb852094ba5be40ae16590f9472d62eea9fde908080946504a43d125cab2bd7c95ae27
         | 
| 7 | 
            +
              data.tar.gz: 9213a4f73ae57cd8e80899a51cc6ab0140f872c8ee0e642c29e3b4004b1d5cc95dc368b850fd8b1b3865c1508ccdf81eeb35f82390ad2c5cda82ddbd577baaa6
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            +
            you may not use this file except in compliance with the License.
         | 
| 5 | 
            +
            You may obtain a copy of the License at
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            +
            distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            +
            WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            +
            See the License for the specific language governing permissions and
         | 
| 13 | 
            +
            limitations under the License.
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1,96 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            require "logstash/outputs/base"
         | 
| 3 | 
            +
            require "logstash/namespace"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Push events to a RabbitMQ exchange. Requires RabbitMQ 2.x
         | 
| 6 | 
            +
            # or later version (3.x is recommended).
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            # Relevant links:
         | 
| 9 | 
            +
            #
         | 
| 10 | 
            +
            # * http://www.rabbitmq.com/[RabbitMQ]
         | 
| 11 | 
            +
            # * http://rubymarchhare.info[March Hare]
         | 
| 12 | 
            +
            # * http://rubybunny.info[Bunny]
         | 
| 13 | 
            +
            class LogStash::Outputs::RabbitMQ < LogStash::Outputs::Base
         | 
| 14 | 
            +
              EXCHANGE_TYPES = ["fanout", "direct", "topic"]
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              config_name "rabbitmq"
         | 
| 17 | 
            +
              milestone 1
         | 
| 18 | 
            +
             | 
| 19 | 
            +
             | 
| 20 | 
            +
              #
         | 
| 21 | 
            +
              # Connection
         | 
| 22 | 
            +
              #
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              # RabbitMQ server address
         | 
| 25 | 
            +
              config :host, :validate => :string, :required => true
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              # RabbitMQ port to connect on
         | 
| 28 | 
            +
              config :port, :validate => :number, :default => 5672
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              # RabbitMQ username
         | 
| 31 | 
            +
              config :user, :validate => :string, :default => "guest"
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              # RabbitMQ password
         | 
| 34 | 
            +
              config :password, :validate => :password, :default => "guest"
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              # The vhost to use. If you don't know what this is, leave the default.
         | 
| 37 | 
            +
              config :vhost, :validate => :string, :default => "/"
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              # Enable or disable SSL
         | 
| 40 | 
            +
              config :ssl, :validate => :boolean, :default => false
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              # Validate SSL certificate
         | 
| 43 | 
            +
              config :verify_ssl, :validate => :boolean, :default => false
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              # Enable or disable logging
         | 
| 46 | 
            +
              config :debug, :validate => :boolean, :default => false, :deprecated => "Use the logstash --debug flag for this instead."
         | 
| 47 | 
            +
             | 
| 48 | 
            +
             | 
| 49 | 
            +
             | 
| 50 | 
            +
              #
         | 
| 51 | 
            +
              # Exchange
         | 
| 52 | 
            +
              #
         | 
| 53 | 
            +
             | 
| 54 | 
            +
             | 
| 55 | 
            +
              # The exchange type (fanout, topic, direct)
         | 
| 56 | 
            +
              config :exchange_type, :validate => EXCHANGE_TYPES, :required => true
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              # The name of the exchange
         | 
| 59 | 
            +
              config :exchange, :validate => :string, :required => true
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              # Key to route to by default. Defaults to 'logstash'
         | 
| 62 | 
            +
              #
         | 
| 63 | 
            +
              # * Routing keys are ignored on fanout exchanges.
         | 
| 64 | 
            +
              config :key, :validate => :string, :default => "logstash"
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              # Is this exchange durable? (aka; Should it survive a broker restart?)
         | 
| 67 | 
            +
              config :durable, :validate => :boolean, :default => true
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              # Should RabbitMQ persist messages to disk?
         | 
| 70 | 
            +
              config :persistent, :validate => :boolean, :default => true
         | 
| 71 | 
            +
             | 
| 72 | 
            +
             | 
| 73 | 
            +
             | 
| 74 | 
            +
              def initialize(params)
         | 
| 75 | 
            +
                params["codec"] = "json" if !params["codec"]
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                super
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              # Use MarchHare on JRuby to avoid IO#select CPU spikes
         | 
| 81 | 
            +
              # (see github.com/ruby-amqp/bunny/issues/95).
         | 
| 82 | 
            +
              #
         | 
| 83 | 
            +
              # On MRI, use Bunny.
         | 
| 84 | 
            +
              #
         | 
| 85 | 
            +
              # See http://rubybunny.info and http://rubymarchhare.info
         | 
| 86 | 
            +
              # for the docs.
         | 
| 87 | 
            +
              if RUBY_ENGINE == "jruby"
         | 
| 88 | 
            +
                require "logstash/outputs/rabbitmq/march_hare"
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                include MarchHareImpl
         | 
| 91 | 
            +
              else
         | 
| 92 | 
            +
                require "logstash/outputs/rabbitmq/bunny"
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                include BunnyImpl
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
            end # class LogStash::Outputs::RabbitMQ
         | 
| @@ -0,0 +1,138 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "logstash/json"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class LogStash::Outputs::RabbitMQ
         | 
| 6 | 
            +
              module BunnyImpl
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                #
         | 
| 9 | 
            +
                # API
         | 
| 10 | 
            +
                #
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def register
         | 
| 13 | 
            +
                  require "bunny"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  @logger.info("Registering output", :plugin => self)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  connect
         | 
| 18 | 
            +
                  declare_exchange
         | 
| 19 | 
            +
                end # def register
         | 
| 20 | 
            +
             | 
| 21 | 
            +
             | 
| 22 | 
            +
                def receive(event)
         | 
| 23 | 
            +
                  return unless output?(event)
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  @logger.debug("Sending event", :destination => to_s, :event => event, :key => key)
         | 
| 26 | 
            +
                  key = event.sprintf(@key) if @key
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  begin
         | 
| 29 | 
            +
                    publish_serialized(event.to_json, key)
         | 
| 30 | 
            +
                  rescue LogStash::Json::GeneratorError => e
         | 
| 31 | 
            +
                    @logger.warn("Trouble converting event to JSON", :exception => e,
         | 
| 32 | 
            +
                                 :event => event)
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def publish_serialized(message, key = @key)
         | 
| 37 | 
            +
                  begin
         | 
| 38 | 
            +
                    if @x
         | 
| 39 | 
            +
                      @x.publish(message, :persistent => @persistent, :routing_key => key)
         | 
| 40 | 
            +
                    else
         | 
| 41 | 
            +
                      @logger.warn("Tried to send a message, but not connected to RabbitMQ yet.")
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                  rescue Bunny::NetworkFailure, Bunny::ConnectionClosedError, Bunny::ConnectionLevelException, Bunny::TCPConnectionFailed => e
         | 
| 44 | 
            +
                    n = Bunny::Session::DEFAULT_NETWORK_RECOVERY_INTERVAL * 2
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    @logger.error("RabbitMQ connection error: #{e.message}. Will attempt to reconnect in #{n} seconds...",
         | 
| 47 | 
            +
                                  :exception => e,
         | 
| 48 | 
            +
                                  :backtrace => e.backtrace)
         | 
| 49 | 
            +
                    return if terminating?
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    sleep n
         | 
| 52 | 
            +
                    connect
         | 
| 53 | 
            +
                    declare_exchange
         | 
| 54 | 
            +
                    retry
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                def to_s
         | 
| 59 | 
            +
                  return "amqp://#{@user}@#{@host}:#{@port}#{@vhost}/#{@exchange_type}/#{@exchange}\##{@key}"
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                def teardown
         | 
| 63 | 
            +
                  @conn.close if @conn && @conn.open?
         | 
| 64 | 
            +
                  @conn = nil
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  finished
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
             | 
| 70 | 
            +
             | 
| 71 | 
            +
                #
         | 
| 72 | 
            +
                # Implementation
         | 
| 73 | 
            +
                #
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                def connect
         | 
| 76 | 
            +
                  @vhost       ||= Bunny::DEFAULT_HOST
         | 
| 77 | 
            +
                  # 5672. Will be switched to 5671 by Bunny if TLS is enabled.
         | 
| 78 | 
            +
                  @port        ||= AMQ::Protocol::DEFAULT_PORT
         | 
| 79 | 
            +
                  @routing_key ||= "#"
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  @settings = {
         | 
| 82 | 
            +
                    :vhost => @vhost,
         | 
| 83 | 
            +
                    :host  => @host,
         | 
| 84 | 
            +
                    :port  => @port,
         | 
| 85 | 
            +
                    :automatically_recover => false
         | 
| 86 | 
            +
                  }
         | 
| 87 | 
            +
                  @settings[:user]      = @user || Bunny::DEFAULT_USER
         | 
| 88 | 
            +
                  @settings[:pass]      = if @password
         | 
| 89 | 
            +
                                            @password.value
         | 
| 90 | 
            +
                                          else
         | 
| 91 | 
            +
                                            Bunny::DEFAULT_PASSWORD
         | 
| 92 | 
            +
                                          end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  @settings[:log_level] = if @debug || @logger.debug?
         | 
| 95 | 
            +
                                            :debug
         | 
| 96 | 
            +
                                          else
         | 
| 97 | 
            +
                                            :error
         | 
| 98 | 
            +
                                          end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  @settings[:tls]        = @ssl if @ssl
         | 
| 101 | 
            +
                  @settings[:verify_ssl] = @verify_ssl if @verify_ssl
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  proto                  = if @ssl
         | 
| 104 | 
            +
                                             "amqp"
         | 
| 105 | 
            +
                                           else
         | 
| 106 | 
            +
                                             "amqps"
         | 
| 107 | 
            +
                                           end
         | 
| 108 | 
            +
                  @connection_url        = "#{proto}://#{@user}@#{@host}:#{@port}#{vhost}/#{@queue}"
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                  begin
         | 
| 111 | 
            +
                    @conn = Bunny.new(@settings)
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    @logger.debug("Connecting to RabbitMQ. Settings: #{@settings.inspect}, queue: #{@queue.inspect}")
         | 
| 114 | 
            +
                    return if terminating?
         | 
| 115 | 
            +
                    @conn.start
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                    @ch = @conn.create_channel
         | 
| 118 | 
            +
                    @logger.info("Connected to RabbitMQ at #{@settings[:host]}")
         | 
| 119 | 
            +
                  rescue Bunny::NetworkFailure, Bunny::ConnectionClosedError, Bunny::ConnectionLevelException, Bunny::TCPConnectionFailed => e
         | 
| 120 | 
            +
                    n = Bunny::Session::DEFAULT_NETWORK_RECOVERY_INTERVAL * 2
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                    @logger.error("RabbitMQ connection error: #{e.message}. Will attempt to reconnect in #{n} seconds...",
         | 
| 123 | 
            +
                                  :exception => e,
         | 
| 124 | 
            +
                                  :backtrace => e.backtrace)
         | 
| 125 | 
            +
                    return if terminating?
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    sleep n
         | 
| 128 | 
            +
                    retry
         | 
| 129 | 
            +
                  end
         | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                def declare_exchange
         | 
| 133 | 
            +
                  @logger.debug("Declaring an exchange", :name => @exchange, :type => @exchange_type,
         | 
| 134 | 
            +
                                :durable => @durable)
         | 
| 135 | 
            +
                  @x = @ch.exchange(@exchange, :type => @exchange_type.to_sym, :durable => @durable)
         | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
              end # BunnyImpl
         | 
| 138 | 
            +
            end # LogStash::Outputs::RabbitMQ
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "logstash/outputs/rabbitmq/march_hare"
         | 
| @@ -0,0 +1,143 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            class LogStash::Outputs::RabbitMQ
         | 
| 3 | 
            +
              module MarchHareImpl
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # API
         | 
| 8 | 
            +
                #
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def register
         | 
| 11 | 
            +
                  require "march_hare"
         | 
| 12 | 
            +
                  require "java"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  @logger.info("Registering output", :plugin => self)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  @connected = java.util.concurrent.atomic.AtomicBoolean.new
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  connect
         | 
| 19 | 
            +
                  declare_exchange
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  @connected.set(true)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  @codec.on_event(&method(:publish_serialized))
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
                def receive(event)
         | 
| 28 | 
            +
                  return unless output?(event)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  begin
         | 
| 31 | 
            +
                    @codec.encode(event)
         | 
| 32 | 
            +
                  rescue JSON::GeneratorError => e
         | 
| 33 | 
            +
                    @logger.warn("Trouble converting event to JSON", :exception => e,
         | 
| 34 | 
            +
                                 :event => event)
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                def publish_serialized(message)
         | 
| 39 | 
            +
                  begin
         | 
| 40 | 
            +
                    if @connected.get
         | 
| 41 | 
            +
                      @x.publish(message, :routing_key => @key, :properties => {
         | 
| 42 | 
            +
                        :persistent => @persistent
         | 
| 43 | 
            +
                      })
         | 
| 44 | 
            +
                    else
         | 
| 45 | 
            +
                      @logger.warn("Tried to send a message, but not connected to RabbitMQ.")
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                  rescue MarchHare::Exception, IOError, com.rabbitmq.client.AlreadyClosedException => e
         | 
| 48 | 
            +
                    @connected.set(false)
         | 
| 49 | 
            +
                    n = 10
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    @logger.error("RabbitMQ connection error: #{e.message}. Will attempt to reconnect in #{n} seconds...",
         | 
| 52 | 
            +
                                  :exception => e,
         | 
| 53 | 
            +
                                  :backtrace => e.backtrace)
         | 
| 54 | 
            +
                    return if terminating?
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                    sleep n
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    connect
         | 
| 59 | 
            +
                    declare_exchange
         | 
| 60 | 
            +
                    retry
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                def to_s
         | 
| 65 | 
            +
                  return "amqp://#{@user}@#{@host}:#{@port}#{@vhost}/#{@exchange_type}/#{@exchange}\##{@key}"
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def teardown
         | 
| 69 | 
            +
                  @connected.set(false)
         | 
| 70 | 
            +
                  @conn.close if @conn && @conn.open?
         | 
| 71 | 
            +
                  @conn = nil
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  finished
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
             | 
| 77 | 
            +
             | 
| 78 | 
            +
                #
         | 
| 79 | 
            +
                # Implementation
         | 
| 80 | 
            +
                #
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def connect
         | 
| 83 | 
            +
                  return if terminating?
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  @vhost       ||= "127.0.0.1"
         | 
| 86 | 
            +
                  # 5672. Will be switched to 5671 by Bunny if TLS is enabled.
         | 
| 87 | 
            +
                  @port        ||= 5672
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                  @settings = {
         | 
| 90 | 
            +
                    :vhost => @vhost,
         | 
| 91 | 
            +
                    :host  => @host,
         | 
| 92 | 
            +
                    :port  => @port,
         | 
| 93 | 
            +
                    :user  => @user,
         | 
| 94 | 
            +
                    :automatic_recovery => false
         | 
| 95 | 
            +
                  }
         | 
| 96 | 
            +
                  @settings[:pass]      = if @password
         | 
| 97 | 
            +
                                            @password.value
         | 
| 98 | 
            +
                                          else
         | 
| 99 | 
            +
                                            "guest"
         | 
| 100 | 
            +
                                          end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  @settings[:tls]        = @ssl if @ssl
         | 
| 103 | 
            +
                  proto                  = if @ssl
         | 
| 104 | 
            +
                                             "amqp"
         | 
| 105 | 
            +
                                           else
         | 
| 106 | 
            +
                                             "amqps"
         | 
| 107 | 
            +
                                           end
         | 
| 108 | 
            +
                  @connection_url        = "#{proto}://#{@user}@#{@host}:#{@port}#{vhost}/#{@queue}"
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                  begin
         | 
| 111 | 
            +
                    @conn = MarchHare.connect(@settings)
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    @logger.debug("Connecting to RabbitMQ. Settings: #{@settings.inspect}, queue: #{@queue.inspect}")
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                    @ch = @conn.create_channel
         | 
| 116 | 
            +
                    @logger.info("Connected to RabbitMQ at #{@settings[:host]}")
         | 
| 117 | 
            +
                  rescue MarchHare::Exception => e
         | 
| 118 | 
            +
                    @connected.set(false)
         | 
| 119 | 
            +
                    n = 10
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                    @logger.error("RabbitMQ connection error: #{e.message}. Will attempt to reconnect in #{n} seconds...",
         | 
| 122 | 
            +
                                  :exception => e,
         | 
| 123 | 
            +
                                  :backtrace => e.backtrace)
         | 
| 124 | 
            +
                    return if terminating?
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                    sleep n
         | 
| 127 | 
            +
                    retry
         | 
| 128 | 
            +
                  end
         | 
| 129 | 
            +
                end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                def declare_exchange
         | 
| 132 | 
            +
                  @logger.debug("Declaring an exchange", :name => @exchange, :type => @exchange_type,
         | 
| 133 | 
            +
                                :durable => @durable)
         | 
| 134 | 
            +
                  @x = @ch.exchange(@exchange, :type => @exchange_type.to_sym, :durable => @durable)
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                  # sets @connected to true during recovery. MK.
         | 
| 137 | 
            +
                  @connected.set(true)
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                  @x
         | 
| 140 | 
            +
                end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
              end # MarchHareImpl
         | 
| 143 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            Gem::Specification.new do |s|
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              s.name            = 'logstash-output-rabbitmq'
         | 
| 4 | 
            +
              s.version         = '0.1.1'
         | 
| 5 | 
            +
              s.licenses        = ['Apache License (2.0)']
         | 
| 6 | 
            +
              s.summary         = "Push events to a RabbitMQ exchange"
         | 
| 7 | 
            +
              s.description     = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
         | 
| 8 | 
            +
              s.authors         = ["Elasticsearch"]
         | 
| 9 | 
            +
              s.email           = 'info@elasticsearch.com'
         | 
| 10 | 
            +
              s.homepage        = "http://www.elasticsearch.org/guide/en/logstash/current/index.html"
         | 
| 11 | 
            +
              s.require_paths = ["lib"]
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              # Files
         | 
| 14 | 
            +
              s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # Tests
         | 
| 17 | 
            +
              s.test_files = s.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              # Special flag to let us know this is actually a logstash plugin
         | 
| 20 | 
            +
              s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              # Gem dependencies
         | 
| 23 | 
            +
              s.add_runtime_dependency 'logstash', '>= 1.4.0', '< 2.0.0'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              if RUBY_PLATFORM == 'java'
         | 
| 26 | 
            +
                s.platform = RUBY_PLATFORM
         | 
| 27 | 
            +
                s.add_runtime_dependency 'march_hare', ['~> 2.5.1'] #(MIT license)
         | 
| 28 | 
            +
              else
         | 
| 29 | 
            +
                s.add_runtime_dependency 'bunny', ['>= 1.6.0'] #(MIT license)
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              s.add_development_dependency 'logstash-devutils'
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "logstash/devutils/rspec/spec_helper"
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: logstash-output-rabbitmq
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 | 
            +
            platform: java
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Elasticsearch
         | 
| 8 | 
            +
            autorequire:
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-11-19 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 15 | 
            +
                requirements:
         | 
| 16 | 
            +
                - - '>='
         | 
| 17 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 18 | 
            +
                    version: 1.4.0
         | 
| 19 | 
            +
                - - <
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: 2.0.0
         | 
| 22 | 
            +
              name: logstash
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              type: :runtime
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 1.4.0
         | 
| 30 | 
            +
                - - <
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 2.0.0
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 35 | 
            +
                requirements:
         | 
| 36 | 
            +
                - - ~>
         | 
| 37 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 38 | 
            +
                    version: 2.5.1
         | 
| 39 | 
            +
              name: march_hare
         | 
| 40 | 
            +
              prerelease: false
         | 
| 41 | 
            +
              type: :runtime
         | 
| 42 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - ~>
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: 2.5.1
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                requirements:
         | 
| 50 | 
            +
                - - '>='
         | 
| 51 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            +
                    version: '0'
         | 
| 53 | 
            +
              name: logstash-devutils
         | 
| 54 | 
            +
              prerelease: false
         | 
| 55 | 
            +
              type: :development
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - '>='
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '0'
         | 
| 61 | 
            +
            description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
         | 
| 62 | 
            +
            email: info@elasticsearch.com
         | 
| 63 | 
            +
            executables: []
         | 
| 64 | 
            +
            extensions: []
         | 
| 65 | 
            +
            extra_rdoc_files: []
         | 
| 66 | 
            +
            files:
         | 
| 67 | 
            +
            - .gitignore
         | 
| 68 | 
            +
            - Gemfile
         | 
| 69 | 
            +
            - LICENSE
         | 
| 70 | 
            +
            - Rakefile
         | 
| 71 | 
            +
            - lib/logstash/outputs/rabbitmq.rb
         | 
| 72 | 
            +
            - lib/logstash/outputs/rabbitmq/bunny.rb
         | 
| 73 | 
            +
            - lib/logstash/outputs/rabbitmq/hot_bunnies.rb
         | 
| 74 | 
            +
            - lib/logstash/outputs/rabbitmq/march_hare.rb
         | 
| 75 | 
            +
            - logstash-output-rabbitmq.gemspec
         | 
| 76 | 
            +
            - spec/outputs/rabbitmq_spec.rb
         | 
| 77 | 
            +
            homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
         | 
| 78 | 
            +
            licenses:
         | 
| 79 | 
            +
            - Apache License (2.0)
         | 
| 80 | 
            +
            metadata:
         | 
| 81 | 
            +
              logstash_plugin: 'true'
         | 
| 82 | 
            +
              logstash_group: output
         | 
| 83 | 
            +
            post_install_message:
         | 
| 84 | 
            +
            rdoc_options: []
         | 
| 85 | 
            +
            require_paths:
         | 
| 86 | 
            +
            - lib
         | 
| 87 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 88 | 
            +
              requirements:
         | 
| 89 | 
            +
              - - '>='
         | 
| 90 | 
            +
                - !ruby/object:Gem::Version
         | 
| 91 | 
            +
                  version: '0'
         | 
| 92 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
              requirements:
         | 
| 94 | 
            +
              - - '>='
         | 
| 95 | 
            +
                - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                  version: '0'
         | 
| 97 | 
            +
            requirements: []
         | 
| 98 | 
            +
            rubyforge_project:
         | 
| 99 | 
            +
            rubygems_version: 2.1.9
         | 
| 100 | 
            +
            signing_key:
         | 
| 101 | 
            +
            specification_version: 4
         | 
| 102 | 
            +
            summary: Push events to a RabbitMQ exchange
         | 
| 103 | 
            +
            test_files:
         | 
| 104 | 
            +
            - spec/outputs/rabbitmq_spec.rb
         |