logstash-output-rabbitmq 1.0.0-java → 1.0.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 +4 -4
- data/CHANGELOG.md +2 -0
- data/lib/logstash/outputs/rabbitmq/march_hare.rb +20 -18
- data/logstash-output-rabbitmq.gemspec +1 -1
- data/spec/outputs/rabbitmq_spec.rb +60 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 196e13c70544a6e6b7429647f627d2909ca4b5df
|
4
|
+
data.tar.gz: 3e6871d57fdcb9afde9a531058728e0f57b252f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28810116ec622545494f279bb88107edf73e74d8f9886f533a8cf51c2e42dd096255ebcffbbefd8ae97b64031a024c6279128923280a53f5ad31e0b6c3fec87b
|
7
|
+
data.tar.gz: 4088c7f9ebdf63d9458effc176127df3c4fa3a8cd9acb6299d3e60ac47c4efb71f58935be1d49db8a341673bba6e29c5768f284e3a69871551b8938cd9ed4d62
|
data/CHANGELOG.md
CHANGED
@@ -35,26 +35,28 @@ class LogStash::Outputs::RabbitMQ
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def publish_serialized(event, message)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
@logger.warn("Tried to send a message, but not connected to RabbitMQ.")
|
43
|
-
end
|
44
|
-
rescue MarchHare::Exception, IOError, com.rabbitmq.client.AlreadyClosedException => e
|
45
|
-
@connected.set(false)
|
46
|
-
n = 10
|
38
|
+
attempt_publish_serialized(event, message)
|
39
|
+
rescue MarchHare::Exception, IOError, com.rabbitmq.client.AlreadyClosedException => e
|
40
|
+
@connected.set(false)
|
41
|
+
n = 10
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
@logger.error("RabbitMQ connection error: #{e.message}. Will attempt to reconnect in #{n} seconds...",
|
44
|
+
:exception => e,
|
45
|
+
:backtrace => e.backtrace)
|
46
|
+
return if terminating?
|
52
47
|
|
53
|
-
|
48
|
+
sleep n
|
54
49
|
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
connect
|
51
|
+
@x = declare_exchange
|
52
|
+
retry
|
53
|
+
end
|
54
|
+
|
55
|
+
def attempt_publish_serialized(event, message)
|
56
|
+
if @connected.get
|
57
|
+
@x.publish(message, :routing_key => event.sprintf(@key), :properties => { :persistent => @persistent })
|
58
|
+
else
|
59
|
+
@logger.warn("Tried to send a message, but not connected to RabbitMQ.")
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
@@ -105,7 +107,7 @@ class LogStash::Outputs::RabbitMQ
|
|
105
107
|
@connection_url = "#{proto}://#{@user}@#{@host}:#{@port}#{vhost}/#{@queue}"
|
106
108
|
|
107
109
|
begin
|
108
|
-
@conn = MarchHare.connect(@settings)
|
110
|
+
@conn = MarchHare.connect(@settings) unless @conn && @conn.open?
|
109
111
|
|
110
112
|
@logger.debug("Connecting to RabbitMQ. Settings: #{@settings.inspect}, queue: #{@queue.inspect}")
|
111
113
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-rabbitmq'
|
4
|
-
s.version = '1.0.
|
4
|
+
s.version = '1.0.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Push events to a RabbitMQ exchange"
|
7
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"
|
@@ -69,4 +69,64 @@ describe LogStash::Outputs::RabbitMQ do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
end
|
72
|
+
|
73
|
+
# TODO: Redo all this
|
74
|
+
# This is a crazy test to fix an urgent bug. It tests that we actually to change the
|
75
|
+
# store exchange value when an exception happens
|
76
|
+
# This should be a small number of lines, but until we refactor we must jump through hoops
|
77
|
+
# to put the plugin in the proper state and extract the proper state to test
|
78
|
+
describe "retrying a publish" do
|
79
|
+
let(:settings) {
|
80
|
+
{
|
81
|
+
"host" => "localhost",
|
82
|
+
"exchange_type" => "topic",
|
83
|
+
"exchange" => "foo",
|
84
|
+
"key" => "%{foo}"
|
85
|
+
}
|
86
|
+
}
|
87
|
+
let(:event) { LogStash::Event.new("foo" => "bar")}
|
88
|
+
|
89
|
+
subject { LogStash::Outputs::RabbitMQ.new(settings) }
|
90
|
+
|
91
|
+
before do
|
92
|
+
allow(subject).to receive(:connect) {
|
93
|
+
subject.instance_variable_get(:@connected).set(true)
|
94
|
+
}
|
95
|
+
|
96
|
+
exchange_invocation = 0
|
97
|
+
|
98
|
+
@most_recent_exchange = nil
|
99
|
+
|
100
|
+
allow(subject).to receive(:declare_exchange) do
|
101
|
+
exchange_invocation += 1
|
102
|
+
@most_recent_exchange = double("exchange #{exchange_invocation}")
|
103
|
+
end
|
104
|
+
|
105
|
+
subject.register
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when the connection aborts once" do
|
109
|
+
before do
|
110
|
+
i = 0
|
111
|
+
allow(subject).to receive(:attempt_publish_serialized) do
|
112
|
+
i+=1
|
113
|
+
if i == 1 # Raise an exception once
|
114
|
+
raise MarchHare::Exception, "First"
|
115
|
+
else
|
116
|
+
"nope"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
subject.publish_serialized(event, "hello")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should re-declare the exchange" do
|
124
|
+
expect(subject).to have_received(:declare_exchange).twice
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should set the exchange to the second double" do
|
128
|
+
expect(subject.instance_variable_get(:@x)).to eql(@most_recent_exchange)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
72
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-rabbitmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.1.9
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Push events to a RabbitMQ exchange
|