logstash-output-rabbitmq 5.0.3-java → 5.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c097811756fa78460301fbdad94c779c3a6b65778b55555e738f230b1b8e6998
4
- data.tar.gz: cd67152827ef4762d92b7734bba053868781322df3654a8dc61309e5b25817ac
3
+ metadata.gz: 803d787d5f5a3fddb6c4d96d06fce0c293f413ae75cbfe2020b16943d754c3ee
4
+ data.tar.gz: b6e8410d0bc521f557304be2f2d55053fc2dc5b385c9341e604870822ba8b5bf
5
5
  SHA512:
6
- metadata.gz: 785e5f832d33b7bcabc3ad74d1326af12ab8ce5cd2e670e39f0aa9e868d8b2eb3facdff39169eced37fc4ae11828aca1dfe758d8652540ba38f17c00b9cef4b8
7
- data.tar.gz: 38900f94b2b77f312c3ee92feda4707396ee4843235b05b2b918002906fc4f9329f74dab3bd7447b400349bf70eb002b09ac351a49db7dcf33c027ed0647abb8
6
+ metadata.gz: c2aacec385fd40029381cf15ee2e0afbfd2eb0c2e9cfac5b7ab385341a70708c0c45a01a6f02df7ed133e93c15603d1edb3d5c24431eb4031a428e32e84ec36c
7
+ data.tar.gz: b52cf1d8e1adb9dae4827d2e175703c7b90bc6ad6f9cdb3b81a3344948a6d9ef34b5802d84b866646f3628747cdf328b2113215e1394d45f7894aaa8efae2109
@@ -1,3 +1,6 @@
1
+ ## 5.1.0
2
+ _ Use shared concurrency / multiple channels for performance
3
+
1
4
  ## 5.0.3
2
5
  - Update gemspec summary
3
6
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
1
+ Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@ module LogStash
17
17
  include LogStash::PluginMixins::RabbitMQConnection
18
18
 
19
19
  config_name "rabbitmq"
20
+
21
+ concurrency :shared
20
22
 
21
23
  # The default codec for this plugin is JSON. You can override this to suit your particular needs however.
22
24
  default :codec, "json"
@@ -44,22 +46,24 @@ module LogStash
44
46
  def register
45
47
  connect!
46
48
  @hare_info.exchange = declare_exchange!(@hare_info.channel, @exchange, @exchange_type, @durable)
47
- @codec.on_event(&method(:publish))
49
+ # The connection close should close all channels, so it is safe to store thread locals here without closing them
50
+ @thread_local_channel = java.lang.ThreadLocal.new
51
+ @thread_local_exchange = java.lang.ThreadLocal.new
48
52
  end
49
53
 
50
54
  def symbolize(myhash)
51
55
  Hash[myhash.map{|(k,v)| [k.to_sym,v]}]
52
56
  end
53
57
 
54
- def receive(event)
55
- @codec.encode(event)
56
- rescue StandardError => e
57
- @logger.warn("Error encoding event", :exception => e, :event => event)
58
+ def multi_receive_encoded(events_and_data)
59
+ events_and_data.each do |event, data|
60
+ publish(event, data)
61
+ end
58
62
  end
59
63
 
60
64
  def publish(event, message)
61
65
  raise ArgumentError, "No exchange set in HareInfo!!!" unless @hare_info.exchange
62
- @hare_info.exchange.publish(message, :routing_key => event.sprintf(@key), :properties => symbolize(@message_properties.merge(:persistent => @persistent)))
66
+ local_exchange.publish(message, :routing_key => event.sprintf(@key), :properties => symbolize(@message_properties.merge(:persistent => @persistent)))
63
67
  rescue MarchHare::Exception, IOError, AlreadyClosedException, TimeoutException => e
64
68
  @logger.error("Error while publishing. Will retry.",
65
69
  :message => e.message,
@@ -70,6 +74,24 @@ module LogStash
70
74
  retry
71
75
  end
72
76
 
77
+ def local_exchange
78
+ exchange = @thread_local_exchange.get
79
+ if !exchange
80
+ exchange = declare_exchange!(local_channel, @exchange, @exchange_type, @durable)
81
+ @thread_local_exchange.set(exchange)
82
+ end
83
+ exchange
84
+ end
85
+
86
+ def local_channel
87
+ channel = @thread_local_channel.get
88
+ if !channel
89
+ channel = @hare_info.connection.create_channel
90
+ @thread_local_channel.set(channel)
91
+ end
92
+ channel
93
+ end
94
+
73
95
  def close
74
96
  close_connection
75
97
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-rabbitmq'
3
- s.version = '5.0.3'
3
+ s.version = '5.1.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Pushes events to 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/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -163,6 +163,7 @@ describe "with a live server", :integration => true do
163
163
  sleep 1
164
164
  end
165
165
  let(:message) { LogStash::Event.new("message" => "Foo Message", "extra_field" => "Blah") }
166
+ let(:encoded) { message.to_json }
166
167
  let(:test_connection) { MarchHare.connect(instance.send(:rabbitmq_settings)) }
167
168
  let(:test_channel) { test_connection.create_channel }
168
169
  let(:test_queue) {
@@ -196,7 +197,7 @@ describe "with a live server", :integration => true do
196
197
  end
197
198
 
198
199
  it 'applies per message settings' do
199
- instance.receive(message)
200
+ instance.multi_receive_encoded([[message, encoded]])
200
201
  sleep 1.0
201
202
 
202
203
  message, payload = test_queue.pop
@@ -213,7 +214,7 @@ describe "with a live server", :integration => true do
213
214
  @received = payload
214
215
  end
215
216
 
216
- instance.receive(message)
217
+ instance.multi_receive_encoded([[message, encoded]])
217
218
 
218
219
  until @received
219
220
  sleep 1
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: 5.0.3
4
+ version: 5.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-13 00:00:00.000000000 Z
11
+ date: 2018-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.6.11
135
+ rubygems_version: 2.6.13
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Pushes events to a RabbitMQ exchange