hot_bunnies 1.5.0-java → 2.0.0.pre1-java
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/ext/rabbitmq-client.jar +0 -0
- data/lib/hot_bunnies/channel.rb +287 -9
- data/lib/hot_bunnies/consumers.rb +152 -0
- data/lib/hot_bunnies/exceptions.rb +151 -0
- data/lib/hot_bunnies/exchange.rb +22 -30
- data/lib/hot_bunnies/juc.rb +9 -0
- data/lib/hot_bunnies/metadata.rb +90 -0
- data/lib/hot_bunnies/queue.rb +52 -265
- data/lib/hot_bunnies/session.rb +170 -0
- data/lib/hot_bunnies/version.rb +1 -1
- data/lib/hot_bunnies.rb +5 -91
- metadata +15 -39
- data/.gitignore +0 -7
- data/.rvmrc +0 -1
- data/.travis.yml +0 -12
- data/ChangeLog.md +0 -46
- data/Gemfile +0 -10
- data/LICENSE +0 -20
- data/README.md +0 -58
- data/Rakefile +0 -6
- data/examples/blocking_subscription.rb +0 -36
- data/examples/non_blocking_subscription.rb +0 -32
- data/examples/non_blocking_subscription_with_executor.rb +0 -38
- data/hot_bunnies.gemspec +0 -24
- data/spec/integration/alternate_exchanges_spec.rb +0 -36
- data/spec/integration/basic_consume_spec.rb +0 -128
- data/spec/integration/connection_spec.rb +0 -26
- data/spec/integration/error_handling_by_consumers_spec.rb +0 -97
- data/spec/integration/exchange_bind_spec.rb +0 -35
- data/spec/integration/exchange_declare_spec.rb +0 -113
- data/spec/integration/message_metadata_access_spec.rb +0 -94
- data/spec/integration/publisher_confirmations_spec.rb +0 -51
- data/spec/integration/queue_bind_spec.rb +0 -56
- data/spec/integration/queue_declare_spec.rb +0 -44
- data/spec/integration/queue_delete_spec.rb +0 -23
- data/spec/integration/queue_purge_spec.rb +0 -38
- data/spec/integration/queue_unbind_spec.rb +0 -53
- data/spec/integration/sender_selected_distribution_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -18
data/lib/hot_bunnies.rb
CHANGED
@@ -4,99 +4,13 @@ require 'java'
|
|
4
4
|
require 'ext/commons-io'
|
5
5
|
require 'ext/rabbitmq-client'
|
6
6
|
|
7
|
+
require 'hot_bunnies/version'
|
8
|
+
require 'hot_bunnies/exceptions'
|
9
|
+
require 'hot_bunnies/session'
|
7
10
|
|
8
11
|
module HotBunnies
|
9
|
-
|
10
|
-
|
11
|
-
java_import 'com.rabbitmq.client.Channel'
|
12
|
-
java_import 'com.rabbitmq.client.DefaultConsumer'
|
13
|
-
java_import 'com.rabbitmq.client.AMQP'
|
14
|
-
|
15
|
-
def self.connect(options={})
|
16
|
-
cf = ConnectionFactory.new
|
17
|
-
|
18
|
-
cf.uri = options[:uri] if options[:uri]
|
19
|
-
cf.host = hostname_from(options) if include_host?(options)
|
20
|
-
cf.port = options[:port] if options[:port]
|
21
|
-
cf.virtual_host = vhost_from(options) if include_vhost?(options)
|
22
|
-
cf.connection_timeout = timeout_from(options) if include_timeout?(options)
|
23
|
-
cf.username = username_from(options) if include_username?(options)
|
24
|
-
cf.password = password_from(options) if include_password?(options)
|
25
|
-
|
26
|
-
cf.requested_heartbeat = heartbeat_from(options) if include_heartbeat?(options)
|
27
|
-
cf.connection_timeout = connection_timeout_from(options) if include_connection_timeout?(options)
|
28
|
-
|
29
|
-
tls = (options[:ssl] || options[:tls])
|
30
|
-
case tls
|
31
|
-
when true then
|
32
|
-
cf.use_ssl_protocol
|
33
|
-
when String then
|
34
|
-
if options[:trust_manager]
|
35
|
-
cf.use_ssl_protocol(tls, options[:trust_manager])
|
36
|
-
else
|
37
|
-
cf.use_ssl_protocol(tls)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
cf.new_connection
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
|
46
|
-
def self.hostname_from(options)
|
47
|
-
options[:host] || options[:hostname] || ConnectionFactory.DEFAULT_HOST
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.include_host?(options)
|
51
|
-
!!(options[:host] || options[:hostname])
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.vhost_from(options)
|
55
|
-
options[:virtual_host] || options[:vhost] || ConnectionFactory.DEFAULT_VHOST
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.include_vhost?(options)
|
59
|
-
!!(options[:virtual_host] || options[:vhost])
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.timeout_from(options)
|
63
|
-
options[:connection_timeout] || options[:timeout]
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.include_timeout?(options)
|
67
|
-
!!(options[:connection_timeout] || options[:timeout])
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.username_from(options)
|
71
|
-
options[:username] || options[:user] || ConnectionFactory.DEFAULT_USER
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.heartbeat_from(options)
|
75
|
-
options[:heartbeat_interval] || options[:requested_heartbeat] || ConnectionFactory.DEFAULT_HEARTBEAT
|
76
|
-
end
|
77
|
-
|
78
|
-
def self.connection_timeout_from(options)
|
79
|
-
options[:connection_timeout_interval] || options[:connection_timeout] || ConnectionFactory.DEFAULT_CONNECTION_TIMEOUT
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.include_username?(options)
|
83
|
-
!!(options[:username] || options[:user])
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.password_from(options)
|
87
|
-
options[:password] || options[:pass] || ConnectionFactory.DEFAULT_PASS
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.include_password?(options)
|
91
|
-
!!(options[:password] || options[:pass])
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.include_heartbeat?(options)
|
95
|
-
!!(options[:heartbeat_interval] || options[:requested_heartbeat] || options[:heartbeat])
|
96
|
-
end
|
97
|
-
|
98
|
-
def self.include_connection_timeout?(options)
|
99
|
-
!!(options[:connection_timeout_interval] || options[:connection_timeout])
|
12
|
+
def self.connect(*args)
|
13
|
+
Session.connect(*args)
|
100
14
|
end
|
101
15
|
end
|
102
16
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot_bunnies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0.pre1
|
5
|
+
prerelease: 6
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Theo Hultberg
|
@@ -10,50 +10,28 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
|
-
description:
|
15
|
+
description: RabbitMQ client for JRuby built around the official RabbitMQ Java client
|
16
16
|
email:
|
17
17
|
- theo@burtcorp.com
|
18
18
|
executables: []
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- ".gitignore"
|
23
|
-
- ".rvmrc"
|
24
|
-
- ".travis.yml"
|
25
|
-
- ChangeLog.md
|
26
|
-
- Gemfile
|
27
|
-
- LICENSE
|
28
|
-
- README.md
|
29
|
-
- Rakefile
|
30
|
-
- examples/blocking_subscription.rb
|
31
|
-
- examples/non_blocking_subscription.rb
|
32
|
-
- examples/non_blocking_subscription_with_executor.rb
|
33
|
-
- hot_bunnies.gemspec
|
34
22
|
- lib/ext/commons-io.jar
|
35
23
|
- lib/ext/rabbitmq-client.jar
|
36
24
|
- lib/hot_bunnies.rb
|
37
25
|
- lib/hot_bunnies/channel.rb
|
26
|
+
- lib/hot_bunnies/consumers.rb
|
27
|
+
- lib/hot_bunnies/exceptions.rb
|
38
28
|
- lib/hot_bunnies/exchange.rb
|
29
|
+
- lib/hot_bunnies/juc.rb
|
30
|
+
- lib/hot_bunnies/metadata.rb
|
39
31
|
- lib/hot_bunnies/queue.rb
|
32
|
+
- lib/hot_bunnies/session.rb
|
40
33
|
- lib/hot_bunnies/version.rb
|
41
|
-
|
42
|
-
- spec/integration/basic_consume_spec.rb
|
43
|
-
- spec/integration/connection_spec.rb
|
44
|
-
- spec/integration/error_handling_by_consumers_spec.rb
|
45
|
-
- spec/integration/exchange_bind_spec.rb
|
46
|
-
- spec/integration/exchange_declare_spec.rb
|
47
|
-
- spec/integration/message_metadata_access_spec.rb
|
48
|
-
- spec/integration/publisher_confirmations_spec.rb
|
49
|
-
- spec/integration/queue_bind_spec.rb
|
50
|
-
- spec/integration/queue_declare_spec.rb
|
51
|
-
- spec/integration/queue_delete_spec.rb
|
52
|
-
- spec/integration/queue_purge_spec.rb
|
53
|
-
- spec/integration/queue_unbind_spec.rb
|
54
|
-
- spec/integration/sender_selected_distribution_spec.rb
|
55
|
-
- spec/spec_helper.rb
|
56
|
-
homepage: http://github.com/iconara/hot_bunnies
|
34
|
+
homepage: http://github.com/ruby-amqp/hot_bunnies
|
57
35
|
licenses: []
|
58
36
|
post_install_message:
|
59
37
|
rdoc_options: []
|
@@ -61,22 +39,20 @@ require_paths:
|
|
61
39
|
- lib
|
62
40
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
41
|
requirements:
|
64
|
-
- -
|
42
|
+
- - '>='
|
65
43
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
67
|
-
MA==
|
44
|
+
version: '0'
|
68
45
|
none: false
|
69
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
47
|
requirements:
|
71
|
-
- -
|
48
|
+
- - '>'
|
72
49
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
74
|
-
MA==
|
50
|
+
version: 1.3.1
|
75
51
|
none: false
|
76
52
|
requirements: []
|
77
53
|
rubyforge_project: hot_bunnies
|
78
54
|
rubygems_version: 1.8.24
|
79
55
|
signing_key:
|
80
56
|
specification_version: 3
|
81
|
-
summary:
|
57
|
+
summary: RabbitMQ client for JRuby built around the official RabbitMQ Java client
|
82
58
|
test_files: []
|
data/.gitignore
DELETED
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm --create use jruby@hot_bunnies
|
data/.travis.yml
DELETED
data/ChangeLog.md
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# Changes Between 1.5.0 and 1.6.0
|
2
|
-
|
3
|
-
No changes yet.
|
4
|
-
|
5
|
-
|
6
|
-
# Changes Between 1.4.0 and 1.5.0
|
7
|
-
|
8
|
-
## RabbitMQ Java Client Upgrade
|
9
|
-
|
10
|
-
Hot Bunnies now uses RabbitMQ Java client 3.0.x.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Changes Between 1.3.0 and 1.4.0
|
15
|
-
|
16
|
-
## RabbitMQ Java Client Upgrade
|
17
|
-
|
18
|
-
Hot Bunnies now uses RabbitMQ Java client 2.8.7.
|
19
|
-
|
20
|
-
|
21
|
-
## TLS Support
|
22
|
-
|
23
|
-
`HotBunnies.connect` now supports a new `:tls` option:
|
24
|
-
|
25
|
-
``` ruby
|
26
|
-
HotBunnies.connect(:tls => true)
|
27
|
-
|
28
|
-
HotBunnies.connect(:tls => "SSLv3")
|
29
|
-
HotBunnies.connect(:tls => "SSLv2")
|
30
|
-
|
31
|
-
HotBunnies.connect(:tls => "SSLv3", :trust_manager => custom_trust_manager)
|
32
|
-
```
|
33
|
-
|
34
|
-
|
35
|
-
## Consumer Back Pressure Improvements
|
36
|
-
|
37
|
-
* The async consumer will not attempt to add tasks when its executor is shutting down.
|
38
|
-
|
39
|
-
* The blocking consumer got a buffer size option that makes it create a bounded blocking queue instead of an unbounded.
|
40
|
-
|
41
|
-
|
42
|
-
## Consumer Improvements
|
43
|
-
|
44
|
-
`HotBunnies::Queue#subscribe` is now more resilient to exceptions and uses a new
|
45
|
-
executor task for each delivery. When a consumer is cancelled, any remaining messages
|
46
|
-
will be delivered instead of being ignored.
|
data/Gemfile
DELETED
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Theo Hultberg
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# What is Hot Bunnies
|
2
|
-
|
3
|
-
Hot Bunnies is an idiomatic, fast and well-maintained (J)Ruby DSL on top of the [RabbitMQ Java client](http://www.rabbitmq.com/api-guide.html). It strives to combine
|
4
|
-
strong parts of the Java client with over 3 years of [Ruby amqp gem](https://github.com/ruby-amqp/amqp) development experience.
|
5
|
-
|
6
|
-
## Why Hot Bunnies
|
7
|
-
|
8
|
-
* Concurrency support on the JVM is excellent, with many tools & approaches available. Lets make use of it.
|
9
|
-
* RabbitMQ Java client is rock solid and supports every RabbitMQ feature. Very nice.
|
10
|
-
* It is screaming fast thanks to all the heavy duty being done in the pretty efficient & lightweight Java code.
|
11
|
-
* It uses synchronous APIs where it makes sense and asynchronous APIs where it makes sense. Some other [Ruby RabbitMQ clients](https://github.com/ruby-amqp)
|
12
|
-
only use one or the other.
|
13
|
-
* [amqp gem](https://github.com/ruby-amqp/amqp) has certain amount of baggage it cannot drop because of backwards compatibility concerns. Hot Bunnies is a
|
14
|
-
clean room design, much more open to radical new ideas.
|
15
|
-
* Someone just *had* to come up with a library called Hot Bunnies. Are your bunnies hot?
|
16
|
-
|
17
|
-
|
18
|
-
## What Hot Bunnies is not
|
19
|
-
|
20
|
-
Hot Bunnies is not
|
21
|
-
|
22
|
-
* A replacement for the RabbitMQ Java client
|
23
|
-
* An attempt to re-create 100% of the amqp gem API on top of the Java client
|
24
|
-
* A "work queue" like Resque
|
25
|
-
* A cure for cancer
|
26
|
-
|
27
|
-
|
28
|
-
## Installation, Dependency
|
29
|
-
|
30
|
-
### With Rubygems
|
31
|
-
|
32
|
-
gem install hot_bunnies
|
33
|
-
|
34
|
-
### With Bundler
|
35
|
-
|
36
|
-
gem "hot_bunnies", "~> 1.4.0"
|
37
|
-
|
38
|
-
|
39
|
-
## Change Log
|
40
|
-
|
41
|
-
See ChangeLog.md.
|
42
|
-
|
43
|
-
|
44
|
-
## Continuous Integration
|
45
|
-
|
46
|
-
[](http://travis-ci.org/ruby-amqp/hot_bunnies)
|
47
|
-
|
48
|
-
CI is hosted by [travis-ci.org](http://travis-ci.org)
|
49
|
-
|
50
|
-
|
51
|
-
## License
|
52
|
-
|
53
|
-
MIT, see LICENSE in the repository root
|
54
|
-
|
55
|
-
|
56
|
-
## Copyright
|
57
|
-
|
58
|
-
Theo Hultberg, Michael Klishin, 2011-2012.
|
data/Rakefile
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
$: << 'lib'
|
2
|
-
|
3
|
-
require 'hot_bunnies'
|
4
|
-
|
5
|
-
|
6
|
-
connection = HotBunnies.connect(:host => 'localhost')
|
7
|
-
channel = connection.create_channel
|
8
|
-
channel.prefetch = 10
|
9
|
-
|
10
|
-
exchange = channel.exchange('test', :type => :direct)
|
11
|
-
|
12
|
-
queue = channel.queue('hello.world')
|
13
|
-
queue.bind(exchange, :routing_key => 'xyz')
|
14
|
-
queue.purge
|
15
|
-
|
16
|
-
100.times do |i|
|
17
|
-
exchange.publish("hello world! #{i}", :routing_key => 'xyz')
|
18
|
-
end
|
19
|
-
|
20
|
-
exchange.publish("POISON!", :routing_key => 'xyz')
|
21
|
-
|
22
|
-
subscription = queue.subscribe(:ack => true)
|
23
|
-
subscription.each(:blocking => true) do |headers, msg|
|
24
|
-
puts msg
|
25
|
-
headers.ack
|
26
|
-
if msg == "POISON!"
|
27
|
-
:cancel
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
puts "ALL DONE!"
|
32
|
-
|
33
|
-
at_exit do
|
34
|
-
channel.close
|
35
|
-
connection.close
|
36
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
$: << 'lib'
|
2
|
-
|
3
|
-
require 'hot_bunnies'
|
4
|
-
|
5
|
-
|
6
|
-
connection = HotBunnies.connect(:host => 'localhost')
|
7
|
-
channel = connection.create_channel
|
8
|
-
channel.prefetch = 10
|
9
|
-
|
10
|
-
exchange = channel.exchange('test', :type => :direct)
|
11
|
-
|
12
|
-
queue = channel.queue('hello.world')
|
13
|
-
queue.bind(exchange, :routing_key => 'xyz')
|
14
|
-
queue.purge
|
15
|
-
|
16
|
-
subscription = queue.subscribe(:ack => true, :blocking => false) do |headers, msg|
|
17
|
-
puts msg
|
18
|
-
headers.ack
|
19
|
-
end
|
20
|
-
|
21
|
-
100.times do |i|
|
22
|
-
exchange.publish("hello world! #{i}", :routing_key => 'xyz')
|
23
|
-
end
|
24
|
-
|
25
|
-
subscription.cancel
|
26
|
-
|
27
|
-
puts "ALMOST ALL DONE!"
|
28
|
-
|
29
|
-
at_exit do
|
30
|
-
channel.close
|
31
|
-
connection.close
|
32
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
$: << 'lib'
|
2
|
-
|
3
|
-
require 'hot_bunnies'
|
4
|
-
|
5
|
-
import java.util.concurrent.Executors
|
6
|
-
|
7
|
-
|
8
|
-
connection = HotBunnies.connect(:host => 'localhost')
|
9
|
-
channel = connection.create_channel
|
10
|
-
channel.prefetch = 10
|
11
|
-
|
12
|
-
exchange = channel.exchange('test', :type => :direct)
|
13
|
-
|
14
|
-
queue = channel.queue('hello.world')
|
15
|
-
queue.bind(exchange, :routing_key => 'xyz')
|
16
|
-
queue.purge
|
17
|
-
|
18
|
-
thread_pool = Executors.new_fixed_thread_pool(3)
|
19
|
-
|
20
|
-
subscription = queue.subscribe(:ack => true)
|
21
|
-
subscription.each(:blocking => false, :executor => thread_pool) do |headers, msg|
|
22
|
-
puts msg
|
23
|
-
headers.ack
|
24
|
-
end
|
25
|
-
|
26
|
-
100.times do |i|
|
27
|
-
exchange.publish("hello world! #{i}", :routing_key => 'xyz')
|
28
|
-
end
|
29
|
-
|
30
|
-
thread_pool.shutdown_now
|
31
|
-
subscription.cancel
|
32
|
-
|
33
|
-
puts "ALMOST ALL DONE!"
|
34
|
-
|
35
|
-
at_exit do
|
36
|
-
channel.close
|
37
|
-
connection.close
|
38
|
-
end
|
data/hot_bunnies.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$: << File.expand_path('../lib', __FILE__)
|
4
|
-
|
5
|
-
require 'hot_bunnies/version'
|
6
|
-
|
7
|
-
|
8
|
-
Gem::Specification.new do |s|
|
9
|
-
s.name = 'hot_bunnies'
|
10
|
-
s.version = HotBunnies::VERSION
|
11
|
-
s.platform = 'java'
|
12
|
-
s.authors = ['Theo Hultberg', 'Michael S. Klishin']
|
13
|
-
s.email = ['theo@burtcorp.com']
|
14
|
-
s.homepage = 'http://github.com/iconara/hot_bunnies'
|
15
|
-
s.summary = %q{Ruby wrapper for the RabbitMQ Java driver}
|
16
|
-
s.description = %q{A object oriented interface to RabbitMQ that uses the Java driver under the hood}
|
17
|
-
|
18
|
-
s.rubyforge_project = 'hot_bunnies'
|
19
|
-
|
20
|
-
s.files = `git ls-files`.split("\n")
|
21
|
-
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
-
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
-
s.require_paths = %w(lib)
|
24
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Any exchange" do
|
4
|
-
|
5
|
-
#
|
6
|
-
# Environment
|
7
|
-
#
|
8
|
-
|
9
|
-
let(:connection) { HotBunnies.connect }
|
10
|
-
let(:channel) { connection.create_channel }
|
11
|
-
|
12
|
-
after :each do
|
13
|
-
channel.close
|
14
|
-
connection.close
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
# Examples
|
20
|
-
#
|
21
|
-
|
22
|
-
it "can have an alternate exchange (a RabbitMQ-specific extension to AMQP 0.9.1)" do
|
23
|
-
queue = channel.queue("", :auto_delete => true)
|
24
|
-
|
25
|
-
fe = channel.exchange("hot_bunnies.extensions.alternate_xchanges.fanout1")
|
26
|
-
de = channel.exchange("hot_bunnies.extensions.alternate_xchanges.direct1", :arguments => {
|
27
|
-
"alternate-exchange" => fe.name
|
28
|
-
})
|
29
|
-
|
30
|
-
queue.bind(fe)
|
31
|
-
de.publish("1010", :routing_key => "", :mandatory => true)
|
32
|
-
|
33
|
-
mc, _ = queue.status
|
34
|
-
mc.should == 1
|
35
|
-
end
|
36
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'A consumer of a queue' do
|
5
|
-
let(:connection) { HotBunnies.connect }
|
6
|
-
let(:channel) { connection.create_channel }
|
7
|
-
|
8
|
-
after :each do
|
9
|
-
channel.close
|
10
|
-
connection.close
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'receives messages until cancelled' do
|
14
|
-
exchange = connection.create_channel.default_exchange
|
15
|
-
queue = connection.create_channel.queue("", :auto_delete => true)
|
16
|
-
subscription = queue.subscribe
|
17
|
-
|
18
|
-
messages = []
|
19
|
-
consumer_exited = false
|
20
|
-
|
21
|
-
consumer_thread = Thread.new do
|
22
|
-
subscription.each do |headers, message|
|
23
|
-
messages << message
|
24
|
-
sleep 0.1
|
25
|
-
end
|
26
|
-
consumer_exited = true
|
27
|
-
end
|
28
|
-
|
29
|
-
publisher_thread = Thread.new do
|
30
|
-
20.times do
|
31
|
-
exchange.publish('hello world', :routing_key => queue.name)
|
32
|
-
sleep 0.01
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
sleep 0.2
|
37
|
-
|
38
|
-
subscription.cancel
|
39
|
-
|
40
|
-
consumer_thread.join
|
41
|
-
publisher_thread.join
|
42
|
-
|
43
|
-
messages.should_not be_empty
|
44
|
-
consumer_exited.should be_true
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "Multiple non-exclusive consumers per queue" do
|
49
|
-
let(:connection) { HotBunnies.connect }
|
50
|
-
let(:channel) { connection.create_channel }
|
51
|
-
|
52
|
-
after :each do
|
53
|
-
channel.close
|
54
|
-
connection.close
|
55
|
-
end
|
56
|
-
|
57
|
-
context "on the same channel (so prefetch levels won't affect message distribution)" do
|
58
|
-
it "have messages distributed to them in the round robin manner" do
|
59
|
-
n = 100
|
60
|
-
mailbox1 = []
|
61
|
-
mailbox2 = []
|
62
|
-
mailbox3 = []
|
63
|
-
|
64
|
-
all_received = java.util.concurrent.CountDownLatch.new(n)
|
65
|
-
consumer_channel = connection.create_channel
|
66
|
-
|
67
|
-
queue = channel.queue("", :auto_delete => true)
|
68
|
-
|
69
|
-
consumer1 = queue.subscribe(:blocking => false) do |metadata, payload|
|
70
|
-
mailbox1 << payload
|
71
|
-
all_received.count_down
|
72
|
-
end
|
73
|
-
consumer2 = queue.subscribe(:blocking => false) do |metadata, payload|
|
74
|
-
mailbox2 << payload
|
75
|
-
all_received.count_down
|
76
|
-
end
|
77
|
-
consumer3 = queue.subscribe(:blocking => false) do |metadata, payload|
|
78
|
-
mailbox3 << payload
|
79
|
-
all_received.count_down
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
sleep 2.0 # let consumers in other threads start.
|
84
|
-
n.times do |i|
|
85
|
-
channel.default_exchange.publish("Message #{i}", :routing_key => queue.name)
|
86
|
-
end
|
87
|
-
|
88
|
-
all_received.await
|
89
|
-
|
90
|
-
mailbox1.size.should >= 33
|
91
|
-
mailbox2.size.should >= 33
|
92
|
-
mailbox3.size.should >= 33
|
93
|
-
|
94
|
-
consumer1.shutdown!
|
95
|
-
consumer2.shutdown!
|
96
|
-
consumer3.shutdown!
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
describe "Queue consumer" do
|
103
|
-
let(:connection) { HotBunnies.connect }
|
104
|
-
let(:channel) { connection.create_channel }
|
105
|
-
|
106
|
-
after :each do
|
107
|
-
channel.close
|
108
|
-
connection.close
|
109
|
-
end
|
110
|
-
|
111
|
-
it "provides predicates" do
|
112
|
-
queue = channel.queue("", :auto_delete => true)
|
113
|
-
|
114
|
-
subscription = queue.subscribe(:blocking => false) { |_, _| nil }
|
115
|
-
|
116
|
-
# consumer tag will be sent by the broker, so this happens
|
117
|
-
# asynchronously and we can either add callbacks/use latches or
|
118
|
-
# just wait. MK.
|
119
|
-
sleep(1.0)
|
120
|
-
subscription.should be_active
|
121
|
-
|
122
|
-
subscription.cancel
|
123
|
-
sleep(1.0)
|
124
|
-
subscription.should_not be_active
|
125
|
-
|
126
|
-
subscription.shutdown!
|
127
|
-
end
|
128
|
-
end
|