jruby-jms 1.1.0-java → 1.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +24 -7
- data/README.md +49 -49
- data/Rakefile +17 -12
- data/lib/jms.rb +8 -17
- data/lib/jms/bytes_message.rb +3 -19
- data/lib/jms/connection.rb +63 -83
- data/lib/jms/map_message.rb +9 -25
- data/lib/jms/message.rb +22 -173
- data/lib/jms/message_consumer.rb +23 -35
- data/lib/jms/message_listener_impl.rb +22 -38
- data/lib/jms/message_producer.rb +9 -25
- data/lib/jms/mq_workaround.rb +11 -26
- data/lib/jms/object_message.rb +1 -17
- data/lib/jms/oracle_a_q_connection_factory.rb +4 -21
- data/lib/jms/queue_browser.rb +2 -18
- data/lib/jms/session.rb +92 -106
- data/lib/jms/session_pool.rb +34 -41
- data/lib/jms/text_message.rb +0 -16
- data/lib/jms/version.rb +1 -1
- data/test/connection_test.rb +35 -81
- data/test/jms.yml +18 -8
- data/test/message_test.rb +27 -43
- data/test/session_pool_test.rb +30 -46
- data/test/session_test.rb +30 -45
- data/test/test_helper.rb +33 -0
- metadata +20 -26
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -36
- data/examples/advanced/session_pool.rb +0 -37
- data/examples/client-server/replier.rb +0 -29
- data/examples/client-server/requestor.rb +0 -40
- data/examples/file-to-q/files_to_q.rb +0 -51
- data/examples/file-to-q/q_to_files.rb +0 -44
- data/examples/invm/invm.rb +0 -44
- data/examples/invm/log4j.properties +0 -58
- data/examples/jms.yml +0 -149
- data/examples/performance/consumer.rb +0 -25
- data/examples/performance/producer.rb +0 -31
- data/examples/producer-consumer/browser.rb +0 -24
- data/examples/producer-consumer/consumer.rb +0 -24
- data/examples/producer-consumer/consumer_async.rb +0 -41
- data/examples/producer-consumer/producer.rb +0 -25
- data/examples/publish-subscribe/publish.rb +0 -24
- data/examples/publish-subscribe/subscribe.rb +0 -31
- data/lib/jms/logging.rb +0 -50
- data/nbproject/private/private.properties +0 -3
- data/nbproject/private/rake-d.txt +0 -5
- data/parallel_minion.gemspec +0 -21
data/lib/jms/map_message.rb
CHANGED
@@ -1,20 +1,4 @@
|
|
1
|
-
|
2
|
-
# Copyright 2008, 2009, 2010, 2011 J. Reid Morrison
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
################################################################################
|
16
|
-
|
17
|
-
#Interface javax.jms.MapMessage
|
1
|
+
# Interface javax.jms.MapMessage
|
18
2
|
module JMS::MapMessage
|
19
3
|
# Since each is defined, add support for: inject, map, include?, and find_all?
|
20
4
|
# <=> also allows support for: min, max, and sort
|
@@ -23,7 +7,7 @@ module JMS::MapMessage
|
|
23
7
|
# Return Map Message as a hash
|
24
8
|
def to_h
|
25
9
|
h = {}
|
26
|
-
each_pair {|key, value| h[key] = value}
|
10
|
+
each_pair { |key, value| h[key] = value }
|
27
11
|
h
|
28
12
|
end
|
29
13
|
|
@@ -42,20 +26,20 @@ module JMS::MapMessage
|
|
42
26
|
# nil => null
|
43
27
|
# Otherwise it calls ::to_s on the supplied data type
|
44
28
|
def data=(data)
|
45
|
-
data.each_pair do |key,val|
|
29
|
+
data.each_pair do |key, val|
|
46
30
|
case
|
47
31
|
when val.class == Fixnum # 1
|
48
|
-
setLong(key.to_s,val)
|
32
|
+
setLong(key.to_s, val)
|
49
33
|
when val.class == Float #1.1
|
50
|
-
setDouble(key.to_s,val)
|
34
|
+
setDouble(key.to_s, val)
|
51
35
|
when val.class == Bignum # 11111111111111111
|
52
|
-
setLong(key.to_s,val)
|
36
|
+
setLong(key.to_s, val)
|
53
37
|
when (val.class == TrueClass) || (val.class == FalseClass)
|
54
|
-
setBoolean(key.to_s,val)
|
38
|
+
setBoolean(key.to_s, val)
|
55
39
|
when val.class == NilClass
|
56
|
-
setObject(key.to_s,val)
|
40
|
+
setObject(key.to_s, val)
|
57
41
|
else
|
58
|
-
setString(key.to_s,val.to_s)
|
42
|
+
setString(key.to_s, val.to_s)
|
59
43
|
end
|
60
44
|
end
|
61
45
|
end
|
data/lib/jms/message.rb
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Copyright 2008, 2009, 2010, 2011 J. Reid Morrison
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
################################################################################
|
16
|
-
|
17
1
|
# Extend JMS Message Interface with Ruby methods
|
18
2
|
#
|
19
3
|
# A Message is the item that can be put on a queue, or obtained from a queue.
|
@@ -54,142 +38,6 @@ module JMS::Message
|
|
54
38
|
# Clears out the properties of this message
|
55
39
|
#
|
56
40
|
|
57
|
-
# For Backward compatibility with JRuby prior to 1.6
|
58
|
-
# JRuby 1.6 now does all this for us. Thank you headius :)
|
59
|
-
unless self.instance_methods.include? :jms_delivery_mode
|
60
|
-
|
61
|
-
# Header Fields - Attributes of the message
|
62
|
-
|
63
|
-
# Returns the JMS Delivery Mode
|
64
|
-
# One of the following will be returned
|
65
|
-
# JMS::DeliveryMode::PERSISTENT
|
66
|
-
# JMS::DeliveryMode::NON_PERSISTENT
|
67
|
-
def jms_delivery_mode
|
68
|
-
getJMSDeliveryMode
|
69
|
-
end
|
70
|
-
|
71
|
-
# Set the JMS Delivery Mode
|
72
|
-
# Values can be
|
73
|
-
# JMS::DeliveryMode::PERSISTENT
|
74
|
-
# JMS::DeliveryMode::NON_PERSISTENT
|
75
|
-
def jms_delivery_mode=(mode)
|
76
|
-
raise "Sorry, due to incompatibility with JRuby 1.6, please call jms_delivery_mode_sym when using symbols" if mode.is_a? Symbol
|
77
|
-
self.setJMSDeliveryMode(mode)
|
78
|
-
end
|
79
|
-
|
80
|
-
# Is the message persistent?
|
81
|
-
def persistent?
|
82
|
-
getJMSDeliveryMode == JMS::DeliveryMode::PERSISTENT
|
83
|
-
end
|
84
|
-
|
85
|
-
# Returns the Message correlation ID as a String
|
86
|
-
# The resulting string may contain nulls
|
87
|
-
def jms_correlation_id
|
88
|
-
String.from_java_bytes(getJMSCorrelationIDAsBytes) if getJMSCorrelationIDAsBytes
|
89
|
-
end
|
90
|
-
|
91
|
-
# Set the Message correlation ID
|
92
|
-
# correlation_id: String
|
93
|
-
# Also supports embedded nulls within the correlation id
|
94
|
-
def jms_correlation_id=(correlation_id)
|
95
|
-
setJMSCorrelationIDAsBytes(correlation_id.nil? ? nil : correlation_id.to_java_bytes)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Returns the Message Destination
|
99
|
-
# Instance of JMS::Destination
|
100
|
-
def jms_destination
|
101
|
-
getJMSDestination
|
102
|
-
end
|
103
|
-
|
104
|
-
# Set the Message Destination
|
105
|
-
# jms_destination: Must be an instance of JMS::Destination
|
106
|
-
def jms_destination=(destination)
|
107
|
-
setJMSDestination(destination)
|
108
|
-
end
|
109
|
-
|
110
|
-
# Return the message expiration value as an Integer
|
111
|
-
def jms_expiration
|
112
|
-
getJMSExpiration
|
113
|
-
end
|
114
|
-
|
115
|
-
# Set the Message expiration value
|
116
|
-
# expiration: Integer
|
117
|
-
def jms_expiration=(expiration)
|
118
|
-
setJMSExpiration(expiration)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Returns the Message ID as a String
|
122
|
-
# The resulting string may contain embedded nulls
|
123
|
-
def jms_message_id
|
124
|
-
getJMSMessageID
|
125
|
-
end
|
126
|
-
|
127
|
-
# Set the Message correlation ID
|
128
|
-
# message_id: String
|
129
|
-
# Also supports nulls within the message id
|
130
|
-
def jms_message_id=(message_id)
|
131
|
-
setJMSMessageID(message_id)
|
132
|
-
end
|
133
|
-
|
134
|
-
# Returns the Message Priority level as an Integer
|
135
|
-
def jms_priority
|
136
|
-
getJMSPriority
|
137
|
-
end
|
138
|
-
|
139
|
-
# Set the Message priority level
|
140
|
-
# priority: Integer
|
141
|
-
def jms_priority=(priority)
|
142
|
-
setJMSPriority(priority)
|
143
|
-
end
|
144
|
-
|
145
|
-
# Indicates whether the Message was redelivered?
|
146
|
-
def jms_redelivered?
|
147
|
-
getJMSRedelivered
|
148
|
-
end
|
149
|
-
|
150
|
-
# Set whether the Message was redelivered
|
151
|
-
# bool: Boolean
|
152
|
-
def jms_redelivered=(bool)
|
153
|
-
setJMSPriority(bool)
|
154
|
-
end
|
155
|
-
|
156
|
-
# Returns the Message reply to Destination
|
157
|
-
# Instance of JMS::Destination
|
158
|
-
def jms_reply_to
|
159
|
-
getJMSReplyTo
|
160
|
-
end
|
161
|
-
|
162
|
-
# Set the Message reply to Destination
|
163
|
-
# reply_to: Must be an instance of JMS::Destination
|
164
|
-
def jms_reply_to=(reply_to)
|
165
|
-
setJMSReplyTo(reply_to)
|
166
|
-
end
|
167
|
-
|
168
|
-
# Returns the Message timestamp as Java Timestamp Integer
|
169
|
-
#TODO Return Ruby Time object?
|
170
|
-
def jms_timestamp
|
171
|
-
getJMSTimestamp
|
172
|
-
end
|
173
|
-
|
174
|
-
# Set the Message timestamp as Java Timestamp Integer
|
175
|
-
# timestamp: Must be an Java Timestamp Integer
|
176
|
-
#TODO Support Ruby Time
|
177
|
-
def jms_timestamp=(timestamp)
|
178
|
-
setJMSTimestamp(timestamp)
|
179
|
-
end
|
180
|
-
|
181
|
-
# Returns the Message type supplied by the client when the message was sent
|
182
|
-
def jms_type
|
183
|
-
getJMSType
|
184
|
-
end
|
185
|
-
|
186
|
-
# Sets the Message type
|
187
|
-
# type: String
|
188
|
-
def jms_type=(type)
|
189
|
-
setJMSType(type)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
41
|
# Return the JMS Delivery Mode as a Ruby symbol
|
194
42
|
# :persistent
|
195
43
|
# :non_persistent
|
@@ -210,30 +58,31 @@ module JMS::Message
|
|
210
58
|
# :persistent
|
211
59
|
# :non_persistent
|
212
60
|
def jms_delivery_mode_sym=(mode)
|
213
|
-
val =
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
61
|
+
val =
|
62
|
+
case mode
|
63
|
+
when :persistent
|
64
|
+
JMS::DeliveryMode::PERSISTENT
|
65
|
+
when :non_persistent
|
66
|
+
JMS::DeliveryMode::NON_PERSISTENT
|
67
|
+
else
|
68
|
+
raise "Unknown delivery mode symbol: #{mode}"
|
69
|
+
end
|
221
70
|
self.setJMSDeliveryMode(val)
|
222
71
|
end
|
223
72
|
|
224
73
|
# Return the attributes (header fields) of the message as a Hash
|
225
74
|
def attributes
|
226
75
|
{
|
227
|
-
:jms_correlation_id
|
228
|
-
:
|
229
|
-
:jms_destination
|
230
|
-
:jms_expiration
|
231
|
-
:jms_message_id
|
232
|
-
:jms_priority
|
233
|
-
:jms_redelivered
|
234
|
-
:jms_reply_to
|
235
|
-
:jms_timestamp
|
236
|
-
:jms_type
|
76
|
+
jms_correlation_id: jms_correlation_id,
|
77
|
+
jms_delivery_mode_sym: jms_delivery_mode_sym,
|
78
|
+
jms_destination: jms_destination.nil? ? nil : jms_destination.to_string,
|
79
|
+
jms_expiration: jms_expiration,
|
80
|
+
jms_message_id: jms_message_id,
|
81
|
+
jms_priority: jms_priority,
|
82
|
+
jms_redelivered: jms_redelivered?,
|
83
|
+
jms_reply_to: jms_reply_to,
|
84
|
+
jms_timestamp: jms_timestamp,
|
85
|
+
jms_type: jms_type,
|
237
86
|
}
|
238
87
|
end
|
239
88
|
|
@@ -258,14 +107,14 @@ module JMS::Message
|
|
258
107
|
# Return Properties as a hash
|
259
108
|
def properties
|
260
109
|
h = {}
|
261
|
-
properties_each_pair {|k,v| h[k]=v}
|
110
|
+
properties_each_pair { |k, v| h[k]=v }
|
262
111
|
h
|
263
112
|
end
|
264
113
|
|
265
114
|
# Set Properties from an existing hash
|
266
115
|
def properties=(h)
|
267
116
|
clear_properties
|
268
|
-
h.each_pair {|k,v| setObjectProperty(k.to_s, v)}
|
117
|
+
h.each_pair { |k, v| setObjectProperty(k.to_s, v) }
|
269
118
|
h
|
270
119
|
end
|
271
120
|
|
@@ -282,4 +131,4 @@ module JMS::Message
|
|
282
131
|
"#{self.class.name}: #{data}\nAttributes: #{attributes.inspect}\nProperties: #{properties.inspect}"
|
283
132
|
end
|
284
133
|
|
285
|
-
end
|
134
|
+
end
|
data/lib/jms/message_consumer.rb
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Copyright 2008, 2009, 2010, 2011 J. Reid Morrison
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
################################################################################
|
16
|
-
|
17
1
|
# Interface javax.jms.MessageConsumer
|
18
2
|
module JMS::MessageConsumer
|
19
3
|
# Obtain a message from the Destination or Topic
|
@@ -36,8 +20,8 @@ module JMS::MessageConsumer
|
|
36
20
|
end
|
37
21
|
end
|
38
22
|
|
39
|
-
# For each message available to be consumed call the
|
40
|
-
# Returns the statistics gathered when :
|
23
|
+
# For each message available to be consumed call the supplied block
|
24
|
+
# Returns the statistics gathered when statistics: true, otherwise nil
|
41
25
|
#
|
42
26
|
# Parameters:
|
43
27
|
# :timeout How to timeout waiting for messages on the Queue or Topic
|
@@ -52,32 +36,33 @@ module JMS::MessageConsumer
|
|
52
36
|
# true : This method will capture statistics on the number of messages received
|
53
37
|
# and the time it took to process them.
|
54
38
|
# The statistics can be reset by calling MessageConsumer::each again
|
55
|
-
# with :
|
39
|
+
# with statistics: true
|
56
40
|
#
|
57
|
-
# The statistics gathered are returned when :
|
58
|
-
def each(params={}, &
|
59
|
-
raise
|
41
|
+
# The statistics gathered are returned when statistics: true and async: false
|
42
|
+
def each(params={}, &block)
|
43
|
+
raise(ArgumentError, 'Destination::each requires a code block to be executed for each message received') unless block
|
60
44
|
|
61
45
|
message_count = nil
|
62
|
-
start_time
|
46
|
+
start_time = nil
|
63
47
|
|
64
48
|
if params[:statistics]
|
65
49
|
message_count = 0
|
66
|
-
start_time
|
50
|
+
start_time = Time.now
|
67
51
|
end
|
68
52
|
|
69
53
|
# Receive messages according to timeout
|
70
54
|
while message = self.get(params) do
|
71
|
-
|
55
|
+
block.call(message)
|
72
56
|
message_count += 1 if message_count
|
73
57
|
end
|
74
58
|
|
75
59
|
unless message_count.nil?
|
76
60
|
duration = Time.now - start_time
|
77
|
-
{
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
61
|
+
{
|
62
|
+
messages: message_count,
|
63
|
+
duration: duration,
|
64
|
+
messages_per_second: duration > 0 ? (message_count/duration).to_i : 0,
|
65
|
+
ms_per_msg: message_count > 0 ? (duration*1000.0)/message_count : 0
|
81
66
|
}
|
82
67
|
end
|
83
68
|
end
|
@@ -96,21 +81,24 @@ module JMS::MessageConsumer
|
|
96
81
|
# or when Destination::statistics is called. In this case MessageConsumer::statistics
|
97
82
|
# can be called several times during processing without affecting the end time.
|
98
83
|
# Also, the start time and message count is not reset until MessageConsumer::each
|
99
|
-
# is called again with :
|
84
|
+
# is called again with statistics: true
|
100
85
|
#
|
101
|
-
# The statistics gathered are returned when :
|
86
|
+
# The statistics gathered are returned when statistics: true and async: false
|
102
87
|
#
|
103
88
|
def on_message(params={}, &proc)
|
104
|
-
raise
|
89
|
+
raise(ArgumentError, 'MessageConsumer::on_message requires a code block to be executed for each message received') unless proc
|
90
|
+
|
91
|
+
# Turn on Java class persistence: https://github.com/jruby/jruby/wiki/Persistence
|
92
|
+
self.class.__persistent__ = true
|
105
93
|
|
106
|
-
@listener = JMS::MessageListenerImpl.new(params
|
107
|
-
self.setMessageListener
|
94
|
+
@listener = JMS::MessageListenerImpl.new(params, &proc)
|
95
|
+
self.setMessageListener(@listener)
|
108
96
|
end
|
109
97
|
|
110
98
|
# Return the current statistics for a running MessageConsumer::on_message
|
111
99
|
def on_message_statistics
|
112
100
|
stats = @listener.statistics if @listener
|
113
|
-
raise
|
101
|
+
raise(ArgumentError, 'First call MessageConsumer::on_message with statistics: true before calling MessageConsumer::statistics()') unless stats
|
114
102
|
stats
|
115
103
|
end
|
116
104
|
|
@@ -1,25 +1,11 @@
|
|
1
|
-
################################################################################
|
2
|
-
# Copyright 2008, 2009, 2010, 2011 J. Reid Morrison
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
################################################################################
|
16
|
-
|
17
1
|
module JMS
|
18
2
|
|
19
3
|
private
|
4
|
+
|
20
5
|
# For internal use only by JMS::Connection
|
21
6
|
class MessageListenerImpl
|
22
7
|
include JMS::MessageListener
|
8
|
+
include SemanticLogger::Loggable
|
23
9
|
|
24
10
|
# Parameters:
|
25
11
|
# :statistics Capture statistics on how many messages have been read
|
@@ -29,15 +15,15 @@ module JMS
|
|
29
15
|
# or when Destination::statistics is called. In this case MessageConsumer::statistics
|
30
16
|
# can be called several times during processing without affecting the end time.
|
31
17
|
# Also, the start time and message count is not reset until MessageConsumer::each
|
32
|
-
# is called again with :
|
18
|
+
# is called again with statistics: true
|
33
19
|
#
|
34
|
-
# The statistics gathered are returned when :
|
20
|
+
# The statistics gathered are returned when statistics: true and async: false
|
35
21
|
def initialize(params={}, &proc)
|
36
22
|
@proc = proc
|
37
23
|
|
38
24
|
if params[:statistics]
|
39
25
|
@message_count = 0
|
40
|
-
@start_time
|
26
|
+
@start_time = Time.now
|
41
27
|
end
|
42
28
|
end
|
43
29
|
|
@@ -49,31 +35,29 @@ module JMS
|
|
49
35
|
begin
|
50
36
|
if @message_count
|
51
37
|
@message_count += 1
|
52
|
-
@last_time
|
38
|
+
@last_time = Time.now
|
39
|
+
end
|
40
|
+
logger.benchmark_debug('Message processed') do
|
41
|
+
@proc.call message
|
53
42
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
JMS::logger.error "Unhandled Exception processing JMS Message. Doesn't compile: " + bang
|
61
|
-
JMS::logger.error "Ignoring poison message:\n#{message.inspect}"
|
62
|
-
JMS::logger.error bang.backtrace.join("\n")
|
63
|
-
rescue => exc
|
64
|
-
JMS::logger.error "Unhandled Exception processing JMS Message. Exception occurred:\n#{exc}"
|
65
|
-
JMS::logger.error "Ignoring poison message:\n#{message.inspect}"
|
66
|
-
JMS::logger.error exc.backtrace.join("\n")
|
43
|
+
rescue SyntaxError, NameError => exc
|
44
|
+
logger.error "Ignoring poison message:\n#{message.inspect}", exc
|
45
|
+
rescue StandardError => exc
|
46
|
+
logger.error "Ignoring poison message:\n#{message.inspect}", exc
|
47
|
+
rescue Exception => exc
|
48
|
+
logger.error "Ignoring poison message:\n#{message.inspect}", exc
|
67
49
|
end
|
68
50
|
end
|
69
51
|
|
70
52
|
# Return Statistics gathered for this listener
|
71
53
|
def statistics
|
72
|
-
raise
|
73
|
-
duration =(@last_time || Time.now) - @start_time
|
74
|
-
{
|
75
|
-
:
|
76
|
-
:
|
54
|
+
raise(ArgumentError, 'First call MessageConsumer::on_message with statistics: true before calling MessageConsumer::statistics()') unless @message_count
|
55
|
+
duration = (@last_time || Time.now) - @start_time
|
56
|
+
{
|
57
|
+
messages: @message_count,
|
58
|
+
duration: duration,
|
59
|
+
messages_per_second: (@message_count/duration).to_i
|
60
|
+
}
|
77
61
|
end
|
78
62
|
end
|
79
63
|
end
|