fluent-plugin-amq 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-amq.gemspec +1 -1
- data/lib/fluent/plugin/in_amq.rb +24 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f6e3b00afdbe3b1108912af865629f3d657cb28
|
4
|
+
data.tar.gz: 00aea0b8d8a89d7808fe23998999639d27ed09c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c995d095cdba1b76ddf9bbc100bf553938dcf66a3fde0874c12cbda4bb74b1199e096a94db8de4d41f00c63f7e0b78452a7f48e6779133fed531885b5a2dfaa8
|
7
|
+
data.tar.gz: 8c989eadabd732ced9c120db595de4e35dea56428dd9daee1de2de222226f6618f2088bc42a481fb68450b790fb779cdce7c85dc9cbb7cfea3e0770e12257508
|
data/fluent-plugin-amq.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-amq"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.4"
|
7
7
|
s.authors = ["Anton Sherkhonov"]
|
8
8
|
s.email = ["sherkhonov@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/t0ffel/fluent-plugin-amq"
|
data/lib/fluent/plugin/in_amq.rb
CHANGED
@@ -4,7 +4,7 @@ require 'fluent/input'
|
|
4
4
|
|
5
5
|
|
6
6
|
module Fluent
|
7
|
-
class
|
7
|
+
class AMQInput < Input
|
8
8
|
NAME = 'amq'
|
9
9
|
Plugin.register_input(NAME, self)
|
10
10
|
|
@@ -43,11 +43,12 @@ module Fluent
|
|
43
43
|
@thread = Thread.new do
|
44
44
|
while !@stop
|
45
45
|
begin
|
46
|
-
h =
|
46
|
+
h = Client.new log, @url, @tag, @router, @ssl_domain, @queue
|
47
47
|
@container = Qpid::Proton::Container.new(h)
|
48
48
|
@container.run
|
49
49
|
rescue => e
|
50
50
|
log.error "Error connecting to the AMQP bus #{e.message}"
|
51
|
+
log.error "Backtrace: #{e.backtrace}"
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -61,7 +62,7 @@ module Fluent
|
|
61
62
|
rescue
|
62
63
|
end
|
63
64
|
|
64
|
-
class
|
65
|
+
class Client < Qpid::Proton::MessagingHandler
|
65
66
|
|
66
67
|
def initialize(log, url, tag, router, ssl_domain, queue)
|
67
68
|
super()
|
@@ -87,18 +88,12 @@ module Fluent
|
|
87
88
|
@log.debug "Connection secured with #{c.transport.ssl.protocol_name.inspect}"
|
88
89
|
end
|
89
90
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
rescue => e
|
98
|
-
@log.error "Error decoding JSON from #{e.message}"
|
99
|
-
@log.error "Backtrace: #{e.backtrace}"
|
100
|
-
end
|
101
|
-
|
91
|
+
def build_json_record(message)
|
92
|
+
record = {
|
93
|
+
body: JSON.parse(message.body),
|
94
|
+
address: message.address,
|
95
|
+
msg_id: message.id
|
96
|
+
}
|
102
97
|
record[:properties] = message.properties if (message.properties and message.properties.size > 0)
|
103
98
|
record[:annotations] = message.annotations if (message.annotations and message.annotations.size > 0)
|
104
99
|
record[:instructions] = message.instructions if (message.instructions and message.instructions.size > 0)
|
@@ -110,6 +105,16 @@ module Fluent
|
|
110
105
|
record
|
111
106
|
end
|
112
107
|
|
108
|
+
def build_record(message)
|
109
|
+
begin
|
110
|
+
record = build_json_record(message)
|
111
|
+
rescue => e
|
112
|
+
@log.warn "Error decoding JSON from the body of `#{message}`"
|
113
|
+
record = { body: message }
|
114
|
+
end
|
115
|
+
record
|
116
|
+
end
|
117
|
+
|
113
118
|
def on_message(delivery, message)
|
114
119
|
record = build_record(message)
|
115
120
|
time = Engine.now
|
@@ -118,6 +123,10 @@ module Fluent
|
|
118
123
|
@router.emit(tag, time, record)
|
119
124
|
end
|
120
125
|
|
126
|
+
def on_transport_error(transport)
|
127
|
+
raise "Connection error: #{transport.condition}"
|
128
|
+
end
|
129
|
+
|
121
130
|
def on_disconnect event
|
122
131
|
puts "FIMXE #{NAME}: disconnected, re-connecting"
|
123
132
|
end
|