hot_bunnies 2.0.0.pre12-java → 2.0.0.pre13-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hot_bunnies/channel.rb +2 -3
- data/lib/hot_bunnies/consumers.rb +0 -2
- data/lib/hot_bunnies/queue.rb +1 -2
- data/lib/hot_bunnies/session.rb +22 -16
- data/lib/hot_bunnies/thread_pools.rb +2 -0
- data/lib/hot_bunnies/version.rb +1 -1
- data/lib/hot_bunnies.rb +0 -1
- metadata +2 -2
data/lib/hot_bunnies/channel.rb
CHANGED
@@ -118,10 +118,9 @@ module HotBunnies
|
|
118
118
|
attr_reader :consumers
|
119
119
|
|
120
120
|
# @private
|
121
|
-
def initialize(session, delegate
|
121
|
+
def initialize(session, delegate)
|
122
122
|
@connection = session
|
123
123
|
@delegate = delegate
|
124
|
-
@thread_pool = thread_pool
|
125
124
|
|
126
125
|
@exchanges = JavaConcurrent::ConcurrentHashMap.new
|
127
126
|
@queues = JavaConcurrent::ConcurrentHashMap.new
|
@@ -403,7 +402,7 @@ module HotBunnies
|
|
403
402
|
# @see http://hotbunnies.info/articles/queues.html Queues and Consumers guide
|
404
403
|
# @see http://hotbunnies.info/articles/extensions.html RabbitMQ Extensions guide
|
405
404
|
def queue(name, options={})
|
406
|
-
dq = Queue.new(self, name,
|
405
|
+
dq = Queue.new(self, name, options).tap do |q|
|
407
406
|
q.declare!
|
408
407
|
end
|
409
408
|
|
data/lib/hot_bunnies/queue.rb
CHANGED
@@ -28,10 +28,9 @@ module HotBunnies
|
|
28
28
|
# @see HotBunnies::Channel#queue
|
29
29
|
# @see http://hotbunnies.info/articles/queues.html Queues and Consumers guide
|
30
30
|
# @see http://hotbunnies.info/articles/extensions.html RabbitMQ Extensions guide
|
31
|
-
def initialize(channel, name,
|
31
|
+
def initialize(channel, name, options={})
|
32
32
|
@channel = channel
|
33
33
|
@name = name
|
34
|
-
@thread_pool = thread_pool
|
35
34
|
@options = {:durable => false, :exclusive => false, :auto_delete => false, :passive => false, :arguments => Hash.new}.merge(options)
|
36
35
|
|
37
36
|
@durable = @options[:durable]
|
data/lib/hot_bunnies/session.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "hot_bunnies/shutdown_listener"
|
3
3
|
require "set"
|
4
|
+
require "hot_bunnies/thread_pools"
|
4
5
|
|
5
6
|
module HotBunnies
|
6
7
|
java_import com.rabbitmq.client.ConnectionFactory
|
@@ -73,13 +74,10 @@ module HotBunnies
|
|
73
74
|
|
74
75
|
# @private
|
75
76
|
def initialize(connection_factory, opts = {})
|
76
|
-
@cf
|
77
|
+
@cf = connection_factory
|
77
78
|
@executor_factory = opts[:executor_factory]
|
78
|
-
@connection
|
79
|
-
|
80
|
-
end
|
81
|
-
@channels = JavaConcurrent::ConcurrentHashMap.new
|
82
|
-
@thread_pool = ThreadPools.dynamically_growing
|
79
|
+
@connection = self.new_connection
|
80
|
+
@channels = JavaConcurrent::ConcurrentHashMap.new
|
83
81
|
|
84
82
|
# should automatic recovery from network failures be used?
|
85
83
|
@automatically_recover = if opts[:automatically_recover].nil? && opts[:automatic_recovery].nil?
|
@@ -110,7 +108,7 @@ module HotBunnies
|
|
110
108
|
@connection.create_channel
|
111
109
|
end
|
112
110
|
|
113
|
-
ch = Channel.new(self, jc
|
111
|
+
ch = Channel.new(self, jc)
|
114
112
|
register_channel(ch)
|
115
113
|
|
116
114
|
ch
|
@@ -126,11 +124,6 @@ module HotBunnies
|
|
126
124
|
ch.close
|
127
125
|
end
|
128
126
|
|
129
|
-
@thread_pool.shutdown
|
130
|
-
unless @thread_pool.await_termination(5, JavaConcurrent::TimeUnit::SECONDS)
|
131
|
-
@thread_pool.shutdown_now
|
132
|
-
end
|
133
|
-
|
134
127
|
@connection.close
|
135
128
|
end
|
136
129
|
|
@@ -171,11 +164,14 @@ module HotBunnies
|
|
171
164
|
# Begins automatic connection recovery (typically only used internally
|
172
165
|
# to recover from network failures)
|
173
166
|
def automatically_recover
|
167
|
+
ms = @network_recovery_interval * 1000
|
174
168
|
# recovering immediately makes little sense. Wait a bit first. MK.
|
175
|
-
java.lang.Thread.sleep(
|
169
|
+
java.lang.Thread.sleep(ms)
|
176
170
|
|
177
171
|
@connection = converting_rjc_exceptions_to_ruby do
|
178
|
-
|
172
|
+
reconnecting_on_network_failures(ms) do
|
173
|
+
self.new_connection
|
174
|
+
end
|
179
175
|
end
|
180
176
|
@thread_pool = ThreadPools.dynamically_growing
|
181
177
|
self.recover_shutdown_hooks
|
@@ -326,12 +322,22 @@ module HotBunnies
|
|
326
322
|
end
|
327
323
|
end
|
328
324
|
|
325
|
+
# @private
|
326
|
+
def reconnecting_on_network_failures(interval_in_ms, &fn)
|
327
|
+
begin
|
328
|
+
fn.call
|
329
|
+
rescue IOError, HotBunnies::ConnectionRefused, java.io.IOException => e
|
330
|
+
java.lang.Thread.sleep(interval_in_ms)
|
331
|
+
|
332
|
+
retry
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
329
336
|
# @private
|
330
337
|
def new_connection
|
331
338
|
converting_rjc_exceptions_to_ruby do
|
332
339
|
if @executor_factory
|
333
|
-
|
334
|
-
@cf.new_connection(ex)
|
340
|
+
@cf.new_connection(@executor_factory.call)
|
335
341
|
else
|
336
342
|
@cf.new_connection
|
337
343
|
end
|
data/lib/hot_bunnies/version.rb
CHANGED
data/lib/hot_bunnies.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot_bunnies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre13
|
5
5
|
prerelease: 6
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: RabbitMQ client for JRuby built around the official RabbitMQ Java client
|
16
16
|
email:
|