logstash-integration-rabbitmq 7.0.2-java → 7.3.0-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 +21 -0
- data/LICENSE +199 -10
- data/README.md +1 -1
- data/docs/input-rabbitmq.asciidoc +13 -4
- data/docs/output-rabbitmq.asciidoc +4 -2
- data/lib/logstash/inputs/rabbitmq.rb +72 -16
- data/lib/logstash/outputs/rabbitmq.rb +71 -10
- data/lib/logstash/plugin_mixins/rabbitmq_connection.rb +75 -45
- data/logstash-integration-rabbitmq.gemspec +2 -2
- data/spec/inputs/rabbitmq_spec.rb +228 -9
- data/spec/outputs/rabbitmq_spec.rb +61 -9
- data/spec/plugin_mixins/rabbitmq_connection_spec.rb +48 -23
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 207f3a12b1cbb1d32a97f5341574d44d025e789c18af79f5562555df9fa94d6a
|
|
4
|
+
data.tar.gz: '09287862ba07197a33028cf84cae6bf84804ca7d4158617cafe71a255958688c'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 162c55651e563452c7a3930ab665a68edacbdbfc4c0f1aaa1bd9ba7e1f8388ce86be8e07cfcc48372333b035c72dfef8cc98122ee1abd332c2fa955928744de5
|
|
7
|
+
data.tar.gz: 699b2aaecda77591b1fa3f731ce094f104ed1b9f74fe81cb1c80876c15baa133d46162a9e8ce9020615aa9b40bb2259e0a98f4f1317f992f4398734552098191
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## 7.3.0
|
|
2
|
+
- Refactor: logging improvements [#47](https://github.com/logstash-plugins/logstash-integration-rabbitmq/pull/47)
|
|
3
|
+
* integrated MarchHare logging to be part of Logstash's log instead of using std-err
|
|
4
|
+
* normalized logging format on (Ruby) errors
|
|
5
|
+
|
|
6
|
+
## 7.2.0
|
|
7
|
+
- Remove ruby pipeline dependency. Starting from Logstash 8, Ruby execution engine is not available. All pipelines should use Java pipeline [#39](https://github.com/logstash-plugins/logstash-integration-rabbitmq/pull/39)
|
|
8
|
+
|
|
9
|
+
## 7.1.1
|
|
10
|
+
- DOC:Replaced plugin_header file with plugin_header-integration file. ([#34](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/34))
|
|
11
|
+
|
|
12
|
+
## 7.1.0
|
|
13
|
+
- Added support in Output plugin for `sprintf` templates in values provided to `message_properties` ([#8](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/8))
|
|
14
|
+
- Added support for _extended_ metadata including raw payload to events generated by the Input Plugin [#13](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/13)
|
|
15
|
+
- Fixes an issue with custom port assignment, in which the custom port was not being applied when more than one host was supplied [#12](https://github.com/logstash-plugins/logstash-integration-rabbitmq/pull/12)
|
|
16
|
+
- Fixes bug where attempting to read from undeclared exchange resulted in infinite retry loop ([#10](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/10))
|
|
17
|
+
- Fixes bug where failing to establish initial connection resulted in a pipeline that refused to shut down ([#11](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/11))
|
|
18
|
+
|
|
19
|
+
## 7.0.3
|
|
20
|
+
- Refactor: scope (and remove unused) java imports [#29](https://github.com/logstash-plugins/logstash-integration-rabbitmq/pull/29)
|
|
21
|
+
|
|
1
22
|
## 7.0.2
|
|
2
23
|
- Fixes issue in Output where failure to register connection reovery hooks prevented the output from starting
|
|
3
24
|
|
data/LICENSE
CHANGED
|
@@ -1,13 +1,202 @@
|
|
|
1
|
-
Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2020 Elastic and contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Logstash Plugin
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.com/logstash-plugins/logstash-integration-rabbitmq)
|
|
4
4
|
|
|
5
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
|
6
6
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
:integration: rabbitmq
|
|
1
2
|
:plugin: rabbitmq
|
|
2
3
|
:type: input
|
|
3
4
|
:default_codec: json
|
|
@@ -17,7 +18,7 @@ END - GENERATED VARIABLES, DO NOT EDIT!
|
|
|
17
18
|
|
|
18
19
|
=== Rabbitmq input plugin
|
|
19
20
|
|
|
20
|
-
include::{include_path}/plugin_header.asciidoc[]
|
|
21
|
+
include::{include_path}/plugin_header-integration.asciidoc[]
|
|
21
22
|
|
|
22
23
|
==== Description
|
|
23
24
|
|
|
@@ -34,7 +35,7 @@ and other parts of the RabbitMQ documentation are useful for deeper
|
|
|
34
35
|
understanding.
|
|
35
36
|
|
|
36
37
|
The properties of messages received will be stored in the
|
|
37
|
-
`[@metadata][rabbitmq_properties]` field if the `@metadata_enabled` setting is
|
|
38
|
+
`[@metadata][rabbitmq_properties]` field if the `@metadata_enabled` setting is enabled.
|
|
38
39
|
Note that storing metadata may degrade performance.
|
|
39
40
|
The following properties may be available (in most cases dependent on whether
|
|
40
41
|
they were set by the sender):
|
|
@@ -187,6 +188,8 @@ The default connection timeout in milliseconds. If not specified the timeout is
|
|
|
187
188
|
* Default value is `false`
|
|
188
189
|
|
|
189
190
|
Is this queue durable? (aka; Should it survive a broker restart?)
|
|
191
|
+
If consuming directly from a queue you must set this value to match the existing queue setting,
|
|
192
|
+
otherwise the connection will fail due to an inequivalent arg error.
|
|
190
193
|
|
|
191
194
|
[id="plugins-{type}s-{plugin}-exchange"]
|
|
192
195
|
===== `exchange`
|
|
@@ -259,8 +262,14 @@ This is only relevant for direct or topic exchanges.
|
|
|
259
262
|
[id="plugins-{type}s-{plugin}-metadata_enabled"]
|
|
260
263
|
===== `metadata_enabled`
|
|
261
264
|
|
|
262
|
-
* Value type is <<
|
|
263
|
-
*
|
|
265
|
+
* Value type is <<string,string>>
|
|
266
|
+
* Accepted values are:
|
|
267
|
+
- `none`: no metadata is added
|
|
268
|
+
- `basic`: headers and properties are added
|
|
269
|
+
- `extended`: headers, properties, and raw payload are added
|
|
270
|
+
- `false`: deprecated alias for `none`
|
|
271
|
+
- `true`: deprecated alias for `basic`
|
|
272
|
+
* Default value is `none`
|
|
264
273
|
|
|
265
274
|
Enable the storage of message headers and properties in `@metadata`. This may impact performance
|
|
266
275
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
:integration: rabbitmq
|
|
1
2
|
:plugin: rabbitmq
|
|
2
3
|
:type: output
|
|
3
4
|
:default_codec: json
|
|
@@ -17,7 +18,7 @@ END - GENERATED VARIABLES, DO NOT EDIT!
|
|
|
17
18
|
|
|
18
19
|
=== Rabbitmq output plugin
|
|
19
20
|
|
|
20
|
-
include::{include_path}/plugin_header.asciidoc[]
|
|
21
|
+
include::{include_path}/plugin_header-integration.asciidoc[]
|
|
21
22
|
|
|
22
23
|
==== Description
|
|
23
24
|
|
|
@@ -168,7 +169,8 @@ Key to route to by default. Defaults to 'logstash'
|
|
|
168
169
|
* Value type is <<hash,hash>>
|
|
169
170
|
* Default value is `{}`
|
|
170
171
|
|
|
171
|
-
Add properties to be set per-message here, such as 'content_type', 'priority'
|
|
172
|
+
Add properties to be set per-message here, such as 'content_type', 'priority'.
|
|
173
|
+
Values can be {logstash-ref}/event-dependent-configuration.html#sprintf[`sprintf` templates], whose value for each message will be populated from the event.
|
|
172
174
|
|
|
173
175
|
Example:
|
|
174
176
|
[source,ruby]
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
require_relative '../plugin_mixins/rabbitmq_connection'
|
|
3
3
|
require 'logstash/inputs/threadable'
|
|
4
4
|
require 'logstash/event'
|
|
5
|
-
java_import java.util.concurrent.ArrayBlockingQueue
|
|
6
|
-
java_import java.util.concurrent.TimeUnit
|
|
7
5
|
|
|
8
6
|
module LogStash
|
|
9
7
|
module Inputs
|
|
@@ -59,6 +57,9 @@ module LogStash
|
|
|
59
57
|
# Additionally, any message headers will be saved in the
|
|
60
58
|
# `[@metadata][rabbitmq_headers]` field.
|
|
61
59
|
class RabbitMQ < LogStash::Inputs::Threadable
|
|
60
|
+
|
|
61
|
+
java_import java.util.concurrent.TimeUnit
|
|
62
|
+
|
|
62
63
|
include ::LogStash::PluginMixins::RabbitMQConnection
|
|
63
64
|
|
|
64
65
|
# The properties to extract from each message and store in a
|
|
@@ -165,16 +166,23 @@ module LogStash
|
|
|
165
166
|
config :subscription_retry_interval_seconds, :validate => :number, :required => true, :default => 5
|
|
166
167
|
|
|
167
168
|
# Enable the storage of message headers and properties in `@metadata`. This may impact performance
|
|
168
|
-
config :metadata_enabled, :validate =>
|
|
169
|
+
config :metadata_enabled, :validate => %w(none basic extended false true), :default => "none"
|
|
169
170
|
|
|
170
171
|
def register
|
|
171
172
|
@internal_queue = java.util.concurrent.ArrayBlockingQueue.new(@prefetch_count*2)
|
|
173
|
+
@metadata_level = extract_metadata_level(@metadata_enabled)
|
|
172
174
|
end
|
|
173
175
|
|
|
176
|
+
attr_reader :metadata_level
|
|
177
|
+
|
|
174
178
|
def run(output_queue)
|
|
175
179
|
setup!
|
|
176
180
|
@output_queue = output_queue
|
|
177
181
|
consume!
|
|
182
|
+
rescue => e
|
|
183
|
+
raise(e) unless stop?
|
|
184
|
+
|
|
185
|
+
@logger.warn("Ignoring exception thrown during plugin shutdown", error_details(e))
|
|
178
186
|
end
|
|
179
187
|
|
|
180
188
|
def setup!
|
|
@@ -183,14 +191,29 @@ module LogStash
|
|
|
183
191
|
bind_exchange!
|
|
184
192
|
@hare_info.channel.prefetch = @prefetch_count
|
|
185
193
|
rescue => e
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
194
|
+
# when encountering an exception during shut-down,
|
|
195
|
+
# re-raise the exception instead of retrying
|
|
196
|
+
raise if stop?
|
|
197
|
+
|
|
198
|
+
reset!
|
|
199
|
+
|
|
200
|
+
@logger.warn("Error while setting up connection, will retry", error_details(e))
|
|
190
201
|
sleep_for_retry
|
|
191
202
|
retry
|
|
192
203
|
end
|
|
193
204
|
|
|
205
|
+
# reset a partially-established connection, enabling subsequent
|
|
206
|
+
# call to `RabbitMQ#setup!` to succeed.
|
|
207
|
+
#
|
|
208
|
+
# @api private
|
|
209
|
+
def reset!
|
|
210
|
+
@hare_info.connection && @hare_info.connection.close
|
|
211
|
+
rescue => e
|
|
212
|
+
@logger.debug("Exception while resetting connection", error_details(e))
|
|
213
|
+
ensure
|
|
214
|
+
@hare_info = nil
|
|
215
|
+
end
|
|
216
|
+
|
|
194
217
|
def bind_exchange!
|
|
195
218
|
if @exchange
|
|
196
219
|
if @exchange_type # Only declare the exchange if @exchange_type is set!
|
|
@@ -221,8 +244,8 @@ module LogStash
|
|
|
221
244
|
|
|
222
245
|
begin
|
|
223
246
|
@hare_info.queue.subscribe_with(@consumer, :manual_ack => @ack)
|
|
224
|
-
rescue
|
|
225
|
-
@logger.warn("Could not subscribe to queue
|
|
247
|
+
rescue => e
|
|
248
|
+
@logger.warn("Could not subscribe to queue, will retry in #{@subscription_retry_interval_seconds} seconds", error_details(e, :queue => @queue))
|
|
226
249
|
|
|
227
250
|
sleep @subscription_retry_interval_seconds
|
|
228
251
|
retry
|
|
@@ -249,12 +272,11 @@ module LogStash
|
|
|
249
272
|
|
|
250
273
|
metadata, data = payload
|
|
251
274
|
@codec.decode(data) do |event|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
if event
|
|
276
|
+
decorate(event, metadata, data)
|
|
277
|
+
|
|
278
|
+
@output_queue << event
|
|
256
279
|
end
|
|
257
|
-
@output_queue << event if event
|
|
258
280
|
end
|
|
259
281
|
|
|
260
282
|
i += 1
|
|
@@ -269,6 +291,16 @@ module LogStash
|
|
|
269
291
|
end
|
|
270
292
|
end
|
|
271
293
|
|
|
294
|
+
def decorate(event, metadata, data)
|
|
295
|
+
super(event)
|
|
296
|
+
|
|
297
|
+
event.set("[@metadata][rabbitmq_headers]", get_headers(metadata)) if metadata_level.include?(:headers)
|
|
298
|
+
event.set("[@metadata][rabbitmq_properties]", get_properties(metadata)) if metadata_level.include?(:properties)
|
|
299
|
+
event.set("[@metadata][rabbitmq_payload]", data) if metadata_level.include?(:payload) && !data.nil?
|
|
300
|
+
|
|
301
|
+
nil
|
|
302
|
+
end
|
|
303
|
+
|
|
272
304
|
def stop
|
|
273
305
|
@internal_queue.put(INTERNAL_QUEUE_POISON)
|
|
274
306
|
shutdown_consumer
|
|
@@ -278,15 +310,17 @@ module LogStash
|
|
|
278
310
|
def shutdown_consumer
|
|
279
311
|
return unless @consumer
|
|
280
312
|
@hare_info.channel.basic_cancel(@consumer.consumer_tag)
|
|
313
|
+
connection = @hare_info.connection
|
|
281
314
|
until @consumer.terminated?
|
|
282
|
-
@logger.info("Waiting for
|
|
315
|
+
@logger.info("Waiting for RabbitMQ consumer to terminate before stopping", url: connection_url(connection))
|
|
283
316
|
sleep 1
|
|
284
317
|
end
|
|
285
318
|
end
|
|
286
319
|
|
|
287
320
|
def on_cancellation
|
|
288
321
|
if !stop? # If this isn't already part of a regular stop
|
|
289
|
-
|
|
322
|
+
connection = @hare_info.connection
|
|
323
|
+
@logger.info("Received cancellation, shutting down", url: connection_url(connection))
|
|
290
324
|
stop
|
|
291
325
|
end
|
|
292
326
|
end
|
|
@@ -310,6 +344,28 @@ module LogStash
|
|
|
310
344
|
acc
|
|
311
345
|
end
|
|
312
346
|
end
|
|
347
|
+
|
|
348
|
+
METADATA_NONE = Set[].freeze
|
|
349
|
+
METADATA_BASIC = Set[:headers,:properties].freeze
|
|
350
|
+
METADATA_EXTENDED = Set[:headers,:properties,:payload].freeze
|
|
351
|
+
METADATA_DEPRECATION_MAP = { 'true' => 'basic', 'false' => 'none' }
|
|
352
|
+
|
|
353
|
+
private
|
|
354
|
+
def extract_metadata_level(metadata_enabled_setting)
|
|
355
|
+
metadata_enabled = metadata_enabled_setting
|
|
356
|
+
|
|
357
|
+
if METADATA_DEPRECATION_MAP.include?(metadata_enabled)
|
|
358
|
+
canonical_value = METADATA_DEPRECATION_MAP[metadata_enabled]
|
|
359
|
+
logger.warn("Deprecated value `#{metadata_enabled_setting}` for `metadata_enabled` option; use `#{canonical_value}` instead.")
|
|
360
|
+
metadata_enabled = canonical_value
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
case metadata_enabled
|
|
364
|
+
when 'none' then METADATA_NONE
|
|
365
|
+
when 'basic' then METADATA_BASIC
|
|
366
|
+
when 'extended' then METADATA_EXTENDED
|
|
367
|
+
end
|
|
368
|
+
end
|
|
313
369
|
end
|
|
314
370
|
end
|
|
315
371
|
end
|