eventq_rabbitmq 1.14.1 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff2c405a89063fc287c9786d515af313b0384121
|
4
|
+
data.tar.gz: b3931296591bbc43c9eca5de61179d7307084f62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5f6294cb4a4c2b25f1256ed9c8c45b5fd50bb951d0e09ad9d93b3a5a7158fbc0960693adb002f9c46c7fe0c39755f2cd83cb750f58f7ad1bcf697c2b68bde4a
|
7
|
+
data.tar.gz: 93c89113d36f8de45c0f6ab53c5541c07b18aeb76ae15e6028a4401770de993dad90abfd561d8589bf92d5588b7988792658868b6aa782c907253e893382f3d5
|
@@ -33,7 +33,11 @@ module EventQ
|
|
33
33
|
true
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def publish(topic:, event:, context: {})
|
37
|
+
raise_event(topic, event, context)
|
38
|
+
end
|
39
|
+
|
40
|
+
def raise_event(event_type, event, context = {})
|
37
41
|
register_event(event_type)
|
38
42
|
|
39
43
|
_event_type = EventQ.create_event_type(event_type)
|
@@ -41,7 +45,7 @@ module EventQ
|
|
41
45
|
with_connection do |channel|
|
42
46
|
exchange = @queue_manager.get_exchange(channel, @event_raised_exchange)
|
43
47
|
|
44
|
-
message = serialized_message(_event_type, event)
|
48
|
+
message = serialized_message(_event_type, event, context)
|
45
49
|
|
46
50
|
exchange.publish(message, routing_key: _event_type)
|
47
51
|
|
@@ -51,7 +55,7 @@ module EventQ
|
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
|
-
def raise_event_in_queue(event_type, event, queue, delay)
|
58
|
+
def raise_event_in_queue(event_type, event, queue, delay, context = {})
|
55
59
|
register_event(event_type)
|
56
60
|
|
57
61
|
_event_type = EventQ.create_event_type(event_type)
|
@@ -69,7 +73,7 @@ module EventQ
|
|
69
73
|
q = channel.queue(_queue_name, durable: @queue_manager.durable)
|
70
74
|
q.bind(exchange, routing_key: _event_type)
|
71
75
|
|
72
|
-
message = serialized_message(_event_type, event)
|
76
|
+
message = serialized_message(_event_type, event, context)
|
73
77
|
|
74
78
|
delay_exchange.publish(message, routing_key: _event_type)
|
75
79
|
|
@@ -101,10 +105,11 @@ module EventQ
|
|
101
105
|
true
|
102
106
|
end
|
103
107
|
|
104
|
-
def serialized_message(event_type, event)
|
108
|
+
def serialized_message(event_type, event, context)
|
105
109
|
qm = new_message
|
106
110
|
qm.content = event
|
107
111
|
qm.type = event_type
|
112
|
+
qm.context = context
|
108
113
|
|
109
114
|
if EventQ::Configuration.signature_secret != nil
|
110
115
|
provider = @signature_manager.get_provider(EventQ::Configuration.signature_provider)
|
@@ -59,13 +59,13 @@ module EventQ
|
|
59
59
|
|
60
60
|
if queue.allow_retry_back_off == true
|
61
61
|
|
62
|
-
EventQ.
|
62
|
+
EventQ.logger.debug { "[#{self.class}] - Requesting retry queue. x-dead-letter-exchange: #{subscriber_exchange.name} | x-message-ttl: #{queue.max_retry_delay}" }
|
63
63
|
|
64
64
|
return channel.queue("#{_queue_name}.r", :durable => @durable, :arguments => { X_DEAD_LETTER_EXCHANGE => subscriber_exchange.name, X_MESSAGE_TTL => queue.max_retry_delay })
|
65
65
|
|
66
66
|
else
|
67
67
|
|
68
|
-
EventQ.
|
68
|
+
EventQ.logger.debug { "[#{self.class}] - Requesting retry queue. x-dead-letter-exchange: #{subscriber_exchange.name} | x-message-ttl: #{queue.retry_delay}" }
|
69
69
|
|
70
70
|
return channel.queue("#{_queue_name}.r", :durable => @durable, :arguments => { X_DEAD_LETTER_EXCHANGE => subscriber_exchange.name, X_MESSAGE_TTL => queue.retry_delay })
|
71
71
|
|
@@ -22,7 +22,7 @@ module EventQ
|
|
22
22
|
|
23
23
|
def start(queue, options = {}, &block)
|
24
24
|
|
25
|
-
EventQ.
|
25
|
+
EventQ.logger.info("[#{self.class}] - Preparing to start listening for messages.")
|
26
26
|
|
27
27
|
configure(queue, options)
|
28
28
|
|
@@ -32,7 +32,7 @@ module EventQ
|
|
32
32
|
raise "[#{self.class}] - :client (QueueClient) must be specified."
|
33
33
|
end
|
34
34
|
|
35
|
-
EventQ.
|
35
|
+
EventQ.logger.info("[#{self.class}] - Listening for messages.")
|
36
36
|
EventQ.logger.debug do
|
37
37
|
"[#{self.class} #start] - Listening for messages on queue: #{EventQ.create_queue_name(queue.name)}"
|
38
38
|
end
|
@@ -100,7 +100,7 @@ module EventQ
|
|
100
100
|
has_received_message = thread_process_iteration(channel, manager, queue, block)
|
101
101
|
|
102
102
|
rescue => e
|
103
|
-
EventQ.
|
103
|
+
EventQ.logger.error("An unhandled error occurred. Error: #{e} | Backtrace: #{e.backtrace}")
|
104
104
|
call_on_error_block(error: e)
|
105
105
|
end
|
106
106
|
|
@@ -111,9 +111,9 @@ module EventQ
|
|
111
111
|
gc_flush
|
112
112
|
|
113
113
|
if !has_received_message
|
114
|
-
EventQ.
|
114
|
+
EventQ.logger.debug { "[#{self.class}] - No message received." }
|
115
115
|
if @sleep > 0
|
116
|
-
EventQ.
|
116
|
+
EventQ.logger.debug { "[#{self.class}] - Sleeping for #{@sleep} seconds" }
|
117
117
|
sleep(@sleep)
|
118
118
|
end
|
119
119
|
end
|
@@ -136,14 +136,14 @@ module EventQ
|
|
136
136
|
|
137
137
|
def call_on_error_block(error:, message: nil)
|
138
138
|
if @on_error_block
|
139
|
-
EventQ.
|
139
|
+
EventQ.logger.debug { "[#{self.class}] - Executing on_error block." }
|
140
140
|
begin
|
141
141
|
@on_error_block.call(error, message)
|
142
142
|
rescue => e
|
143
|
-
EventQ.
|
143
|
+
EventQ.logger.error("[#{self.class}] - An error occurred executing the on_error block. Error: #{e}")
|
144
144
|
end
|
145
145
|
else
|
146
|
-
EventQ.
|
146
|
+
EventQ.logger.debug { "[#{self.class}] - No on_error block specified to execute." }
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -182,7 +182,7 @@ module EventQ
|
|
182
182
|
end
|
183
183
|
|
184
184
|
rescue => e
|
185
|
-
EventQ.
|
185
|
+
EventQ.logger.error("[#{self.class}] - An error occurred attempting to process a message. Error: #{e} | Backtrace: #{e.backtrace}")
|
186
186
|
call_on_error_block(error: e)
|
187
187
|
end
|
188
188
|
|
@@ -230,64 +230,64 @@ module EventQ
|
|
230
230
|
|
231
231
|
def call_on_retry_exceeded_block(message)
|
232
232
|
if @retry_exceeded_block != nil
|
233
|
-
EventQ.
|
233
|
+
EventQ.logger.debug { "[#{self.class}] - Executing on_retry_exceeded block." }
|
234
234
|
begin
|
235
235
|
@retry_exceeded_block.call(message)
|
236
236
|
rescue => e
|
237
|
-
EventQ.
|
237
|
+
EventQ.logger.error("[#{self.class}] - An error occurred executing the on_retry_exceeded block. Error: #{e}")
|
238
238
|
end
|
239
239
|
else
|
240
|
-
EventQ.
|
240
|
+
EventQ.logger.debug { "[#{self.class}] - No on_retry_exceeded block specified." }
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
244
|
def call_on_retry_block(message)
|
245
245
|
if @on_retry_block
|
246
|
-
EventQ.
|
246
|
+
EventQ.logger.debug { "[#{self.class}] - Executing on_retry block." }
|
247
247
|
begin
|
248
248
|
@on_retry_block.call(message, abort)
|
249
249
|
rescue => e
|
250
|
-
EventQ.
|
250
|
+
EventQ.logger.error("[#{self.class}] - An error occurred executing the on_retry block. Error: #{e}")
|
251
251
|
end
|
252
252
|
else
|
253
|
-
EventQ.
|
253
|
+
EventQ.logger.debug { "[#{self.class}] - No on_retry block specified." }
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
257
|
def reject_message(channel, message, delivery_info, retry_exchange, queue, abort)
|
258
258
|
|
259
|
-
EventQ.
|
259
|
+
EventQ.logger.info("[#{self.class}] - Message rejected removing from queue.")
|
260
260
|
#reject the message to remove from queue
|
261
261
|
channel.reject(delivery_info.delivery_tag, false)
|
262
262
|
|
263
263
|
#check if the message retry limit has been exceeded
|
264
264
|
if message.retry_attempts >= queue.max_retry_attempts
|
265
265
|
|
266
|
-
EventQ.
|
266
|
+
EventQ.logger.info("[#{self.class}] - Message retry attempt limit exceeded. Msg: #{serialize_message(message)}")
|
267
267
|
|
268
268
|
call_on_retry_exceeded_block(message)
|
269
269
|
|
270
270
|
#check if the message is allowed to be retried
|
271
271
|
elsif queue.allow_retry
|
272
272
|
|
273
|
-
EventQ.
|
273
|
+
EventQ.logger.debug { "[#{self.class}] - Incrementing retry attempts count." }
|
274
274
|
message.retry_attempts += 1
|
275
275
|
|
276
276
|
if queue.allow_retry_back_off == true
|
277
|
-
EventQ.
|
277
|
+
EventQ.logger.debug { "[#{self.class}] - Calculating message back off retry delay. Attempts: #{message.retry_attempts} * Retry Delay: #{queue.retry_delay}" }
|
278
278
|
message_ttl = message.retry_attempts * queue.retry_delay
|
279
279
|
if (message.retry_attempts * queue.retry_delay) > queue.max_retry_delay
|
280
|
-
EventQ.
|
280
|
+
EventQ.logger.debug { "[#{self.class}] - Max message back off retry delay reached." }
|
281
281
|
message_ttl = queue.max_retry_delay
|
282
282
|
end
|
283
283
|
else
|
284
|
-
EventQ.
|
284
|
+
EventQ.logger.debug { "[#{self.class}] - Setting fixed retry delay for message." }
|
285
285
|
message_ttl = queue.retry_delay
|
286
286
|
end
|
287
287
|
|
288
|
-
EventQ.
|
288
|
+
EventQ.logger.debug { "[#{self.class}] - Sending message for retry. Message TTL: #{message_ttl}" }
|
289
289
|
retry_exchange.publish(serialize_message(message), :expiration => message_ttl)
|
290
|
-
EventQ.
|
290
|
+
EventQ.logger.debug { "[#{self.class}] - Published message to retry exchange." }
|
291
291
|
|
292
292
|
call_on_retry_block(message)
|
293
293
|
|
@@ -323,7 +323,7 @@ module EventQ
|
|
323
323
|
@gc_flush_interval = options[:gc_flush_interval]
|
324
324
|
end
|
325
325
|
|
326
|
-
EventQ.
|
326
|
+
EventQ.logger.info("[#{self.class}] - Configuring. Process Count: #{@fork_count} | Thread Count: #{@thread_count} | Interval Sleep: #{@sleep}.")
|
327
327
|
|
328
328
|
return true
|
329
329
|
|
@@ -336,14 +336,14 @@ module EventQ
|
|
336
336
|
error = false
|
337
337
|
message = deserialize_message(payload)
|
338
338
|
|
339
|
-
EventQ.
|
339
|
+
EventQ.logger.info("[#{self.class}] - Message received. Retry Attempts: #{message.retry_attempts}")
|
340
340
|
|
341
341
|
@signature_provider_manager.validate_signature(message: message, queue: queue)
|
342
342
|
|
343
|
-
message_args = EventQ::MessageArgs.new(message.type, message.retry_attempts)
|
343
|
+
message_args = EventQ::MessageArgs.new(message.type, message.retry_attempts, message.context)
|
344
344
|
|
345
345
|
if(!EventQ::NonceManager.is_allowed?(message.id))
|
346
|
-
EventQ.
|
346
|
+
EventQ.logger.info("[#{self.class}] - Duplicate Message received. Dropping message.")
|
347
347
|
channel.acknowledge(delivery_info.delivery_tag, false)
|
348
348
|
return false
|
349
349
|
end
|
@@ -354,15 +354,15 @@ module EventQ
|
|
354
354
|
|
355
355
|
if message_args.abort == true
|
356
356
|
abort = true
|
357
|
-
EventQ.
|
357
|
+
EventQ.logger.info("[#{self.class}] - Message aborted.")
|
358
358
|
else
|
359
359
|
#accept the message as processed
|
360
360
|
channel.acknowledge(delivery_info.delivery_tag, false)
|
361
|
-
EventQ.
|
361
|
+
EventQ.logger.info("[#{self.class}] - Message acknowledged.")
|
362
362
|
end
|
363
363
|
|
364
364
|
rescue => e
|
365
|
-
EventQ.
|
365
|
+
EventQ.logger.error("[#{self.class}] - An unhandled error happened attempting to process a queue message. Error: #{e} | Backtrace: #{e.backtrace}")
|
366
366
|
error = true
|
367
367
|
call_on_error_block(error: e, message: message)
|
368
368
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventq_rabbitmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|