logstash-input-jms 3.2.0-java → 3.2.1-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: 2a40f29ee0db67e912d547f5fa74a74bcd08466c3f2594dd9edd5f82669ea494
4
- data.tar.gz: c8fa0a986cea0a588b8b68fbd8618f24122ee42abb21ad3cf7f5e7cbb0f3484c
3
+ metadata.gz: 5dca4ef438036be47078b2db808c88cfd09206a952c793a235cb46ef655067c8
4
+ data.tar.gz: 1f8e6bd65539c095a4d78488121a08eaee5d5bd24c6eb1f67e35b070550638ff
5
5
  SHA512:
6
- metadata.gz: a121b9359ff97942888218bb1f2553f469940574e7f8421f7e910980bf37b973fd73cb2e0739a7525c0b71c5e8b4891765f70e505a798d1d9263f0bedbb13eee
7
- data.tar.gz: d10f028310928b17f41f48cc50e8393022171d2c2fa4d25502f428f3d2bfbfc6172eee75d527d0ebb9b66f5a3790b6fe9c50fc3de5355dd71a907be33d5f9c5c
6
+ metadata.gz: 49c794f7452a575a8ce57e168f862e945bb2d57193daca9ff5ac4767b2f9eed39045d5fbed3a8b735fb3c050848d48a8fe2b57febf7a34c19baf9820664c71f3
7
+ data.tar.gz: 707f05788271a99e6e4eff3555285fa4120e3f6e2b1251ed63ddfbce1e38a2e1a821e59df549f3ac912bc4e221fa6776a320f286e6f8ef8b4f070aa4fed59669
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 3.2.1
2
+ - Fix: improve compatibility with MessageConsumer implementations [#51](https://github.com/logstash-plugins/logstash-input-jms/pull/51),
3
+ such as IBM MQ.
4
+ - Test: Fix test failures due to ECS compatibility default changes in `8.x` of logstash [#53](https://github.com/logstash-plugins/logstash-input-jms/pull/53)
5
+
1
6
  ## 3.2.0
2
7
  - Feat: event_factory support + targets to aid ECS [#49](https://github.com/logstash-plugins/logstash-input-jms/pull/49)
3
8
  - Fix: when configured to add JMS headers to the event, headers whose value is not set no longer result in nil entries on the event
@@ -84,7 +84,7 @@ class LogStash::Inputs::Jms < LogStash::Inputs::Threadable
84
84
  # If pub-sub (topic) style should be used.
85
85
  config :pub_sub, :validate => :boolean, :default => false
86
86
 
87
- # Durable subscriber settings.
87
+ # Durable message_consumer settings.
88
88
  # By default the `durable_subscriber_name` will be set to the topic, and `durable_subscriber_client_id` will be set
89
89
  # to 'Logstash'
90
90
  config :durable_subscriber, :validate => :boolean, :default => false
@@ -273,9 +273,9 @@ class LogStash::Inputs::Jms < LogStash::Inputs::Threadable
273
273
  params = {:timeout => @timeout * 1000, :selector => @selector}
274
274
  subscriber = subscriber(session, params)
275
275
  until stop?
276
- # This will read from the queue/topic until :timeout is breached, or messages are available whichever comes
277
- # first.
278
- subscriber.each({:timeout => @interval * 1000}) do |message|
276
+ # read from the queue/topic until :timeout is reached, or a message is available
277
+ # (whichever comes first)
278
+ do_receive_message(subscriber, timeout: @interval * 1000) do |message|
279
279
  queue_event(message, output_queue)
280
280
  break if stop?
281
281
  end
@@ -336,6 +336,28 @@ class LogStash::Inputs::Jms < LogStash::Inputs::Threadable
336
336
  end
337
337
  end
338
338
 
339
+ # Loop through messages received and yield them.
340
+ #
341
+ # NOTE: a simplified replacement for JMS::MessageConsumer#each and #get (extensions).
342
+ #
343
+ # @param message_consumer [javax.jms.MessageConsumer]
344
+ # @param timeout in milliseconds
345
+ def do_receive_message(message_consumer, timeout: 0)
346
+ # Receive messages according to timeout
347
+ while true
348
+ case timeout
349
+ when 0 # Return immediately if no message is available
350
+ message = message_consumer.receiveNoWait()
351
+ when -1 # Wait forever
352
+ message = message_consumer.receive()
353
+ else # Wait for x milli-seconds for a message to be received from the broker
354
+ message = message_consumer.receive(timeout)
355
+ end
356
+ break unless message
357
+ yield message
358
+ end
359
+ end
360
+
339
361
  def to_string_keyed_hash(hash)
340
362
  hash.inject({}) { |h, (key, val)| h[key.to_s] = val; h }
341
363
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-jms'
4
- s.version = '3.2.0'
4
+ s.version = '3.2.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Reads events from a Jms Broker"
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/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -23,11 +23,11 @@ shared_examples_for "a JMS input" do
23
23
  msg
24
24
  end
25
25
  expect(queue.first.get('message')).to eql(message)
26
- expect(queue.first.get('jms_destination')).to_not be_nil
27
- expect(queue.first.get('jms_timestamp')).to_not be_nil
28
- expect(queue.first.get('this')).to be_nil
29
- expect(queue.first.get('that')).to be_nil
30
- expect(queue.first.get('the_other')).to eql('the_other_prop')
26
+ expect(queue.first).to have_header('jms_destination')
27
+ expect(queue.first).to have_header('jms_timestamp')
28
+ expect(queue.first).not_to have_property('this')
29
+ expect(queue.first).not_to have_property('this')
30
+ expect(queue.first).to have_property_value('the_other', 'the_other_prop')
31
31
  end
32
32
  end
33
33
 
@@ -45,8 +45,8 @@ shared_examples_for "a JMS input" do
45
45
  msg
46
46
  end
47
47
  expect(queue.first.get('message')).to eql(message)
48
- expect(queue.first.get('this')).to eql(4)
49
- expect(queue.first.get('that')).to eql('that_prop')
48
+ expect(queue.first).to have_property_value('this', 4)
49
+ expect(queue.first).to have_property_value('that', 'that_prop')
50
50
  end
51
51
 
52
52
  it 'does not process messages that do not conform to the message selector' do
@@ -71,8 +71,8 @@ shared_examples_for "a JMS input" do
71
71
  msg
72
72
  end
73
73
  expect(queue.first.get('message')).to eql(message)
74
- expect(queue.first.get('this')).to eql(3)
75
- expect(queue.first.get('that')).to eql('that_prop')
74
+ expect(queue.first).to have_property_value('this', 3)
75
+ expect(queue.first).to have_property_value('that', 'that_prop')
76
76
  end
77
77
 
78
78
  it 'does not process messages that do not conform to the message selector' do
@@ -97,8 +97,8 @@ shared_examples_for "a JMS input" do
97
97
  msg
98
98
  end
99
99
  expect(queue.first.get('message')).to eql(message)
100
- expect(queue.first.get('this')).to be_within(0.001).of(3.1)
101
- expect(queue.first.get('that')).to eql('that_prop')
100
+ expect(get_property_value(queue.first, 'this')).to be_within(0.001).of(3.1)
101
+ expect(queue.first).to have_property_value('that', 'that_prop')
102
102
  end
103
103
 
104
104
  it 'does not process messages that do not conform to the message selector' do
@@ -124,8 +124,8 @@ shared_examples_for "a JMS input" do
124
124
  msg
125
125
  end
126
126
  expect(queue.first.get('message')).to eql(message)
127
- expect(queue.first.get('this')).to eql('this_prop')
128
- expect(queue.first.get('that')).to eql('that_prop')
127
+ expect(queue.first).to have_property_value('this', 'this_prop')
128
+ expect(queue.first).to have_property_value('that', 'that_prop')
129
129
  end
130
130
 
131
131
  it 'does not process messages that do not conform to the message selector' do
@@ -154,11 +154,11 @@ shared_examples_for "a JMS input" do
154
154
  msg
155
155
  end
156
156
  expect(queue.first.get('message')).to eql(message)
157
- expect(queue.first.get('jms_destination')).to be_nil
158
- expect(queue.first.get('jms_timestamp')).to_not be_nil
159
- expect(queue.first.get('this')).to eq('this_prop')
160
- expect(queue.first.get('that')).to eq('that_prop')
161
- expect(queue.first.get('the_other')).to eq('the_other_prop')
157
+ expect(queue.first).not_to have_header('jms_destination')
158
+ expect(queue.first).to have_header('jms_timestamp')
159
+ expect(queue.first).to have_property_value('this', 'this_prop')
160
+ expect(queue.first).to have_property_value('that', 'that_prop')
161
+ expect(queue.first).to have_property_value('the_other', 'the_other_prop')
162
162
  end
163
163
  end
164
164
 
@@ -293,7 +293,7 @@ shared_examples_for "a JMS input" do
293
293
  end
294
294
  expect(queue.size).to eql 1
295
295
  expect(queue.first.get('message')).to eql 'hello world'
296
- expect(queue.first.get("jms_destination")).to eql(destination)
296
+ expect(queue.first).to have_header_value("jms_destination", destination)
297
297
  end
298
298
  end
299
299
  end
@@ -32,6 +32,42 @@ def send_message(&block)
32
32
  end
33
33
  input.run(queue)
34
34
 
35
- destination = "#{pub_sub ? 'topic' : 'queue'}://#{queue_name}"
36
35
  tt.join(3)
37
36
  end
37
+
38
+
39
+ def get_value(type, actual, name)
40
+ actual.get(name) || actual.get("[@metadata][input][jms][#{type}][#{name}]")
41
+ end
42
+
43
+ def get_header_value(actual, name)
44
+ get_value('headers', actual, name)
45
+ end
46
+
47
+ def get_property_value(actual, name)
48
+ get_value('properties', actual, name)
49
+ end
50
+
51
+ RSpec::Matchers.define :have_header do |expected|
52
+ match do |actual|
53
+ get_header_value(actual, expected)
54
+ end
55
+ end
56
+
57
+ RSpec::Matchers.define :have_property do |expected|
58
+ match do |actual|
59
+ get_property_value(actual, expected)
60
+ end
61
+ end
62
+
63
+ RSpec::Matchers.define :have_header_value do |header, expected|
64
+ match do |actual|
65
+ expected == get_header_value(actual, header)
66
+ end
67
+ end
68
+
69
+ RSpec::Matchers.define :have_property_value do |property, expected|
70
+ match do |actual|
71
+ expected == get_property_value(actual, property)
72
+ end
73
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-jms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement