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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60e5a3271b53e9ca20221e49bdb970935730e586
4
- data.tar.gz: ee5f3fda4e16244475862d3bcdee03bbeeb82a2f
3
+ metadata.gz: 24ca73a8f2f4c29c8e93d9f05c348cfa8ac67587
4
+ data.tar.gz: 7234f3f45f4649865bc7e14030c7ae605392b761
5
5
  SHA512:
6
- metadata.gz: 3c2d6c0381d3bad9aade432ac041ed413aefa7999ef16b35740df18b7c690fa5a1856f99037c0015c9c91612d5b99caf0b07bf7665b82890c63e75678b46e8a9
7
- data.tar.gz: 6a6055eb4e150dbc61592f267d3cc2fa8ec946fecde7daf821628a6d505797dc72476ecad2988408ef9be96ae4cc36cfb62c28af59a4e6edd45db751ae0de0d5
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
- channel = @client.get_channel
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
- channel.connection.close
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 => 2,
34
- :continuation_timeout => 5000,
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 => true)
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 => true, :arguments => { X_DEAD_LETTER_EXCHANGE => subscriber_exchange.name, X_MESSAGE_TTL => queue.max_retry_delay })
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 => true, :arguments => { X_DEAD_LETTER_EXCHANGE => subscriber_exchange.name, X_MESSAGE_TTL => queue.retry_delay })
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 => true)
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
- thread_process_iteration(client, manager, queue, block)
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 rabbitmq. Error: #{e} | Backtrace: #{e.backtrace}"
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(client, manager, queue, block)
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
- channel = @client.get_channel
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
 
@@ -1,3 +1,3 @@
1
1
  module EventqRabbitmq
2
- VERSION = "1.7.7"
2
+ VERSION = "1.7.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq_rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.7
4
+ version: 1.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage