fluent-plugin-amqp 0.7.0 → 0.7.1
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/lib/fluent/plugin/in_amqp.rb +20 -11
- data/lib/fluent/plugin/out_amqp.rb +14 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2faee36d9db937fb190935e620e3b39a3dc226d
|
4
|
+
data.tar.gz: 5070a58c8427cb20c1a100105573036fc0d8688f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d07705f1da8b0618ca41029c5a01a1b453ced2347a829b4e544581d0fb5878f7c383f323911c2be4e30519678faf254123b06073d9b8c7b90e85b7d8a0a962c8
|
7
|
+
data.tar.gz: 2927771afd59c19287d934f5b560845afb57bc705c4799668f581b81ec6d25d907d5b4c6d3f1377dcfb64fb12f12e4fcc522df5005d79bd3e23fe6e39a0dcac7
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'time'
|
2
2
|
|
3
3
|
module Fluent
|
4
|
+
##
|
5
|
+
# AMQPInput to be used as a Fluent SOURCE, reading messages from a RabbitMQ
|
6
|
+
# message broker
|
4
7
|
class AMQPInput < Input
|
5
8
|
Fluent::Plugin.register_input('amqp', self)
|
6
9
|
|
@@ -37,6 +40,11 @@ module Fluent
|
|
37
40
|
config_param :tls_key, :string, :default => nil
|
38
41
|
config_param :tls_ca_certificates, :array, :default => nil
|
39
42
|
config_param :tls_verify_peer, :bool, :default => true
|
43
|
+
config_param :bind_exchange, :bool, :default => false
|
44
|
+
config_param :exchange, :string, :default => ""
|
45
|
+
config_param :routing_key, :string, :default => "#" # The routing key used to bind queue to exchange - # = matches all, * matches section (tag.*.info)
|
46
|
+
|
47
|
+
|
40
48
|
|
41
49
|
def initialize
|
42
50
|
require 'bunny'
|
@@ -59,33 +67,34 @@ module Fluent
|
|
59
67
|
raise ConfigError, "'host' and 'queue' must be all specified."
|
60
68
|
end
|
61
69
|
check_tls_configuration
|
62
|
-
|
63
70
|
end
|
64
71
|
|
65
72
|
def start
|
66
73
|
super
|
67
|
-
@thread = Thread.new(&method(:run))
|
68
|
-
end
|
69
|
-
|
70
|
-
def shutdown
|
71
|
-
@connection.stop
|
72
|
-
@thread.join
|
73
|
-
super
|
74
|
-
end
|
75
|
-
|
76
|
-
def run
|
77
74
|
# Create a new connection, unless its already been provided to us
|
78
75
|
@connection = Bunny.new get_connection_options unless @connection
|
79
76
|
@connection.start
|
80
77
|
@channel = @connection.create_channel
|
81
78
|
q = @channel.queue(@queue, :passive => @passive, :durable => @durable,
|
82
79
|
:exclusive => @exclusive, :auto_delete => @auto_delete)
|
80
|
+
if @bind_exchange
|
81
|
+
log.info "Binding #{@queue} to #{@exchange}, :routing_key => #{@routing_key}"
|
82
|
+
q.bind(exchange=@exchange, :routing_key => @routing_key)
|
83
|
+
end
|
84
|
+
|
83
85
|
q.subscribe do |delivery, meta, msg|
|
86
|
+
log.debug "Recieved message #{@msg}"
|
84
87
|
payload = parse_payload(msg)
|
85
88
|
router.emit(parse_tag(delivery, meta), parse_time(meta), payload)
|
86
89
|
end
|
87
90
|
end # AMQPInput#run
|
88
91
|
|
92
|
+
def shutdown
|
93
|
+
log.info "Closing connection"
|
94
|
+
@connection.stop
|
95
|
+
super
|
96
|
+
end
|
97
|
+
|
89
98
|
private
|
90
99
|
def parse_payload(msg)
|
91
100
|
if @parser
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'json'
|
2
2
|
module Fluent
|
3
|
+
##
|
4
|
+
# AMQPOutput to be used as a Fluent MATCHER, sending messages to a RabbitMQ
|
5
|
+
# messaging broker
|
3
6
|
class AMQPOutput < BufferedOutput
|
4
7
|
Plugin.register_output("amqp", self)
|
5
8
|
|
@@ -48,9 +51,17 @@ module Fluent
|
|
48
51
|
|
49
52
|
def start
|
50
53
|
super
|
51
|
-
|
54
|
+
begin
|
55
|
+
log.info "Connecting to RabbitMQ..."
|
56
|
+
@connection = Bunny.new(get_connection_options) unless @connection
|
57
|
+
@connection.start
|
58
|
+
rescue Bunny::TCPConnectionFailed => e
|
59
|
+
log.error "Connection to #{@host} failed"
|
60
|
+
rescue Bunny::PossibleAuthenticationFailureError => e
|
61
|
+
log.error "Could not authenticate as #{@user}"
|
62
|
+
end
|
52
63
|
|
53
|
-
@
|
64
|
+
log.info "Creating new exchange #{@exchange}"
|
54
65
|
@channel = @connection.create_channel
|
55
66
|
@exch = @channel.exchange(@exchange, :type => @exchange_type.intern,
|
56
67
|
:passive => @passive, :durable => @durable,
|
@@ -69,6 +80,7 @@ module Fluent
|
|
69
80
|
def write(chunk)
|
70
81
|
chunk.msgpack_each do |(tag, time, data)|
|
71
82
|
data = JSON.dump( data ) unless data.is_a?( String )
|
83
|
+
log.debug "Sending message #{data}, :key => #{routing_key( tag)} :headers => #{headers(tag,time)}"
|
72
84
|
@exch.publish(data, :key => routing_key( tag ), :persistent => @persistent, :headers => headers( tag, time ))
|
73
85
|
end
|
74
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiromi Ishii
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 2.2
|
35
|
+
version: '2.2'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.2
|
42
|
+
version: '2.2'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: shoulda
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.4.8
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: AMQP input/output plugin or fluentd
|