eventq_rabbitmq 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eventq_rabbitmq/rabbitmq_queue_worker.rb +41 -28
- data/lib/eventq_rabbitmq/version.rb +1 -1
- 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: 96c30cb1ae498d1150a5117aa1e64c05dd5570ad
|
4
|
+
data.tar.gz: 26ce2d3f2bac930f75222036615dd0fecf2ed6bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c1d737de716bb6a2ab5bd2fd97d098c97df2fa17f8c5c137248d21efd33173055bbdc36b0c1cf798e16186b3a677e5e33922757efbb9aab5c69de124ca64c1
|
7
|
+
data.tar.gz: 145c03a98b3cbac3804c3102002c0248ccc5bc2a6b9940af71bc760b41327627b4ff41672d6c55bec7e4b7aa4cb3593fa6ee8ccaf92fdbafd38ec12be2fe1f4a
|
@@ -128,42 +128,20 @@ module EventQ
|
|
128
128
|
|
129
129
|
received = false
|
130
130
|
error = false
|
131
|
-
abort = false
|
132
131
|
|
133
132
|
begin
|
134
133
|
delivery_info, properties, payload = q.pop(:manual_ack => true, :block => true)
|
135
134
|
|
136
135
|
#check that message was received
|
137
136
|
if payload != nil
|
138
|
-
tag_processing_thread
|
139
|
-
|
140
|
-
message = deserialize_message(payload)
|
141
|
-
|
142
|
-
EventQ.log(:debug, "[#{self.class}] - Message received. Retry Attempts: #{message.retry_attempts}")
|
143
|
-
|
144
|
-
message_args = EventQ::MessageArgs.new(message.type, message.retry_attempts)
|
145
|
-
|
146
|
-
#begin worker block for queue message
|
147
137
|
begin
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
EventQ.log(:info, "[#{self.class}] - Message aborted.")
|
153
|
-
else
|
154
|
-
#accept the message as processed
|
155
|
-
channel.acknowledge(delivery_info.delivery_tag, false)
|
156
|
-
EventQ.log(:info, "[#{self.class}] - Message acknowledged.")
|
157
|
-
received = true
|
138
|
+
tag_processing_thread
|
139
|
+
process_message(payload, queue, channel, retry_exchange, delivery_info, block) do |received, error|
|
140
|
+
received = received
|
141
|
+
error = error
|
158
142
|
end
|
159
|
-
|
160
|
-
|
161
|
-
EventQ.log(:error, "[#{self.class}] - An unhandled error happened attempting to process a queue message. Error: #{e} | Backtrace: #{e.backtrace}")
|
162
|
-
error = true
|
163
|
-
end
|
164
|
-
|
165
|
-
if error || abort
|
166
|
-
reject_message(channel, message, delivery_info, retry_exchange, queue)
|
143
|
+
ensure
|
144
|
+
untag_processing_thread
|
167
145
|
end
|
168
146
|
|
169
147
|
end
|
@@ -284,6 +262,41 @@ module EventQ
|
|
284
262
|
|
285
263
|
end
|
286
264
|
|
265
|
+
private
|
266
|
+
|
267
|
+
def process_message(payload, queue, channel, retry_exchange, delivery_info, block)
|
268
|
+
abort = false
|
269
|
+
message = deserialize_message(payload)
|
270
|
+
|
271
|
+
EventQ.log(:debug, "[#{self.class}] - Message received. Retry Attempts: #{message.retry_attempts}")
|
272
|
+
|
273
|
+
message_args = EventQ::MessageArgs.new(message.type, message.retry_attempts)
|
274
|
+
|
275
|
+
#begin worker block for queue message
|
276
|
+
begin
|
277
|
+
block.call(message.content, message_args)
|
278
|
+
|
279
|
+
if message_args.abort == true
|
280
|
+
abort = true
|
281
|
+
EventQ.log(:info, "[#{self.class}] - Message aborted.")
|
282
|
+
else
|
283
|
+
#accept the message as processed
|
284
|
+
channel.acknowledge(delivery_info.delivery_tag, false)
|
285
|
+
EventQ.log(:info, "[#{self.class}] - Message acknowledged.")
|
286
|
+
received = true
|
287
|
+
end
|
288
|
+
|
289
|
+
rescue => e
|
290
|
+
EventQ.log(:error, "[#{self.class}] - An unhandled error happened attempting to process a queue message. Error: #{e} | Backtrace: #{e.backtrace}")
|
291
|
+
error = true
|
292
|
+
end
|
293
|
+
|
294
|
+
if error || abort
|
295
|
+
reject_message(channel, message, delivery_info, retry_exchange, queue)
|
296
|
+
end
|
297
|
+
|
298
|
+
yield [received, error]
|
299
|
+
end
|
287
300
|
end
|
288
301
|
end
|
289
302
|
end
|