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
@@ -1,26 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "HotBunnies.connect" do
|
5
|
-
|
6
|
-
#
|
7
|
-
# Examples
|
8
|
-
#
|
9
|
-
|
10
|
-
it "lets you specify requested heartbeat interval" do
|
11
|
-
c1 = HotBunnies.connect(:requested_heartbeat => 10)
|
12
|
-
c1.close
|
13
|
-
end
|
14
|
-
|
15
|
-
it "lets you specify connection timeout interval" do
|
16
|
-
c1 = HotBunnies.connect(:connection_timeout => 3)
|
17
|
-
c1.close
|
18
|
-
end
|
19
|
-
|
20
|
-
if !ENV["CI"] && ENV["TLS_TESTS"]
|
21
|
-
it "supports TLS w/o custom protocol or trust manager" do
|
22
|
-
c1 = HotBunnies.connect(:tls => true, :port => 5671)
|
23
|
-
c1.close
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "An AMQP consumer that catches exceptions" do
|
4
|
-
let(:connection) { HotBunnies.connect }
|
5
|
-
let(:channel) { connection.create_channel }
|
6
|
-
|
7
|
-
after :each do
|
8
|
-
channel.close
|
9
|
-
connection.close
|
10
|
-
end
|
11
|
-
|
12
|
-
it "stays up" do
|
13
|
-
mailbox = []
|
14
|
-
exchange = channel.exchange("hot_bunnies.exchanges.fanout#{Time.now.to_i}", :type => :fanout, :auto_delete => true)
|
15
|
-
queue = channel.queue("", :auto_delete => true)
|
16
|
-
|
17
|
-
queue.bind(exchange)
|
18
|
-
consumer = queue.subscribe(:blocking => false) do |meta, payload|
|
19
|
-
n = meta.properties.headers['X-Number']
|
20
|
-
|
21
|
-
begin
|
22
|
-
if n.odd?
|
23
|
-
raise "A failure"
|
24
|
-
else
|
25
|
-
mailbox << payload
|
26
|
-
end
|
27
|
-
rescue Exception => e
|
28
|
-
# no-op
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
25.times do |i|
|
33
|
-
exchange.publish("Message ##{i}", :routing_key => "xyz", :properties => {
|
34
|
-
:headers => {
|
35
|
-
'X-Number' => i
|
36
|
-
}
|
37
|
-
})
|
38
|
-
end
|
39
|
-
|
40
|
-
sleep(0.5)
|
41
|
-
|
42
|
-
mc, cc = queue.status
|
43
|
-
mc.should == 0
|
44
|
-
|
45
|
-
mailbox.size.should == 13
|
46
|
-
consumer.shutdown!
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
describe "An AMQP consumer that DOES NOT catch exceptions" do
|
54
|
-
let(:connection) { HotBunnies.connect }
|
55
|
-
let(:channel) { connection.create_channel }
|
56
|
-
|
57
|
-
after :each do
|
58
|
-
channel.close
|
59
|
-
connection.close
|
60
|
-
end
|
61
|
-
|
62
|
-
it "becomes inactive when the channels prefetch is filled with unacked messages" do
|
63
|
-
mailbox = []
|
64
|
-
exchange = channel.exchange("hot_bunnies.exchanges.fanout#{Time.now.to_i}#{rand}", :type => :fanout, :auto_delete => true)
|
65
|
-
queue = channel.queue("", :auto_delete => true)
|
66
|
-
|
67
|
-
channel.prefetch = 5
|
68
|
-
|
69
|
-
queue.bind(exchange)
|
70
|
-
consumer = queue.subscribe(:blocking => false, :ack => true) do |meta, payload|
|
71
|
-
n = meta.properties.headers['X-Number']
|
72
|
-
|
73
|
-
if n.odd?
|
74
|
-
raise "A failure"
|
75
|
-
else
|
76
|
-
mailbox << payload
|
77
|
-
meta.ack
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
25.times do |i|
|
82
|
-
exchange.publish("Message ##{i}", :routing_key => "xyz", :properties => {
|
83
|
-
:headers => {
|
84
|
-
'X-Number' => i
|
85
|
-
}
|
86
|
-
})
|
87
|
-
end
|
88
|
-
|
89
|
-
sleep(0.5)
|
90
|
-
|
91
|
-
message_count, _ = queue.status
|
92
|
-
message_count.should == 15
|
93
|
-
|
94
|
-
mailbox.size.should == 5
|
95
|
-
consumer.shutdown!
|
96
|
-
end
|
97
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe HotBunnies::Exchange do
|
4
|
-
let(:connection) { HotBunnies.connect }
|
5
|
-
let(:channel) { connection.create_channel }
|
6
|
-
|
7
|
-
after :each do
|
8
|
-
channel.close
|
9
|
-
connection.close
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should bind two exchanges using exchange instances" do
|
13
|
-
source = channel.exchange("hot_bunnies.spec.exchanges.source", :auto_delete => true)
|
14
|
-
destianation = channel.exchange("hot_bunnies.spec.exchanges.destination", :auto_delete => true)
|
15
|
-
|
16
|
-
queue = channel.queue("", :auto_delete => true)
|
17
|
-
queue.bind(destianation)
|
18
|
-
|
19
|
-
destianation.bind(source)
|
20
|
-
source.publish("")
|
21
|
-
queue.get.should_not be_nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should bind two exchanges using exchange name" do
|
25
|
-
source = channel.exchange("hot_bunnies.spec.exchanges.source", :auto_delete => true)
|
26
|
-
destianation = channel.exchange("hot_bunnies.spec.exchanges.destination", :auto_delete => true)
|
27
|
-
|
28
|
-
queue = channel.queue("", :auto_delete => true)
|
29
|
-
queue.bind(destianation)
|
30
|
-
|
31
|
-
destianation.bind(source.name)
|
32
|
-
source.publish("")
|
33
|
-
queue.get.should_not be_nil
|
34
|
-
end
|
35
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Direct exchange" do
|
4
|
-
let(:connection) { HotBunnies.connect }
|
5
|
-
let(:channel) { connection.create_channel }
|
6
|
-
|
7
|
-
after :each do
|
8
|
-
channel.close
|
9
|
-
connection.close
|
10
|
-
end
|
11
|
-
|
12
|
-
it "can be declared" do
|
13
|
-
exchange = channel.exchange("hot_bunnies.exchanges.direct1", :type => :direct)
|
14
|
-
queue = channel.queue("", :auto_delete => true)
|
15
|
-
|
16
|
-
queue.bind(exchange, :routing_key => "abc")
|
17
|
-
|
18
|
-
exchange.publish("", :routing_key => "xyz")
|
19
|
-
exchange.publish("", :routing_key => "abc")
|
20
|
-
|
21
|
-
sleep(0.3)
|
22
|
-
|
23
|
-
mc, cc = queue.status
|
24
|
-
mc.should == 1
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
describe "Fanout exchange" do
|
31
|
-
let(:connection) { HotBunnies.connect }
|
32
|
-
let(:channel) { connection.create_channel }
|
33
|
-
|
34
|
-
after :each do
|
35
|
-
channel.close
|
36
|
-
connection.close
|
37
|
-
end
|
38
|
-
|
39
|
-
it "can be declared" do
|
40
|
-
exchange = channel.exchange("hot_bunnies.exchanges.fanout1", :type => :fanout)
|
41
|
-
queue = channel.queue("", :auto_delete => true)
|
42
|
-
|
43
|
-
queue.bind(exchange)
|
44
|
-
|
45
|
-
exchange.publish("")
|
46
|
-
exchange.publish("", :routing_key => "xyz")
|
47
|
-
exchange.publish("", :routing_key => "abc")
|
48
|
-
|
49
|
-
sleep(0.5)
|
50
|
-
|
51
|
-
mc, cc = queue.status
|
52
|
-
mc.should == 3
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
describe "Topic exchange" do
|
59
|
-
let(:connection) { HotBunnies.connect }
|
60
|
-
let(:channel) { connection.create_channel }
|
61
|
-
|
62
|
-
after :each do
|
63
|
-
channel.close
|
64
|
-
connection.close
|
65
|
-
end
|
66
|
-
|
67
|
-
it "can be declared" do
|
68
|
-
exchange = channel.exchange("hot_bunnies.exchanges.topic1", :type => :topic)
|
69
|
-
queue = channel.queue("", :auto_delete => true)
|
70
|
-
|
71
|
-
queue.bind(exchange, :routing_key => "log.*")
|
72
|
-
|
73
|
-
exchange.publish("")
|
74
|
-
exchange.publish("", :routing_key => "accounts.signup")
|
75
|
-
exchange.publish("", :routing_key => "log.info")
|
76
|
-
exchange.publish("", :routing_key => "log.warn")
|
77
|
-
|
78
|
-
sleep(0.5)
|
79
|
-
|
80
|
-
mc, cc = queue.status
|
81
|
-
mc.should == 2
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
describe "Headers exchange" do
|
88
|
-
let(:connection) { HotBunnies.connect }
|
89
|
-
let(:channel) { connection.create_channel }
|
90
|
-
|
91
|
-
after :each do
|
92
|
-
channel.close
|
93
|
-
connection.close
|
94
|
-
end
|
95
|
-
|
96
|
-
it "can be declared" do
|
97
|
-
exchange = channel.exchange("hot_bunnies.exchanges.headers1", :type => :headers)
|
98
|
-
queue = channel.queue("", :auto_delete => true)
|
99
|
-
|
100
|
-
queue.bind(exchange, :arguments => { 'x-match' => 'all', 'arch' => "x86_64", 'os' => "linux" })
|
101
|
-
|
102
|
-
exchange.publish "For linux/IA64", :properties => { :headers => { 'arch' => "x86_64", 'os' => 'linux' } }
|
103
|
-
exchange.publish "For linux/x86", :properties => { :headers => { 'arch' => "x86", 'os' => 'linux' } }
|
104
|
-
exchange.publish "For any linux", :properties => { :headers => { 'os' => 'linux' } }
|
105
|
-
exchange.publish "For OS X", :properties => { :headers => { 'os' => 'macosx' } }
|
106
|
-
exchange.publish "For solaris/IA64", :properties => { :headers => { 'os' => 'solaris', 'arch' => 'x86_64' } }
|
107
|
-
|
108
|
-
sleep(0.3)
|
109
|
-
|
110
|
-
mc, cc = queue.status
|
111
|
-
mc.should == 1
|
112
|
-
end
|
113
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "An AMQP consumer" do
|
4
|
-
let(:connection) { HotBunnies.connect }
|
5
|
-
let(:channel) { connection.create_channel }
|
6
|
-
|
7
|
-
after :each do
|
8
|
-
channel.close
|
9
|
-
connection.close
|
10
|
-
end
|
11
|
-
|
12
|
-
it "can access message metadata (both message properties and delivery information)" do
|
13
|
-
latch = java.util.concurrent.CountDownLatch.new(1)
|
14
|
-
queue = channel.queue("", :auto_delete => true)
|
15
|
-
exchange = channel.exchange("amq.fanout", :type => :fanout)
|
16
|
-
|
17
|
-
queue.bind(exchange, :routing_key => "hotbunnies.key")
|
18
|
-
|
19
|
-
@now = Time.now
|
20
|
-
@payload = "Hello, world!"
|
21
|
-
@meta = nil
|
22
|
-
|
23
|
-
consumer = queue.subscribe(:blocking => false) do |metadata, payload|
|
24
|
-
begin
|
25
|
-
# we will run assertions on the main thread because RSpec uses exceptions
|
26
|
-
# for its purposes every once in a while. MK.
|
27
|
-
@meta = metadata
|
28
|
-
rescue Exception => e
|
29
|
-
e.print_stack_trace
|
30
|
-
ensure
|
31
|
-
latch.count_down
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
exchange.publish(@payload,
|
36
|
-
:properties => { :app_id => "hotbunnies.tests",
|
37
|
-
:priority => 8,
|
38
|
-
:type => "kinda.checkin",
|
39
|
-
# headers table keys can be anything
|
40
|
-
:headers => {
|
41
|
-
"coordinates" => {
|
42
|
-
"latitude" => 59.35,
|
43
|
-
"longitude" => 18.066667
|
44
|
-
},
|
45
|
-
"time" => @now,
|
46
|
-
"participants" => 11,
|
47
|
-
"venue" => "Stockholm",
|
48
|
-
"true_field" => true,
|
49
|
-
"false_field" => false,
|
50
|
-
"nil_field" => nil,
|
51
|
-
"ary_field" => ["one", 2.0, 3, [{ "abc" => 123 }]]
|
52
|
-
},
|
53
|
-
:timestamp => @now,
|
54
|
-
:reply_to => "a.sender",
|
55
|
-
:correlation_id => "r-1",
|
56
|
-
:message_id => "m-1",
|
57
|
-
:content_type => "application/octet-stream",
|
58
|
-
# just an example. MK.
|
59
|
-
:content_encoding => "zip/zap"
|
60
|
-
},
|
61
|
-
:routing_key => "hotbunnies.key")
|
62
|
-
latch.await
|
63
|
-
|
64
|
-
@meta.routing_key.should == "hotbunnies.key"
|
65
|
-
@meta.content_type.should == "application/octet-stream"
|
66
|
-
@meta.content_encoding.should == "zip/zap"
|
67
|
-
@meta.priority.should == 8
|
68
|
-
|
69
|
-
time = Time.at(@meta.headers["time"].getTime/1000)
|
70
|
-
time.to_i.should == @now.to_i
|
71
|
-
|
72
|
-
@meta.headers["coordinates"]["latitude"].should == 59.35
|
73
|
-
@meta.headers["participants"].should == 11
|
74
|
-
@meta.headers["true_field"].should == true
|
75
|
-
@meta.headers["false_field"].should == false
|
76
|
-
@meta.headers["nil_field"].should be_nil
|
77
|
-
|
78
|
-
@meta.timestamp.should == Time.at(@now.to_i)
|
79
|
-
@meta.type.should == "kinda.checkin"
|
80
|
-
@meta.consumer_tag.should_not be_nil
|
81
|
-
@meta.consumer_tag.should_not be_empty
|
82
|
-
@meta.delivery_tag.should == 1
|
83
|
-
@meta.reply_to.should == "a.sender"
|
84
|
-
@meta.correlation_id.should == "r-1"
|
85
|
-
@meta.message_id.should == "m-1"
|
86
|
-
@meta.should_not be_redelivered
|
87
|
-
|
88
|
-
@meta.app_id.should == "hotbunnies.tests"
|
89
|
-
@meta.exchange.should == "amq.fanout"
|
90
|
-
|
91
|
-
consumer.shut_down!
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Any channel" 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
|
-
let(:latch) { java.util.concurrent.CountDownLatch.new(1) }
|
18
|
-
|
19
|
-
class ConfirmationListener
|
20
|
-
include com.rabbitmq.client.ConfirmListener
|
21
|
-
|
22
|
-
def initialize(latch)
|
23
|
-
@latch = latch
|
24
|
-
end
|
25
|
-
|
26
|
-
def handle_ack(delivery_tag, multiple)
|
27
|
-
@latch.count_down
|
28
|
-
end
|
29
|
-
|
30
|
-
def handle_nack(delivery_tag, multiple)
|
31
|
-
@latch.count_down
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
# Examples
|
38
|
-
#
|
39
|
-
|
40
|
-
it "can use publisher confirmations with listener objects" do
|
41
|
-
channel.confirm_select
|
42
|
-
channel.add_confirm_listener(ConfirmationListener.new(latch))
|
43
|
-
|
44
|
-
queue = channel.queue("", :auto_delete => true)
|
45
|
-
Thread.new do
|
46
|
-
channel.default_exchange.publish("", :routing_key => queue.name)
|
47
|
-
end
|
48
|
-
|
49
|
-
latch.await
|
50
|
-
end
|
51
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "Any queue" do
|
5
|
-
|
6
|
-
#
|
7
|
-
# Environment
|
8
|
-
#
|
9
|
-
|
10
|
-
let(:connection) { HotBunnies.connect }
|
11
|
-
let(:channel) { connection.create_channel }
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
channel.close
|
15
|
-
connection.close
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
# Examples
|
21
|
-
#
|
22
|
-
|
23
|
-
it "can be bound to amq.fanout" do
|
24
|
-
exchange = channel.exchange("amq.fanout", :type => :fanout, :durable => true, :auto_delete => false)
|
25
|
-
queue = channel.queue("", :auto_delete => true)
|
26
|
-
exchange.publish("")
|
27
|
-
queue.get.should be_nil
|
28
|
-
|
29
|
-
queue.bind(exchange)
|
30
|
-
|
31
|
-
exchange.publish("", :routing_key => queue.name)
|
32
|
-
queue.get.should_not be_nil
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
it "can be bound to a newly declared exchange" do
|
37
|
-
exchange = channel.exchange("hot.bunnies.fanout", :type => :fanout, :durable => false, :auto_delete => true)
|
38
|
-
queue = channel.queue("", :auto_delete => true)
|
39
|
-
exchange.publish("")
|
40
|
-
queue.get.should be_nil
|
41
|
-
|
42
|
-
queue.bind(exchange)
|
43
|
-
|
44
|
-
exchange.publish("", :routing_key => queue.name)
|
45
|
-
queue.get.should_not be_nil
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
it "is automatically bound to the default exchange" do
|
50
|
-
exchange = channel.default_exchange
|
51
|
-
queue = channel.queue("", :auto_delete => true)
|
52
|
-
|
53
|
-
exchange.publish("", :routing_key => queue.name)
|
54
|
-
queue.get.should_not be_nil
|
55
|
-
end
|
56
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "Queue" do
|
5
|
-
context "with a server-generated name" do
|
6
|
-
let(:connection) { HotBunnies.connect }
|
7
|
-
let(:channel) { connection.create_channel }
|
8
|
-
|
9
|
-
after :each do
|
10
|
-
channel.close
|
11
|
-
connection.close
|
12
|
-
end
|
13
|
-
|
14
|
-
it "can be declared as auto-deleted" do
|
15
|
-
channel.queue("", :auto_delete => true)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "can be declared as auto-deleted and non-durable" do
|
19
|
-
channel.queue("", :auto_delete => true, :durable => false)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "can be declared as NON-auto-deleted" do
|
23
|
-
channel.queue("", :auto_delete => false)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "can be declared as NON-durable" do
|
27
|
-
channel.queue("", :durable => false)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "can be declared with additional attributes like x-message-ttle" do
|
31
|
-
queue = channel.queue("", :durable => false, :arguments => { 'x-message-ttl' => 2000 })
|
32
|
-
exchange = channel.exchange("", :type => :direct)
|
33
|
-
|
34
|
-
100.times do |i|
|
35
|
-
exchange.publish("Message #{i}", :routing_key => queue.name)
|
36
|
-
end
|
37
|
-
|
38
|
-
queue.get.should_not be_nil
|
39
|
-
sleep(2.1)
|
40
|
-
|
41
|
-
queue.get.should be_nil
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "Client-defined queue" do
|
5
|
-
|
6
|
-
#
|
7
|
-
# Environment
|
8
|
-
#
|
9
|
-
|
10
|
-
let(:connection) { HotBunnies.connect }
|
11
|
-
let(:channel) { connection.create_channel }
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
channel.close
|
15
|
-
connection.close
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
it "can be deleted" do
|
20
|
-
queue = channel.queue("", :auto_delete => true)
|
21
|
-
queue.delete
|
22
|
-
end
|
23
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "Any queue" do
|
5
|
-
|
6
|
-
#
|
7
|
-
# Environment
|
8
|
-
#
|
9
|
-
|
10
|
-
let(:connection) { HotBunnies.connect }
|
11
|
-
let(:channel) { connection.create_channel }
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
channel.close
|
15
|
-
connection.close
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
# Examples
|
21
|
-
#
|
22
|
-
|
23
|
-
it "can be purged" do
|
24
|
-
exchange = channel.exchange("amq.fanout", :type => :fanout, :durable => true, :auto_delete => false)
|
25
|
-
queue = channel.queue("", :auto_delete => true)
|
26
|
-
exchange.publish("")
|
27
|
-
queue.get.should be_nil
|
28
|
-
queue.purge
|
29
|
-
queue.get.should be_nil
|
30
|
-
|
31
|
-
queue.bind(exchange)
|
32
|
-
|
33
|
-
exchange.publish("", :routing_key => queue.name)
|
34
|
-
queue.get.should_not be_nil
|
35
|
-
queue.purge
|
36
|
-
queue.get.should be_nil
|
37
|
-
end
|
38
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "Any queue" do
|
5
|
-
|
6
|
-
#
|
7
|
-
# Environment
|
8
|
-
#
|
9
|
-
|
10
|
-
let(:connection) { HotBunnies.connect }
|
11
|
-
let(:channel) { connection.create_channel }
|
12
|
-
|
13
|
-
after :each do
|
14
|
-
channel.close
|
15
|
-
connection.close
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
# Examples
|
21
|
-
#
|
22
|
-
|
23
|
-
it "can be unbound from amq.fanout" do
|
24
|
-
exchange = channel.exchange("amq.fanout", :type => :fanout, :durable => true, :auto_delete => false)
|
25
|
-
queue = channel.queue("", :auto_delete => true)
|
26
|
-
|
27
|
-
queue.bind(exchange)
|
28
|
-
|
29
|
-
exchange.publish("", :routing_key => queue.name)
|
30
|
-
queue.get.should_not be_nil
|
31
|
-
|
32
|
-
queue.unbind(exchange)
|
33
|
-
|
34
|
-
exchange.publish("")
|
35
|
-
queue.get.should be_nil
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
it "can be unbound from a client-declared exchange" do
|
40
|
-
exchange = channel.exchange("hot.bunnies.fanout#{Time.now.to_i}", :type => :fanout, :durable => false)
|
41
|
-
queue = channel.queue("", :auto_delete => true)
|
42
|
-
|
43
|
-
queue.bind(exchange)
|
44
|
-
|
45
|
-
exchange.publish("", :routing_key => queue.name)
|
46
|
-
queue.get.should_not be_nil
|
47
|
-
|
48
|
-
queue.unbind(exchange)
|
49
|
-
|
50
|
-
exchange.publish("")
|
51
|
-
queue.get.should be_nil
|
52
|
-
end
|
53
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Any AMQP 0.9.1 client using RabbitMQ" 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 use CC and BCC headers for sender selected routing (a RabbitMQ-specific extension to AMQP 0.9.1)" do
|
23
|
-
queue1 = channel.queue("", :auto_delete => true)
|
24
|
-
queue2 = channel.queue("", :auto_delete => true)
|
25
|
-
queue3 = channel.queue("", :auto_delete => true)
|
26
|
-
queue4 = channel.queue("", :auto_delete => true)
|
27
|
-
|
28
|
-
channel.default_exchange.publish("1010", :properties => {
|
29
|
-
:headers => {
|
30
|
-
"CC" => [queue2.name],
|
31
|
-
"BCC" => [queue3.name]
|
32
|
-
}
|
33
|
-
}, :routing_key => queue1.name)
|
34
|
-
|
35
|
-
sleep 1
|
36
|
-
|
37
|
-
mc1, _ = queue1.status
|
38
|
-
mc2, _ = queue2.status
|
39
|
-
mc3, _ = queue3.status
|
40
|
-
mc4, _ = queue4.status
|
41
|
-
|
42
|
-
mc1.should == 1
|
43
|
-
mc2.should == 1
|
44
|
-
mc3.should == 1
|
45
|
-
mc4.should == 0
|
46
|
-
end
|
47
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
4
|
-
|
5
|
-
require 'bundler'
|
6
|
-
Bundler.setup(:default, :test)
|
7
|
-
|
8
|
-
case RUBY_VERSION
|
9
|
-
when "1.8.7" then
|
10
|
-
class Array
|
11
|
-
alias sample choice
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
require "hot_bunnies"
|
17
|
-
|
18
|
-
puts "Running on Ruby #{RUBY_VERSION}."
|