eventq_rabbitmq 1.3.0 → 1.4.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: c2f9d3d90c02d532c784c42bbca3bf36eba741d9
|
4
|
+
data.tar.gz: 981cd38e2de71431bb9a8a62295ac85fee2a1521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5555b42b898c01d1f7f2dd8719ace503d0b6440f3eecf9a953bd2cc3740a9b11b4e83eacd31594331173f52b9a855815860df42a3525d624abc1572cfdafc1
|
7
|
+
data.tar.gz: 00051d1cd3963a8ed9aee720c72946565fbdb3ea75cc208f10bd8115c4e1c487291e25535ace8f7e4f315aebb678e5b2dfbd0ffa316879494a5e45ab1d33a29c
|
@@ -34,7 +34,21 @@ module EventQ
|
|
34
34
|
|
35
35
|
def get_retry_queue(channel, queue)
|
36
36
|
subscriber_exchange = get_subscriber_exchange(channel, queue)
|
37
|
-
|
37
|
+
|
38
|
+
if queue.allow_retry_back_off == true
|
39
|
+
|
40
|
+
EventQ.log(:debug, "[#{self.class}] - Requesting retry queue. x-dead-letter-exchange: #{subscriber_exchange.name} | x-message-ttl: #{queue.max_retry_delay}")
|
41
|
+
|
42
|
+
return channel.queue("#{queue.name}.r", :durable => true, :arguments => { "x-dead-letter-exchange" => subscriber_exchange.name, "x-message-ttl" => queue.max_retry_delay })
|
43
|
+
|
44
|
+
else
|
45
|
+
|
46
|
+
EventQ.log(:debug, "[#{self.class}] - Requesting retry queue. x-dead-letter-exchange: #{subscriber_exchange.name} | x-message-ttl: #{queue.retry_delay}")
|
47
|
+
|
48
|
+
return channel.queue("#{queue.name}.r", :durable => true, :arguments => { "x-dead-letter-exchange" => subscriber_exchange.name, "x-message-ttl" => queue.retry_delay })
|
49
|
+
|
50
|
+
end
|
51
|
+
|
38
52
|
end
|
39
53
|
|
40
54
|
def get_exchange(channel, exchange)
|
@@ -13,7 +13,7 @@ module EventQ
|
|
13
13
|
|
14
14
|
def start(queue, options = {}, &block)
|
15
15
|
|
16
|
-
EventQ.
|
16
|
+
EventQ.log(:info, "[#{self.class}] - Preparing to start listening for messages.")
|
17
17
|
|
18
18
|
configure(queue, options)
|
19
19
|
|
@@ -23,7 +23,7 @@ module EventQ
|
|
23
23
|
raise ':client (QueueClient) must be specified.'
|
24
24
|
end
|
25
25
|
|
26
|
-
EventQ.
|
26
|
+
EventQ.log(:info, "[#{self.class}] - Listening for messages.")
|
27
27
|
|
28
28
|
@is_running = true
|
29
29
|
@threads = []
|
@@ -33,7 +33,7 @@ module EventQ
|
|
33
33
|
thr = Thread.new do
|
34
34
|
|
35
35
|
client = options[:client]
|
36
|
-
manager = QueueManager.new
|
36
|
+
manager = EventQ::RabbitMq::QueueManager.new
|
37
37
|
|
38
38
|
#begin the queue loop for this thread
|
39
39
|
while true do
|
@@ -61,7 +61,7 @@ module EventQ
|
|
61
61
|
|
62
62
|
message = Oj.load(payload)
|
63
63
|
|
64
|
-
EventQ.
|
64
|
+
EventQ.log(:debug, "[#{self.class}] - Message received. Retry Attempts: #{message.retry_attempts}")
|
65
65
|
|
66
66
|
message_args = EventQ::MessageArgs.new(message.type, message.retry_attempts)
|
67
67
|
|
@@ -71,16 +71,16 @@ module EventQ
|
|
71
71
|
|
72
72
|
if message_args.abort == true
|
73
73
|
abort = true
|
74
|
-
EventQ.
|
74
|
+
EventQ.log(:debug, "[#{self.class}] - Message aborted.")
|
75
75
|
else
|
76
76
|
#accept the message as processed
|
77
77
|
channel.acknowledge(delivery_info.delivery_tag, false)
|
78
|
-
EventQ.
|
78
|
+
EventQ.log(:debug, "[#{self.class}] - Message acknowledged.")
|
79
79
|
received = true
|
80
80
|
end
|
81
81
|
|
82
82
|
rescue => e
|
83
|
-
EventQ.
|
83
|
+
EventQ.log(:error, "[#{self.class}] - An unhandled error happened attempting to process a queue message. Error: #{e}")
|
84
84
|
|
85
85
|
error = true
|
86
86
|
|
@@ -93,14 +93,14 @@ module EventQ
|
|
93
93
|
end
|
94
94
|
|
95
95
|
rescue Timeout::Error
|
96
|
-
EventQ.
|
96
|
+
EventQ.log(:debug, "[#{self.class}] - Timeout occurred attempting to pop a message from the queue.")
|
97
97
|
end
|
98
98
|
|
99
99
|
channel.close
|
100
100
|
|
101
101
|
#check if any message was received
|
102
102
|
if !received && !error
|
103
|
-
EventQ.
|
103
|
+
EventQ.log(:debug, "[#{self.class}] - No message received. Sleeping for #{@sleep} seconds")
|
104
104
|
#no message received so sleep before attempting to pop another message from the queue
|
105
105
|
sleep(@sleep)
|
106
106
|
end
|
@@ -121,7 +121,7 @@ module EventQ
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def stop
|
124
|
-
EventQ.
|
124
|
+
EventQ.log(:info, "[#{self.class}] - Stopping.")
|
125
125
|
@is_running = false
|
126
126
|
@threads.each { |thr| thr.join }
|
127
127
|
return true
|
@@ -142,24 +142,44 @@ module EventQ
|
|
142
142
|
#reject the message to remove from queue
|
143
143
|
channel.reject(delivery_info.delivery_tag, false)
|
144
144
|
|
145
|
-
EventQ.
|
145
|
+
EventQ.log(:debug, "[#{self.class}] - Message rejected.")
|
146
146
|
|
147
147
|
#check if the message is allowed to be retried
|
148
148
|
if queue.allow_retry
|
149
149
|
|
150
|
-
EventQ.
|
150
|
+
EventQ.log(:debug, "[#{self.class}] - Checking retry attempts...")
|
151
151
|
|
152
152
|
if message.retry_attempts < queue.max_retry_attempts
|
153
|
-
EventQ.
|
153
|
+
EventQ.log(:debug, "[#{self.class}] - Incrementing retry attempts count.")
|
154
154
|
message.retry_attempts += 1
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
155
|
+
|
156
|
+
if queue.allow_retry_back_off == true
|
157
|
+
EventQ.log(:debug, "[#{self.class}] - Calculating message back off retry delay. Attempts: #{message.retry_attempts} * Retry Delay: #{queue.retry_delay}")
|
158
|
+
message_ttl = message.retry_attempts * queue.retry_delay
|
159
|
+
if (message.retry_attempts * queue.retry_delay) > queue.max_retry_delay
|
160
|
+
EventQ.log(:debug, "[#{self.class}] - Max message back off retry delay reached.")
|
161
|
+
message_ttl = queue.max_retry_delay
|
162
|
+
end
|
163
|
+
else
|
164
|
+
EventQ.log(:debug, "[#{self.class}] - Setting fixed retry delay for message.")
|
165
|
+
message_ttl = queue.retry_delay
|
166
|
+
end
|
167
|
+
|
168
|
+
EventQ.log(:debug, "[#{self.class}] - Sending message for retry. Message TTL: #{message_ttl}")
|
169
|
+
retry_exchange.publish(Oj.dump(message), :expiration => message_ttl)
|
170
|
+
EventQ.log(:debug, "[#{self.class}] - Published message to retry exchange.")
|
171
|
+
|
161
172
|
else
|
162
|
-
|
173
|
+
|
174
|
+
EventQ.log(:debug, "[#{self.class}] - Message retry attempts exceeded.")
|
175
|
+
|
176
|
+
if @retry_exceeded_block != nil
|
177
|
+
EventQ.log(:debug, "[#{self.class}] - Executing retry exceeded block.")
|
178
|
+
@retry_exceeded_block.call(message)
|
179
|
+
else
|
180
|
+
EventQ.log(:debug, "[#{self.class}] - No retry exceeded block specified.")
|
181
|
+
end
|
182
|
+
|
163
183
|
end
|
164
184
|
|
165
185
|
end
|
@@ -184,7 +204,7 @@ module EventQ
|
|
184
204
|
@sleep = options[:sleep]
|
185
205
|
end
|
186
206
|
|
187
|
-
EventQ.
|
207
|
+
EventQ.log(:info, "[#{self.class}] - Configuring. Thread Count: #{@thread_count} | Interval Sleep: #{@sleep}.")
|
188
208
|
|
189
209
|
return true
|
190
210
|
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|