logstash-input-rabbitmq 3.1.3 → 3.1.4
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -3
- data/lib/logstash/inputs/rabbitmq.rb +35 -8
- data/logstash-input-rabbitmq.gemspec +1 -1
- data/spec/inputs/rabbitmq_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0507d6cfebcee1574e915e72dcde6851d4b6584d
|
4
|
+
data.tar.gz: 066a1bf95bf831b85e7bbc3badb0830477cbdd8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17958b74fcd840beba8247d5654db7b6b203ec1e7515d24dcefcab4f884aa2a57db119e79668d3a28db06bc87e35a238f1cc41e1276fac8f38ce543ba57d50fb
|
7
|
+
data.tar.gz: c13776c81987dc71144de3e91e532bf2b2f58daa03d2baf2276ce51a3cb2f66f4ba392005236c02f74ffe0c24bfc24953fd2aec3eca2f273583e3af649b0da36
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Inputs/job/logstash-plugin-input-rabbitmq-unit/)
|
3
|
+
[](https://travis-ci.org/logstash-plugins/logstash-input-rabbitmq)
|
5
4
|
|
6
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
6
|
|
@@ -86,4 +85,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
86
85
|
|
87
86
|
It is more important to the community that you are able to contribute.
|
88
87
|
|
89
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
88
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -52,6 +52,10 @@ module LogStash
|
|
52
52
|
# * Wildcards are not valid on direct exchanges.
|
53
53
|
config :key, :validate => :string, :default => "logstash"
|
54
54
|
|
55
|
+
# Amount of time in seconds to wait after a failed subscription request
|
56
|
+
# before retrying. Subscribes can fail if the server goes away and then comes back
|
57
|
+
config :subscription_retry_interval_seconds, :validate => :number, :required => true, :default => 5
|
58
|
+
|
55
59
|
def register
|
56
60
|
connect!
|
57
61
|
declare_queue!
|
@@ -93,15 +97,38 @@ module LogStash
|
|
93
97
|
def consume!
|
94
98
|
# we manually build a consumer here to be able to keep a reference to it
|
95
99
|
# in an @ivar even though we use a blocking version of HB::Queue#subscribe
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
+
|
101
|
+
# The logic here around resubscription might seem strange, but its predicated on the fact
|
102
|
+
# that we rely on MarchHare to do the reconnection for us with auto_reconnect.
|
103
|
+
# Unfortunately, while MarchHare does the reconnection work it won't re-subscribe the consumer
|
104
|
+
# hence the logic below.
|
105
|
+
loop do
|
106
|
+
begin
|
107
|
+
@consumer = @hare_info.queue.build_consumer(:block => true) do |metadata, data|
|
108
|
+
@codec.decode(data) do |event|
|
109
|
+
decorate(event)
|
110
|
+
@output_queue << event if event
|
111
|
+
end
|
112
|
+
@hare_info.channel.ack(metadata.delivery_tag) if @ack
|
113
|
+
end
|
114
|
+
|
115
|
+
if @hare_info.connection.connected?
|
116
|
+
@logger.info("Will subscribe with consumer", :config => config)
|
117
|
+
@hare_info.queue.subscribe_with(@consumer, :manual_ack => @ack, :block => true)
|
118
|
+
@logger.warn("Queue subscription ended! Will retry in #{@subscription_retry_interval_seconds}s", :config => config)
|
119
|
+
else
|
120
|
+
@logger.info("RabbitMQ connection down, will wait to retry subscription", :config => config)
|
121
|
+
end
|
122
|
+
|
123
|
+
break if stop?
|
124
|
+
@consumer.gracefully_shut_down # Try to clean up gracefully
|
125
|
+
rescue MarchHare::Exception => e
|
126
|
+
@logger.warn("Error re-subscribing to queue!", :config => config, :message => e.message, :class => e.class.name)
|
100
127
|
end
|
101
|
-
@hare_info.channel.ack(metadata.delivery_tag) if @ack
|
102
|
-
end
|
103
128
|
|
104
|
-
|
129
|
+
Stud.stoppable_sleep(@subscription_retry_interval_seconds) { stop? }
|
130
|
+
break if stop? # In case an error was hit before the break above was hit
|
131
|
+
end
|
105
132
|
end
|
106
133
|
|
107
134
|
def stop
|
@@ -117,4 +144,4 @@ module LogStash
|
|
117
144
|
|
118
145
|
end
|
119
146
|
end
|
120
|
-
end
|
147
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-rabbitmq'
|
3
|
-
s.version = '3.1.
|
3
|
+
s.version = '3.1.4'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Pull events from a RabbitMQ exchange."
|
6
6
|
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"
|
@@ -91,6 +91,20 @@ describe LogStash::Inputs::RabbitMQ do
|
|
91
91
|
expect(queue).to have_received(:bind).with(any_args).twice()
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
context "initially unable to subscribe" do
|
96
|
+
before do
|
97
|
+
i = 0
|
98
|
+
allow(queue).to receive(:subscribe_with).with(any_args) do
|
99
|
+
i += 1
|
100
|
+
raise "sub error" if i == 1
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should retry the subscribe" do
|
104
|
+
expect(queue).to have_receive(:subscribe_with).twice()
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
94
108
|
end
|
95
109
|
end
|
96
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-rabbitmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|