amqp 0.8.0.rc8 → 0.8.0.rc9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/Gemfile +4 -0
- data/amqp.gemspec +1 -4
- data/docs/GettingStarted.textile +1 -1
- data/examples/guides/getting_started/03_babblr.rb +2 -2
- data/examples/rack/publish_a_message_on_request/thin.ru +36 -0
- data/lib/amqp/connection.rb +30 -1
- data/lib/amqp/queue.rb +1 -1
- data/lib/amqp/utilities/event_loop_helper.rb +60 -22
- data/lib/amqp/utilities/server_type.rb +18 -0
- data/lib/amqp/version.rb +1 -1
- data/spec/integration/exchange_declaration_spec.rb +47 -45
- data/spec/integration/queue_declaration_spec.rb +10 -6
- data/spec/unit/amqp/connection_spec.rb +0 -45
- metadata +42 -71
- data/bin/jenkins.sh +0 -27
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -25,6 +25,10 @@ group(:development) do
|
|
25
25
|
|
26
26
|
custom_gem "nake", :platform => :ruby_19
|
27
27
|
custom_gem "contributors", :platform => :ruby_19
|
28
|
+
|
29
|
+
# To test event loop helper and various Rack apps
|
30
|
+
gem "thin"
|
31
|
+
gem "unicorn", :platform => :ruby
|
28
32
|
end
|
29
33
|
|
30
34
|
group(:test) do
|
data/amqp.gemspec
CHANGED
@@ -11,21 +11,18 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/ruby-amqp/amqp"
|
12
12
|
s.summary = "AMQP client implementation in Ruby/EventMachine."
|
13
13
|
s.description = "Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries included"
|
14
|
-
s.cert_chain = nil
|
15
14
|
s.email = ["bWljaGFlbEBub3ZlbWJlcmFpbi5jb20=\n", "c3Rhc3RueUAxMDFpZGVhcy5jeg==\n"].map { |i| Base64.decode64(i) }
|
16
15
|
|
17
16
|
# files
|
18
17
|
s.files = `git ls-files`.split("\n").reject { |file| file =~ /^vendor\// || file =~ /^gemfiles\// }
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
21
|
-
# RDoc
|
22
|
-
s.has_rdoc = true
|
23
20
|
s.rdoc_options = '--include=examples --main README.textile'
|
24
21
|
s.extra_rdoc_files = ["README.textile"] + Dir.glob("docs/*")
|
25
22
|
|
26
23
|
# Dependencies
|
27
24
|
s.add_dependency "eventmachine"
|
28
|
-
s.add_dependency "amq-client", ">= 0.7.0.
|
25
|
+
s.add_dependency "amq-client", ">= 0.7.0.alpha21"
|
29
26
|
|
30
27
|
begin
|
31
28
|
require "changelog"
|
data/docs/GettingStarted.textile
CHANGED
@@ -22,8 +22,8 @@ AMQP.start("amqp://dev.rabbitmq.com:5672/") do |connection|
|
|
22
22
|
|
23
23
|
exchange.publish("BOS 101, NYK 89").publish("ORL 85, ALT 88")
|
24
24
|
|
25
|
-
# disconnect & exit after
|
26
|
-
EventMachine.add_timer(
|
25
|
+
# disconnect & exit after 2 seconds
|
26
|
+
EventMachine.add_timer(2) do
|
27
27
|
exchange.delete
|
28
28
|
|
29
29
|
connection.close {
|
@@ -0,0 +1,36 @@
|
|
1
|
+
use Rack::CommonLogger
|
2
|
+
|
3
|
+
require "bundler"
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
$:.unshift(File.expand_path("../../../../lib", __FILE__))
|
7
|
+
|
8
|
+
require 'amqp'
|
9
|
+
require 'amqp/utilities/event_loop_helper'
|
10
|
+
|
11
|
+
puts "EventMachine.reactor_running? => #{EventMachine.reactor_running?.inspect}"
|
12
|
+
|
13
|
+
AMQP::Utilities::EventLoopHelper.run do
|
14
|
+
AMQP.start
|
15
|
+
|
16
|
+
exchange = AMQP.channel.fanout("amq.fanout")
|
17
|
+
|
18
|
+
q = AMQP.channel.queue("", :auto_delete => true, :exclusive => true)
|
19
|
+
q.bind(exchange)
|
20
|
+
AMQP::channel.default_exchange.publish("Started!", :routing_key => q.name)
|
21
|
+
end
|
22
|
+
|
23
|
+
app = proc do |env|
|
24
|
+
AMQP.channel.fanout("amq.fanout").publish("Served a request at (#{Time.now.to_i})")
|
25
|
+
|
26
|
+
[
|
27
|
+
200, # Status code
|
28
|
+
{ # Response headers
|
29
|
+
'Content-Type' => 'text/html',
|
30
|
+
'Content-Length' => '2',
|
31
|
+
},
|
32
|
+
['hi'] # Response body
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
run app
|
data/lib/amqp/connection.rb
CHANGED
@@ -38,6 +38,7 @@ module AMQP
|
|
38
38
|
def self.start(connection_options_or_string = {}, other_options = {}, &block)
|
39
39
|
EM.run do
|
40
40
|
@connection ||= connect(connection_options_or_string, other_options, &block)
|
41
|
+
@channel = Channel.new(@connection)
|
41
42
|
@connection
|
42
43
|
end
|
43
44
|
end
|
@@ -59,8 +60,15 @@ module AMQP
|
|
59
60
|
return if @connection.nil? || self.closing?
|
60
61
|
|
61
62
|
EM.next_tick do
|
63
|
+
if AMQP.channel and AMQP.channel.open? and AMQP.channel.connection.open?
|
64
|
+
AMQP.channel.close
|
65
|
+
end
|
66
|
+
AMQP.channel = nil
|
67
|
+
|
68
|
+
|
62
69
|
shim = Proc.new {
|
63
70
|
block.call
|
71
|
+
|
64
72
|
AMQP.connection = nil
|
65
73
|
}
|
66
74
|
@connection.disconnect(reply_code, reply_text, &shim)
|
@@ -95,6 +103,26 @@ module AMQP
|
|
95
103
|
@connection
|
96
104
|
end
|
97
105
|
|
106
|
+
# "Default channel". A placeholder for apps that only want to use one channel. This channel is not global, *not* used
|
107
|
+
# under the hood by methods like {AMQP::Exchange#initialize} and only shared by exchanges/queues you decide on.
|
108
|
+
# To reiterate: this is only a conventience accessor, since many apps (especially Web apps) can get by with just one
|
109
|
+
# connection and one channel.
|
110
|
+
#
|
111
|
+
# @api public
|
112
|
+
def self.channel
|
113
|
+
@channel
|
114
|
+
end
|
115
|
+
|
116
|
+
# A placeholder for applications that only need one channel. If you use {AMQP.start} to set up default connection,
|
117
|
+
# {AMQP.channel} is open on that connection, but can be replaced by your application.
|
118
|
+
#
|
119
|
+
#
|
120
|
+
# @see AMQP.channel
|
121
|
+
# @api public
|
122
|
+
def self.channel=(value)
|
123
|
+
@channel = value
|
124
|
+
end
|
125
|
+
|
98
126
|
# Sets global connection object.
|
99
127
|
# @api public
|
100
128
|
def self.connection=(value)
|
@@ -176,7 +204,8 @@ module AMQP
|
|
176
204
|
# To handle it, pass a callable object (a proc, a lambda, an instance of a class that responds to #call)
|
177
205
|
# with :on_possible_authentication_failure option.
|
178
206
|
#
|
179
|
-
# @note This method assumes that EventMachine even loop is already running. If it is not the case or you are not sure, we recommend you use {AMQP.start} instead.
|
207
|
+
# @note This method assumes that EventMachine even loop is already running. If it is not the case or you are not sure, we recommend you use {AMQP.start} instead.
|
208
|
+
# It takes exactly the same parameters.
|
180
209
|
# @return [AMQP::Session]
|
181
210
|
# @api public
|
182
211
|
def self.connect(connection_options_or_string = {}, other_options = {}, &block)
|
data/lib/amqp/queue.rb
CHANGED
@@ -1,8 +1,21 @@
|
|
1
1
|
require "eventmachine"
|
2
2
|
require "amqp/utilities/server_type"
|
3
3
|
|
4
|
+
require "thread"
|
5
|
+
|
4
6
|
module AMQP
|
5
7
|
module Utilities
|
8
|
+
|
9
|
+
# A helper that starts EventMachine reactor the optimal way depending on what Web server
|
10
|
+
# (if any) you are running. It should not be considered a 100% safe, general purpose EventMachine
|
11
|
+
# reactor "on/off switch" but is very useful in Web applications and some stand-alone applications.
|
12
|
+
#
|
13
|
+
# This helper was inspired by Qusion project by Dan DeLeo.
|
14
|
+
#
|
15
|
+
# h2. Key methods
|
16
|
+
#
|
17
|
+
# * {EventLoopHelper.run}
|
18
|
+
# * {EventLoopHelper.server_type}
|
6
19
|
class EventLoopHelper
|
7
20
|
|
8
21
|
def self.eventmachine_thread
|
@@ -13,36 +26,61 @@ module AMQP
|
|
13
26
|
EventMachine.reactor_running?
|
14
27
|
end # self.reactor_running?
|
15
28
|
|
29
|
+
# Type of server (if any) that is running.
|
30
|
+
#
|
31
|
+
# @see AMQP::Utilities::ServerType.detect
|
16
32
|
def self.server_type
|
17
33
|
@server_type ||= ServerType.detect
|
18
34
|
end # self.server_type
|
19
35
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
36
|
+
# A helper that detects what app server (if any) is running and starts
|
37
|
+
# EventMachine reactor in the most optimal way. For event-driven servers like
|
38
|
+
# Thin and Goliath, this means relying on them starting the reactor but delaying
|
39
|
+
# execution of a block you pass to {EventLoopHelper.run} until reactor is actually running.
|
40
|
+
#
|
41
|
+
# For Unicorn, Passenger, Mongrel and other servers and standalone apps EventMachine is started
|
42
|
+
# in a separate thread.
|
43
|
+
#
|
44
|
+
# @example Using EventLoopHelper.run to start EventMachine reactor the optimal way without blocking current thread
|
45
|
+
#
|
46
|
+
# AMQP::Utilities::EventLoopHelper.run do
|
47
|
+
# # Sets up default connection, accessible via AMQP.connection, and opens a channel
|
48
|
+
# # accessible via AMQP.channel for convenience
|
49
|
+
# AMQP.start
|
50
|
+
#
|
51
|
+
# exchange = AMQP.channel.fanout("amq.fanout")
|
52
|
+
#
|
53
|
+
# AMQP.channel.queue("", :auto_delete => true, :exclusive => true).bind(exchange)
|
54
|
+
# AMQP::channel.default_exchange.publish("Started!", :routing_key => AMQP::State.queue.name)
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# @return [Thread] A thread EventMachine event loop will be started in (there is no guarantee it is already running).
|
58
|
+
#
|
59
|
+
#
|
60
|
+
# @note This method, unlike EventMachine.run, DOES NOT block current thread.
|
61
|
+
def self.run(&block)
|
62
|
+
@eventmachine_thread ||= begin
|
63
|
+
case self.server_type
|
64
|
+
when :thin, :goliath, :evented_mongrel then
|
65
|
+
EventMachine.next_tick { block.call }
|
66
|
+
Thread.current
|
67
|
+
when :unicorn, :passenger, :mongrel, :scgi, :webrick, nil then
|
68
|
+
t = Thread.new { EventMachine.run(&block) }
|
69
|
+
# give EventMachine reactor some time to start
|
70
|
+
sleep(0.25)
|
28
71
|
|
29
|
-
|
30
|
-
|
31
|
-
|
72
|
+
t
|
73
|
+
else
|
74
|
+
t = Thread.new { EventMachine.run(&block) }
|
75
|
+
# give EventMachine reactor some time to start
|
76
|
+
sleep(0.25)
|
32
77
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# give EventMachine reactor some time to start
|
37
|
-
sleep(0.25)
|
38
|
-
|
39
|
-
t
|
40
|
-
end
|
78
|
+
t
|
79
|
+
end
|
80
|
+
end
|
41
81
|
end # self.run
|
42
82
|
|
43
|
-
|
44
|
-
EventMachine.stop
|
45
|
-
end
|
83
|
+
|
46
84
|
end # EventLoopHelper
|
47
85
|
end # Utilities
|
48
86
|
end # AMQP
|
@@ -23,7 +23,25 @@
|
|
23
23
|
|
24
24
|
module AMQP
|
25
25
|
module Utilities
|
26
|
+
# A helper that detects Web server that may be running (if any). Partially derived
|
27
|
+
# from Qusion project by Daniel DeLeo.
|
26
28
|
class ServerType
|
29
|
+
|
30
|
+
# Return a symbol representing Web server that is running (if any).
|
31
|
+
#
|
32
|
+
# Possible values are:
|
33
|
+
#
|
34
|
+
# * :thin for Thin
|
35
|
+
# * :unicorn for Unicorn
|
36
|
+
# * :passenger for Passenger (Apache mod_rack)
|
37
|
+
# * :goliath for PostRank's Goliath
|
38
|
+
# * :evented_mongrel for Swiftiply's Evented Mongrel
|
39
|
+
# * :mongrel for Mongrel
|
40
|
+
# * :scgi for SCGI
|
41
|
+
# * :webrick for WEBrick
|
42
|
+
# * nil: none of the above (the case for non-Web application, for example)
|
43
|
+
#
|
44
|
+
# @return [Symbol]
|
27
45
|
def self.detect
|
28
46
|
if defined?(::PhusionPassenger)
|
29
47
|
:passenger
|
data/lib/amqp/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe AMQP do
|
5
|
+
describe AMQP::Channel do
|
6
6
|
|
7
7
|
#
|
8
8
|
# Environment
|
@@ -10,13 +10,15 @@ describe AMQP do
|
|
10
10
|
|
11
11
|
include EventedSpec::AMQPSpec
|
12
12
|
|
13
|
-
default_timeout
|
13
|
+
default_timeout 2
|
14
|
+
|
14
15
|
|
15
16
|
amqp_before do
|
16
17
|
@channel = AMQP::Channel.new
|
17
18
|
end
|
18
19
|
|
19
20
|
|
21
|
+
|
20
22
|
#
|
21
23
|
# Examples
|
22
24
|
#
|
@@ -26,7 +28,7 @@ describe AMQP do
|
|
26
28
|
it 'declares a new direct exchange with that name' do
|
27
29
|
@channel.direct('name').name.should == 'name'
|
28
30
|
|
29
|
-
done
|
31
|
+
done(0.3)
|
30
32
|
end
|
31
33
|
|
32
34
|
it "declares direct exchange as transient (non-durable)" do
|
@@ -35,7 +37,7 @@ describe AMQP do
|
|
35
37
|
exchange.should_not be_durable
|
36
38
|
exchange.should be_transient
|
37
39
|
|
38
|
-
done
|
40
|
+
done(0.3)
|
39
41
|
end
|
40
42
|
|
41
43
|
it "declares direct exchange as non-auto-deleted" do
|
@@ -43,7 +45,7 @@ describe AMQP do
|
|
43
45
|
|
44
46
|
exchange.should_not be_auto_deleted
|
45
47
|
|
46
|
-
done
|
48
|
+
done(0.3)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -51,7 +53,7 @@ describe AMQP do
|
|
51
53
|
context "when exchange name is omitted" do
|
52
54
|
it 'uses amq.direct' do
|
53
55
|
@channel.direct.name.should == 'amq.direct'
|
54
|
-
done
|
56
|
+
done(0.3)
|
55
57
|
end # it
|
56
58
|
end # context
|
57
59
|
|
@@ -64,7 +66,7 @@ describe AMQP do
|
|
64
66
|
EOF
|
65
67
|
@channel.direct("") do |exchange|
|
66
68
|
exchange.name.should_not be_empty
|
67
|
-
done
|
69
|
+
done(0.3)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end # context
|
@@ -80,7 +82,7 @@ describe AMQP do
|
|
80
82
|
|
81
83
|
exchange.should == original_exchange
|
82
84
|
|
83
|
-
done
|
85
|
+
done(0.3)
|
84
86
|
end # it
|
85
87
|
end
|
86
88
|
|
@@ -92,7 +94,7 @@ describe AMQP do
|
|
92
94
|
exchange = @channel.direct("direct exchange declared at #{Time.now.to_i}", :passive => true)
|
93
95
|
}.to raise_error
|
94
96
|
|
95
|
-
done
|
97
|
+
done(0.3)
|
96
98
|
end # it
|
97
99
|
end # context
|
98
100
|
end # context
|
@@ -104,7 +106,7 @@ describe AMQP do
|
|
104
106
|
exchange.should be_durable
|
105
107
|
exchange.should_not be_transient
|
106
108
|
|
107
|
-
done
|
109
|
+
done(0.3)
|
108
110
|
end # it
|
109
111
|
end # context
|
110
112
|
|
@@ -115,7 +117,7 @@ describe AMQP do
|
|
115
117
|
exchange.should_not be_durable
|
116
118
|
exchange.should be_transient
|
117
119
|
|
118
|
-
done
|
120
|
+
done(0.3)
|
119
121
|
end # it
|
120
122
|
end # context
|
121
123
|
|
@@ -125,7 +127,7 @@ describe AMQP do
|
|
125
127
|
exchange = @channel.direct("a new auto-deleted direct exchange", :auto_delete => true)
|
126
128
|
|
127
129
|
exchange.should be_auto_deleted
|
128
|
-
done
|
130
|
+
done(0.3)
|
129
131
|
end # it
|
130
132
|
end # context
|
131
133
|
|
@@ -135,7 +137,7 @@ describe AMQP do
|
|
135
137
|
exchange = @channel.direct("a new non-auto-deleted direct exchange", :auto_delete => false)
|
136
138
|
|
137
139
|
exchange.should_not be_auto_deleted
|
138
|
-
done
|
140
|
+
done(0.3)
|
139
141
|
end # it
|
140
142
|
end # context
|
141
143
|
|
@@ -145,7 +147,7 @@ describe AMQP do
|
|
145
147
|
exchange = @channel.direct("a new non-auto-deleted direct exchange", :auto_delete => false)
|
146
148
|
|
147
149
|
exchange.should_not be_auto_deleted
|
148
|
-
done
|
150
|
+
done(0.3)
|
149
151
|
end # it
|
150
152
|
end # context
|
151
153
|
|
@@ -158,7 +160,7 @@ describe AMQP do
|
|
158
160
|
@channel.direct("previously.declared.durable.direct.exchange", :durable => false)
|
159
161
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
160
162
|
|
161
|
-
done
|
163
|
+
done(0.3)
|
162
164
|
end # it
|
163
165
|
end # context
|
164
166
|
end # describe
|
@@ -175,7 +177,7 @@ describe AMQP do
|
|
175
177
|
|
176
178
|
exchange.name.should == name
|
177
179
|
|
178
|
-
done
|
180
|
+
done(0.3)
|
179
181
|
end
|
180
182
|
end # context
|
181
183
|
|
@@ -185,7 +187,7 @@ describe AMQP do
|
|
185
187
|
exchange.name.should == "amq.fanout"
|
186
188
|
exchange.name.should_not == "amq.fanout2"
|
187
189
|
|
188
|
-
done
|
190
|
+
done(0.3)
|
189
191
|
end
|
190
192
|
end # context
|
191
193
|
|
@@ -199,7 +201,7 @@ describe AMQP do
|
|
199
201
|
|
200
202
|
exchange.should == original_exchange
|
201
203
|
|
202
|
-
done
|
204
|
+
done(0.3)
|
203
205
|
end # it
|
204
206
|
end
|
205
207
|
|
@@ -211,7 +213,7 @@ describe AMQP do
|
|
211
213
|
exchange = @channel.fanout("fanout exchange declared at #{Time.now.to_i}", :passive => true)
|
212
214
|
}.to raise_error
|
213
215
|
|
214
|
-
done
|
216
|
+
done(0.3)
|
215
217
|
end # it
|
216
218
|
end # context
|
217
219
|
end # context
|
@@ -223,7 +225,7 @@ describe AMQP do
|
|
223
225
|
exchange.should be_durable
|
224
226
|
exchange.should_not be_transient
|
225
227
|
|
226
|
-
done
|
228
|
+
done(0.3)
|
227
229
|
end # it
|
228
230
|
end # context
|
229
231
|
|
@@ -234,7 +236,7 @@ describe AMQP do
|
|
234
236
|
exchange.should_not be_durable
|
235
237
|
exchange.should be_transient
|
236
238
|
|
237
|
-
done
|
239
|
+
done(0.3)
|
238
240
|
end # it
|
239
241
|
end # context
|
240
242
|
|
@@ -244,7 +246,7 @@ describe AMQP do
|
|
244
246
|
exchange = @channel.fanout("a new auto-deleted fanout exchange", :auto_delete => true)
|
245
247
|
|
246
248
|
exchange.should be_auto_deleted
|
247
|
-
done
|
249
|
+
done(0.3)
|
248
250
|
end # it
|
249
251
|
end # context
|
250
252
|
|
@@ -254,7 +256,7 @@ describe AMQP do
|
|
254
256
|
exchange = @channel.fanout("a new non-auto-deleted fanout exchange", :auto_delete => false)
|
255
257
|
|
256
258
|
exchange.should_not be_auto_deleted
|
257
|
-
done
|
259
|
+
done(0.3)
|
258
260
|
end # it
|
259
261
|
end # context
|
260
262
|
|
@@ -264,7 +266,7 @@ describe AMQP do
|
|
264
266
|
exchange = @channel.fanout("a new non-auto-deleted fanout exchange", :auto_delete => false)
|
265
267
|
|
266
268
|
exchange.should_not be_auto_deleted
|
267
|
-
done
|
269
|
+
done(0.3)
|
268
270
|
end # it
|
269
271
|
end # context
|
270
272
|
|
@@ -277,7 +279,7 @@ describe AMQP do
|
|
277
279
|
@channel.fanout("previously.declared.durable.topic.exchange", :durable => false)
|
278
280
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
279
281
|
|
280
|
-
done
|
282
|
+
done(0.3)
|
281
283
|
end # it
|
282
284
|
end # context
|
283
285
|
end # describe
|
@@ -293,7 +295,7 @@ describe AMQP do
|
|
293
295
|
exchange = @channel.topic(name)
|
294
296
|
exchange.name.should == name
|
295
297
|
|
296
|
-
done
|
298
|
+
done(0.3)
|
297
299
|
end
|
298
300
|
end # context
|
299
301
|
|
@@ -303,7 +305,7 @@ describe AMQP do
|
|
303
305
|
exchange.name.should == "amq.topic"
|
304
306
|
exchange.name.should_not == "amq.topic2"
|
305
307
|
|
306
|
-
done
|
308
|
+
done(0.3)
|
307
309
|
end
|
308
310
|
end # context
|
309
311
|
|
@@ -317,7 +319,7 @@ describe AMQP do
|
|
317
319
|
|
318
320
|
exchange.should == original_exchange
|
319
321
|
|
320
|
-
done
|
322
|
+
done(0.3)
|
321
323
|
end # it
|
322
324
|
end
|
323
325
|
|
@@ -329,7 +331,7 @@ describe AMQP do
|
|
329
331
|
exchange = @channel.topic("topic exchange declared at #{Time.now.to_i}", :passive => true)
|
330
332
|
}.to raise_error
|
331
333
|
|
332
|
-
done
|
334
|
+
done(0.3)
|
333
335
|
end # it
|
334
336
|
end # context
|
335
337
|
end # context
|
@@ -341,7 +343,7 @@ describe AMQP do
|
|
341
343
|
exchange.should be_durable
|
342
344
|
exchange.should_not be_transient
|
343
345
|
|
344
|
-
done
|
346
|
+
done(0.3)
|
345
347
|
end # it
|
346
348
|
end # context
|
347
349
|
|
@@ -352,7 +354,7 @@ describe AMQP do
|
|
352
354
|
exchange.should_not be_durable
|
353
355
|
exchange.should be_transient
|
354
356
|
|
355
|
-
done
|
357
|
+
done(0.3)
|
356
358
|
end # it
|
357
359
|
end # context
|
358
360
|
|
@@ -362,7 +364,7 @@ describe AMQP do
|
|
362
364
|
exchange = @channel.topic("a new auto-deleted topic exchange", :auto_delete => true)
|
363
365
|
|
364
366
|
exchange.should be_auto_deleted
|
365
|
-
done
|
367
|
+
done(0.3)
|
366
368
|
end # it
|
367
369
|
end # context
|
368
370
|
|
@@ -372,7 +374,7 @@ describe AMQP do
|
|
372
374
|
exchange = @channel.topic("a new non-auto-deleted topic exchange", :auto_delete => false)
|
373
375
|
|
374
376
|
exchange.should_not be_auto_deleted
|
375
|
-
done
|
377
|
+
done(0.3)
|
376
378
|
end # it
|
377
379
|
end # context
|
378
380
|
|
@@ -382,7 +384,7 @@ describe AMQP do
|
|
382
384
|
exchange = @channel.topic("a new non-auto-deleted topic exchange", :auto_delete => false)
|
383
385
|
|
384
386
|
exchange.should_not be_auto_deleted
|
385
|
-
done
|
387
|
+
done(0.3)
|
386
388
|
end # it
|
387
389
|
end # context
|
388
390
|
|
@@ -402,7 +404,7 @@ describe AMQP do
|
|
402
404
|
channel.topic("previously.declared.durable.topic.exchange", :durable => false)
|
403
405
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
404
406
|
|
405
|
-
done
|
407
|
+
done(0.3)
|
406
408
|
end # it
|
407
409
|
end # context
|
408
410
|
end # describe
|
@@ -419,7 +421,7 @@ describe AMQP do
|
|
419
421
|
|
420
422
|
exchange.name.should == name
|
421
423
|
|
422
|
-
done
|
424
|
+
done(0.3)
|
423
425
|
end
|
424
426
|
end # context
|
425
427
|
|
@@ -433,7 +435,7 @@ describe AMQP do
|
|
433
435
|
exchange.name.should == "amq.match"
|
434
436
|
exchange.name.should_not == "amq.headers"
|
435
437
|
|
436
|
-
done
|
438
|
+
done(0.3)
|
437
439
|
end
|
438
440
|
end # context
|
439
441
|
|
@@ -447,7 +449,7 @@ describe AMQP do
|
|
447
449
|
|
448
450
|
exchange.should == original_exchange
|
449
451
|
|
450
|
-
done
|
452
|
+
done(0.3)
|
451
453
|
end # it
|
452
454
|
end
|
453
455
|
|
@@ -459,7 +461,7 @@ describe AMQP do
|
|
459
461
|
exchange = @channel.headers("headers exchange declared at #{Time.now.to_i}", :passive => true)
|
460
462
|
}.to raise_error
|
461
463
|
|
462
|
-
done
|
464
|
+
done(0.3)
|
463
465
|
end # it
|
464
466
|
end # context
|
465
467
|
end # context
|
@@ -471,7 +473,7 @@ describe AMQP do
|
|
471
473
|
exchange.should be_durable
|
472
474
|
exchange.should_not be_transient
|
473
475
|
|
474
|
-
done
|
476
|
+
done(0.3)
|
475
477
|
end # it
|
476
478
|
end # context
|
477
479
|
|
@@ -482,7 +484,7 @@ describe AMQP do
|
|
482
484
|
exchange.should_not be_durable
|
483
485
|
exchange.should be_transient
|
484
486
|
|
485
|
-
done
|
487
|
+
done(0.3)
|
486
488
|
end # it
|
487
489
|
end # context
|
488
490
|
|
@@ -492,7 +494,7 @@ describe AMQP do
|
|
492
494
|
exchange = @channel.headers("a new auto-deleted headers exchange", :auto_delete => true)
|
493
495
|
|
494
496
|
exchange.should be_auto_deleted
|
495
|
-
done
|
497
|
+
done(0.3)
|
496
498
|
end # it
|
497
499
|
end # context
|
498
500
|
|
@@ -502,7 +504,7 @@ describe AMQP do
|
|
502
504
|
exchange = @channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false)
|
503
505
|
|
504
506
|
exchange.should_not be_auto_deleted
|
505
|
-
done
|
507
|
+
done(0.3)
|
506
508
|
end # it
|
507
509
|
end # context
|
508
510
|
|
@@ -512,7 +514,7 @@ describe AMQP do
|
|
512
514
|
exchange = @channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false)
|
513
515
|
|
514
516
|
exchange.should_not be_auto_deleted
|
515
|
-
done
|
517
|
+
done(0.3)
|
516
518
|
end # it
|
517
519
|
end # context
|
518
520
|
|
@@ -529,7 +531,7 @@ describe AMQP do
|
|
529
531
|
@channel.headers("previously.declared.durable.topic.exchange", :durable => false)
|
530
532
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
531
533
|
|
532
|
-
done
|
534
|
+
done(0.3)
|
533
535
|
end # it
|
534
536
|
end # context
|
535
537
|
end # describe
|
@@ -16,6 +16,10 @@ describe AMQP do
|
|
16
16
|
@channel = AMQP::Channel.new
|
17
17
|
end
|
18
18
|
|
19
|
+
after(:all) do
|
20
|
+
AMQP.cleanup_state
|
21
|
+
done(0.3)
|
22
|
+
end
|
19
23
|
|
20
24
|
#
|
21
25
|
# Examples
|
@@ -28,13 +32,13 @@ describe AMQP do
|
|
28
32
|
it "declares a new queue with that name" do
|
29
33
|
queue = @channel.queue(name)
|
30
34
|
queue.name.should == name
|
31
|
-
done
|
35
|
+
done(0.3)
|
32
36
|
end
|
33
37
|
|
34
38
|
it "caches that queue" do
|
35
39
|
queue = @channel.queue(name)
|
36
40
|
@channel.queue(name).object_id.should == queue.object_id
|
37
|
-
done
|
41
|
+
done(0.3)
|
38
42
|
end
|
39
43
|
end # context
|
40
44
|
|
@@ -68,7 +72,7 @@ describe AMQP do
|
|
68
72
|
@channel.queue(name, different_options)
|
69
73
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
70
74
|
@queue.delete
|
71
|
-
done(0.
|
75
|
+
done(0.3)
|
72
76
|
end
|
73
77
|
end
|
74
78
|
end
|
@@ -83,7 +87,7 @@ describe AMQP do
|
|
83
87
|
|
84
88
|
queue.should == original_queue
|
85
89
|
|
86
|
-
done
|
90
|
+
done(0.3)
|
87
91
|
end # it
|
88
92
|
end
|
89
93
|
|
@@ -95,7 +99,7 @@ describe AMQP do
|
|
95
99
|
exchange = @channel.queue("queue declared at #{Time.now.to_i}", :passive => true)
|
96
100
|
}.to raise_error
|
97
101
|
|
98
|
-
done
|
102
|
+
done(0.3)
|
99
103
|
end # it
|
100
104
|
end # context
|
101
105
|
end # context
|
@@ -111,7 +115,7 @@ describe AMQP do
|
|
111
115
|
@channel.queue("previously.declared.durable.queue", :durable => false)
|
112
116
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
113
117
|
|
114
|
-
done
|
118
|
+
done(0.3)
|
115
119
|
end # it
|
116
120
|
end # context
|
117
121
|
end # describe
|
@@ -74,49 +74,4 @@ describe AMQP, 'class object' do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end # .start
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
describe '.stop' do
|
82
|
-
context "when connection is not established" do
|
83
|
-
it 'is a no-op' do
|
84
|
-
AMQP.stop
|
85
|
-
AMQP.stop
|
86
|
-
|
87
|
-
@res = AMQP.stop
|
88
|
-
@res.should be_nil
|
89
|
-
end # it
|
90
|
-
end # context
|
91
|
-
|
92
|
-
|
93
|
-
context 'with established AMQP connection' do
|
94
|
-
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
|
99
|
-
include EventedSpec::EMSpec
|
100
|
-
default_options AMQP_OPTS
|
101
|
-
#
|
102
|
-
# Examples
|
103
|
-
#
|
104
|
-
|
105
|
-
it 'properly closes AMQP broker connection and fires a callback. Mind the delay!' do
|
106
|
-
AMQP.start(AMQP_OPTS) do
|
107
|
-
AMQP.connection.should be_connected
|
108
|
-
|
109
|
-
@block_has_fired = false
|
110
|
-
|
111
|
-
AMQP.stop do
|
112
|
-
@block_has_fired = true
|
113
|
-
end
|
114
|
-
AMQP.connection.should_not be_nil
|
115
|
-
done(0.1) do
|
116
|
-
@block_has_fired.should be_true
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end # it
|
120
|
-
end # context
|
121
|
-
end # describe
|
122
77
|
end # describe AMQP
|
metadata
CHANGED
@@ -1,65 +1,48 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 8
|
9
|
-
- 0
|
10
|
-
- rc8
|
11
|
-
version: 0.8.0.rc8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0.rc9
|
5
|
+
prerelease: 6
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- Aman Gupta
|
15
9
|
- Jakub Stastny aka botanicus
|
16
10
|
- Michael S. Klishin
|
17
11
|
autorequire:
|
18
12
|
bindir: bin
|
19
|
-
cert_chain:
|
20
|
-
date: 2011-05-
|
21
|
-
|
22
|
-
|
23
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
cert_chain: []
|
14
|
+
date: 2011-05-10 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
24
17
|
name: eventmachine
|
25
|
-
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &2152811580 !ruby/object:Gem::Requirement
|
27
19
|
none: false
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
|
32
|
-
segments:
|
33
|
-
- 0
|
34
|
-
version: "0"
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
35
24
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: amq-client
|
39
25
|
prerelease: false
|
40
|
-
|
26
|
+
version_requirements: *2152811580
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: amq-client
|
29
|
+
requirement: &2152833600 !ruby/object:Gem::Requirement
|
41
30
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 7
|
49
|
-
- 0
|
50
|
-
- alpha20
|
51
|
-
version: 0.7.0.alpha20
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.0.alpha21
|
52
35
|
type: :runtime
|
53
|
-
|
54
|
-
|
55
|
-
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *2152833600
|
38
|
+
description: Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries
|
39
|
+
included
|
40
|
+
email:
|
56
41
|
- michael@novemberain.com
|
57
42
|
- stastny@101ideas.cz
|
58
43
|
executables: []
|
59
|
-
|
60
44
|
extensions: []
|
61
|
-
|
62
|
-
extra_rdoc_files:
|
45
|
+
extra_rdoc_files:
|
63
46
|
- README.textile
|
64
47
|
- docs/08Migration.textile
|
65
48
|
- docs/Bindings.textile
|
@@ -75,7 +58,7 @@ extra_rdoc_files:
|
|
75
58
|
- docs/RabbitMQVersions.textile
|
76
59
|
- docs/Routing.textile
|
77
60
|
- docs/VendorSpecificExtensions.textile
|
78
|
-
files:
|
61
|
+
files:
|
79
62
|
- .gitignore
|
80
63
|
- .rspec
|
81
64
|
- .travis.yml
|
@@ -88,7 +71,6 @@ files:
|
|
88
71
|
- amqp.gemspec
|
89
72
|
- bin/cleanify.rb
|
90
73
|
- bin/irb
|
91
|
-
- bin/jenkins.sh
|
92
74
|
- bin/set_test_suite_realms_up.sh
|
93
75
|
- docs/08Migration.textile
|
94
76
|
- docs/Bindings.textile
|
@@ -151,6 +133,7 @@ files:
|
|
151
133
|
- examples/queues/declare_a_queue_without_assignment.rb
|
152
134
|
- examples/queues/declare_and_bind_a_server_named_queue.rb
|
153
135
|
- examples/queues/queue_status.rb
|
136
|
+
- examples/rack/publish_a_message_on_request/thin.ru
|
154
137
|
- examples/real-world/task-queue/README.textile
|
155
138
|
- examples/real-world/task-queue/consumer.rb
|
156
139
|
- examples/real-world/task-queue/producer.rb
|
@@ -220,41 +203,29 @@ files:
|
|
220
203
|
- spec/unit/amqp/basic_spec.rb
|
221
204
|
- spec/unit/amqp/connection_spec.rb
|
222
205
|
- tasks.rb
|
223
|
-
has_rdoc: true
|
224
206
|
homepage: http://github.com/ruby-amqp/amqp
|
225
207
|
licenses: []
|
226
|
-
|
227
208
|
post_install_message:
|
228
|
-
rdoc_options:
|
209
|
+
rdoc_options:
|
229
210
|
- --include=examples --main README.textile
|
230
|
-
require_paths:
|
211
|
+
require_paths:
|
231
212
|
- lib
|
232
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
213
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
233
214
|
none: false
|
234
|
-
requirements:
|
235
|
-
- -
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
|
238
|
-
|
239
|
-
- 0
|
240
|
-
version: "0"
|
241
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ! '>='
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
242
220
|
none: false
|
243
|
-
requirements:
|
244
|
-
- -
|
245
|
-
- !ruby/object:Gem::Version
|
246
|
-
hash: 25
|
247
|
-
segments:
|
248
|
-
- 1
|
249
|
-
- 3
|
250
|
-
- 1
|
221
|
+
requirements:
|
222
|
+
- - ! '>'
|
223
|
+
- !ruby/object:Gem::Version
|
251
224
|
version: 1.3.1
|
252
225
|
requirements: []
|
253
|
-
|
254
226
|
rubyforge_project: amqp
|
255
|
-
rubygems_version: 1.
|
227
|
+
rubygems_version: 1.8.1
|
256
228
|
signing_key:
|
257
229
|
specification_version: 3
|
258
230
|
summary: AMQP client implementation in Ruby/EventMachine.
|
259
231
|
test_files: []
|
260
|
-
|
data/bin/jenkins.sh
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
echo -e "\n\n==== Setup ===="
|
4
|
-
source /etc/profile
|
5
|
-
git fetch && git reset origin/master --hard
|
6
|
-
|
7
|
-
# FIXME: Jenkins user doesn't have permissions to run it.
|
8
|
-
# PATH=/usr/sbin:$PATH ./bin/set_test_suite_realms_up.sh
|
9
|
-
echo "~ NOT running ./bin/set_test_suite_realms_up.sh"
|
10
|
-
|
11
|
-
echo -e "\n\n==== Ruby 1.9.2 Head ===="
|
12
|
-
rvm use 1.9.2-head@ruby-amqp
|
13
|
-
gem install bundler --no-ri --no-rdoc
|
14
|
-
bundle install --path vendor/bundle/1.9.2 --without development; echo
|
15
|
-
bundle update; echo
|
16
|
-
bundle exec rspec spec
|
17
|
-
return_status=$?
|
18
|
-
|
19
|
-
echo -e "\n\n==== Ruby 1.8.7 ===="
|
20
|
-
rvm use 1.8.7@ruby-amqp
|
21
|
-
gem install bundler --no-ri --no-rdoc
|
22
|
-
bundle install --path vendor/bundle/1.8.7 --without development; echo
|
23
|
-
bundle update; echo
|
24
|
-
bundle exec rspec spec
|
25
|
-
return_status=$(expr $return_status + $?)
|
26
|
-
|
27
|
-
test $return_status -eq 0
|