eventq_rabbitmq 1.7.7 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/eventq_rabbitmq/rabbitmq_eventq_client.rb +5 -2
- data/lib/eventq_rabbitmq/rabbitmq_queue_client.rb +2 -8
- data/lib/eventq_rabbitmq/rabbitmq_queue_manager.rb +7 -4
- data/lib/eventq_rabbitmq/rabbitmq_queue_worker.rb +22 -12
- data/lib/eventq_rabbitmq/rabbitmq_subscription_manager.rb +5 -1
- 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: 24ca73a8f2f4c29c8e93d9f05c348cfa8ac67587
|
4
|
+
data.tar.gz: 7234f3f45f4649865bc7e14030c7ae605392b761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24bf7380a5624c8470ef4f673059bf60eead657a5268f8b35e535462cc22b4069947d8426572dffa867a390b8aa11ac50e2f92d94cffcfca8ca1ae2d845fbc55
|
7
|
+
data.tar.gz: c7492e0b142d96634b4badd3be7b3d9b6865e22964261e1843e1b95cb8f69a3f0010bbd0285840ba7c1716659f5e7278afd02d57cab9ac15c58d867a39680148
|
@@ -15,7 +15,10 @@ module EventQ
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def raise_event(event_type, event)
|
18
|
-
|
18
|
+
|
19
|
+
connection = @client.get_connection
|
20
|
+
channel = connection.create_channel
|
21
|
+
|
19
22
|
ex = @queue_manager.get_exchange(channel, @event_raised_exchange)
|
20
23
|
|
21
24
|
qm = EventQ::QueueMessage.new
|
@@ -28,7 +31,7 @@ module EventQ
|
|
28
31
|
|
29
32
|
ex.publish(message, :routing_key => event_type)
|
30
33
|
channel.close
|
31
|
-
|
34
|
+
connection.close
|
32
35
|
|
33
36
|
EventQ.logger.debug "[#{self.class}] - Raised event. Message: #{message} | Type: #{event_type}."
|
34
37
|
|
@@ -30,20 +30,14 @@ module EventQ
|
|
30
30
|
:pass => @password,
|
31
31
|
:ssl => @ssl,
|
32
32
|
:read_timeout => 2,
|
33
|
-
:heartbeat =>
|
34
|
-
:continuation_timeout =>
|
33
|
+
:heartbeat => 10,
|
34
|
+
:continuation_timeout => 1000,
|
35
35
|
:automatically_recover => true,
|
36
36
|
:network_recovery_interval => 1,
|
37
37
|
:recover_from_connection_close => true
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
-
def get_channel
|
42
|
-
conn = Bunny.new(connection_options)
|
43
|
-
conn.start
|
44
|
-
return conn.create_channel
|
45
|
-
end
|
46
|
-
|
47
41
|
def get_connection
|
48
42
|
conn = Bunny.new(connection_options)
|
49
43
|
conn.start
|
@@ -5,14 +5,17 @@ module EventQ
|
|
5
5
|
X_DEAD_LETTER_EXCHANGE = 'x-dead-letter-exchange'.freeze
|
6
6
|
X_MESSAGE_TTL = 'x-message-ttl'.freeze
|
7
7
|
|
8
|
+
attr_accessor :durable
|
9
|
+
|
8
10
|
def initialize
|
9
11
|
@event_raised_exchange = EventQ::EventRaisedExchange.new
|
12
|
+
@durable = true
|
10
13
|
end
|
11
14
|
|
12
15
|
def get_queue(channel, queue)
|
13
16
|
|
14
17
|
#get/create the queue
|
15
|
-
q = channel.queue(queue.name, :durable =>
|
18
|
+
q = channel.queue(queue.name, :durable => @durable)
|
16
19
|
|
17
20
|
if queue.allow_retry
|
18
21
|
retry_exchange = get_retry_exchange(channel, queue)
|
@@ -42,20 +45,20 @@ module EventQ
|
|
42
45
|
|
43
46
|
EventQ.log(:debug, "[#{self.class}] - Requesting retry queue. x-dead-letter-exchange: #{subscriber_exchange.name} | x-message-ttl: #{queue.max_retry_delay}")
|
44
47
|
|
45
|
-
return channel.queue("#{queue.name}.r", :durable =>
|
48
|
+
return channel.queue("#{queue.name}.r", :durable => @durable, :arguments => { X_DEAD_LETTER_EXCHANGE => subscriber_exchange.name, X_MESSAGE_TTL => queue.max_retry_delay })
|
46
49
|
|
47
50
|
else
|
48
51
|
|
49
52
|
EventQ.log(:debug, "[#{self.class}] - Requesting retry queue. x-dead-letter-exchange: #{subscriber_exchange.name} | x-message-ttl: #{queue.retry_delay}")
|
50
53
|
|
51
|
-
return channel.queue("#{queue.name}.r", :durable =>
|
54
|
+
return channel.queue("#{queue.name}.r", :durable => @durable, :arguments => { X_DEAD_LETTER_EXCHANGE => subscriber_exchange.name, X_MESSAGE_TTL => queue.retry_delay })
|
52
55
|
|
53
56
|
end
|
54
57
|
|
55
58
|
end
|
56
59
|
|
57
60
|
def get_exchange(channel, exchange)
|
58
|
-
return channel.direct(exchange.name, :durable =>
|
61
|
+
return channel.direct(exchange.name, :durable => @durable)
|
59
62
|
end
|
60
63
|
|
61
64
|
end
|
@@ -59,15 +59,22 @@ module EventQ
|
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
62
|
+
if !options.key?(:durable)
|
63
|
+
options[:durable] = true
|
64
|
+
end
|
65
|
+
|
66
|
+
client = options[:client]
|
67
|
+
manager = EventQ::RabbitMq::QueueManager.new
|
68
|
+
manager.durable = options[:durable]
|
69
|
+
|
70
|
+
connection = client.get_connection
|
71
|
+
|
62
72
|
@threads = []
|
63
73
|
|
64
74
|
#loop through each thread count
|
65
75
|
@thread_count.times do
|
66
76
|
thr = Thread.new do
|
67
77
|
|
68
|
-
client = options[:client]
|
69
|
-
manager = EventQ::RabbitMq::QueueManager.new
|
70
|
-
|
71
78
|
#begin the queue loop for this thread
|
72
79
|
while true do
|
73
80
|
|
@@ -77,9 +84,17 @@ module EventQ
|
|
77
84
|
end
|
78
85
|
|
79
86
|
begin
|
80
|
-
|
87
|
+
|
88
|
+
channel = connection.create_channel
|
89
|
+
|
90
|
+
thread_process_iteration(channel, manager, queue, block)
|
91
|
+
|
81
92
|
rescue => e
|
82
|
-
EventQ.logger.error "An unhandled error occurred attempting to communicate with
|
93
|
+
EventQ.logger.error "An unhandled error occurred attempting to communicate with RabbitMQ. Error: #{e} | Backtrace: #{e.backtrace}"
|
94
|
+
end
|
95
|
+
|
96
|
+
if channel != nil && channel.status != :closed
|
97
|
+
channel.close
|
83
98
|
end
|
84
99
|
|
85
100
|
end
|
@@ -91,16 +106,14 @@ module EventQ
|
|
91
106
|
|
92
107
|
if options.key?(:wait) && options[:wait] == true
|
93
108
|
@threads.each { |thr| thr.join }
|
109
|
+
connection.close
|
94
110
|
end
|
95
111
|
|
96
112
|
return true
|
97
113
|
|
98
114
|
end
|
99
115
|
|
100
|
-
def thread_process_iteration(
|
101
|
-
|
102
|
-
connection = client.get_connection
|
103
|
-
channel = connection.create_channel
|
116
|
+
def thread_process_iteration(channel, manager, queue, block)
|
104
117
|
|
105
118
|
#get the queue
|
106
119
|
q = manager.get_queue(channel, queue)
|
@@ -138,9 +151,7 @@ module EventQ
|
|
138
151
|
|
139
152
|
rescue => e
|
140
153
|
EventQ.log(:error, "[#{self.class}] - An unhandled error happened attempting to process a queue message. Error: #{e} | Backtrace: #{e.backtrace}")
|
141
|
-
|
142
154
|
error = true
|
143
|
-
|
144
155
|
end
|
145
156
|
|
146
157
|
if error || abort
|
@@ -154,7 +165,6 @@ module EventQ
|
|
154
165
|
end
|
155
166
|
|
156
167
|
channel.close
|
157
|
-
connection.close
|
158
168
|
|
159
169
|
GC.start
|
160
170
|
|
@@ -13,12 +13,16 @@ module EventQ
|
|
13
13
|
|
14
14
|
def subscribe(event_type, queue)
|
15
15
|
|
16
|
-
|
16
|
+
connection = @client.get_connection
|
17
|
+
channel = connection.create_channel
|
17
18
|
queue = @queue_manager.get_queue(channel, queue)
|
18
19
|
exchange = @queue_manager.get_exchange(channel, @event_raised_exchange)
|
19
20
|
|
20
21
|
queue.bind(exchange, :routing_key => event_type)
|
21
22
|
|
23
|
+
channel.close
|
24
|
+
connection.close
|
25
|
+
|
22
26
|
return true
|
23
27
|
end
|
24
28
|
|