tootsie 0.9.28 → 0.9.29
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.
- data/lib/tootsie/queues/amqp_queue.rb +7 -7
- data/lib/tootsie/version.rb +1 -1
- metadata +3 -3
|
@@ -9,7 +9,6 @@ module Tootsie
|
|
|
9
9
|
@logger = Application.get.logger
|
|
10
10
|
@host_name = options[:host_name] || 'localhost'
|
|
11
11
|
@queue_name = options[:queue_name] || 'tootsie'
|
|
12
|
-
connect!
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def count
|
|
@@ -19,7 +18,7 @@ module Tootsie
|
|
|
19
18
|
def push(item)
|
|
20
19
|
data = item.to_json
|
|
21
20
|
with_retry do
|
|
22
|
-
|
|
21
|
+
with_connection do
|
|
23
22
|
@exchange.publish(data, :persistent => true, :key => @queue_name)
|
|
24
23
|
end
|
|
25
24
|
end
|
|
@@ -31,7 +30,7 @@ module Tootsie
|
|
|
31
30
|
@backoff.with do
|
|
32
31
|
message = nil
|
|
33
32
|
with_retry do
|
|
34
|
-
|
|
33
|
+
with_connection do
|
|
35
34
|
message = @queue.pop(:ack => true)
|
|
36
35
|
end
|
|
37
36
|
end
|
|
@@ -41,7 +40,7 @@ module Tootsie
|
|
|
41
40
|
if data
|
|
42
41
|
@logger.info "Popped: #{data.inspect}"
|
|
43
42
|
item = JSON.parse(data)
|
|
44
|
-
|
|
43
|
+
with_connection do
|
|
45
44
|
@queue.ack(:delivery_tag => message[:delivery_details][:delivery_tag])
|
|
46
45
|
end
|
|
47
46
|
end
|
|
@@ -59,13 +58,14 @@ module Tootsie
|
|
|
59
58
|
|
|
60
59
|
private
|
|
61
60
|
|
|
62
|
-
def
|
|
61
|
+
def with_connection(&block)
|
|
63
62
|
begin
|
|
63
|
+
connect! unless @connection
|
|
64
64
|
result = yield
|
|
65
65
|
rescue Bunny::ServerDownError, Bunny::ConnectionError, Bunny::ProtocolError => e
|
|
66
66
|
@logger.error "Error in AMQP server connection (#{e.class}: #{e}), retrying"
|
|
67
|
+
@connection = nil
|
|
67
68
|
sleep(0.5)
|
|
68
|
-
connect!
|
|
69
69
|
retry
|
|
70
70
|
else
|
|
71
71
|
result
|
|
@@ -90,7 +90,7 @@ module Tootsie
|
|
|
90
90
|
|
|
91
91
|
@connection = Bunny.new(:host => @host_name)
|
|
92
92
|
@connection.start
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
@exchange = @connection.exchange('')
|
|
95
95
|
|
|
96
96
|
@queue = @connection.queue(@queue_name, :durable => true)
|
data/lib/tootsie/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tootsie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.29
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -326,7 +326,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
326
326
|
version: '0'
|
|
327
327
|
segments:
|
|
328
328
|
- 0
|
|
329
|
-
hash:
|
|
329
|
+
hash: 1887276204761055397
|
|
330
330
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
331
|
none: false
|
|
332
332
|
requirements:
|
|
@@ -335,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
335
335
|
version: '0'
|
|
336
336
|
segments:
|
|
337
337
|
- 0
|
|
338
|
-
hash:
|
|
338
|
+
hash: 1887276204761055397
|
|
339
339
|
requirements: []
|
|
340
340
|
rubyforge_project: tootsie
|
|
341
341
|
rubygems_version: 1.8.24
|