bunny 0.6.3.rc2 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rspec +3 -0
- data/.travis.yml +15 -0
- data/.yardopts +9 -0
- data/CHANGELOG +3 -0
- data/Gemfile +39 -0
- data/Gemfile.lock +34 -0
- data/LICENSE +5 -4
- data/README.textile +54 -0
- data/Rakefile +15 -13
- data/bunny.gemspec +42 -61
- data/examples/simple_08.rb +4 -2
- data/examples/simple_09.rb +4 -2
- data/examples/simple_ack_08.rb +3 -1
- data/examples/simple_ack_09.rb +3 -1
- data/examples/simple_consumer_08.rb +4 -2
- data/examples/simple_consumer_09.rb +4 -2
- data/examples/simple_fanout_08.rb +3 -1
- data/examples/simple_fanout_09.rb +3 -1
- data/examples/simple_headers_08.rb +5 -3
- data/examples/simple_headers_09.rb +5 -3
- data/examples/simple_publisher_08.rb +3 -1
- data/examples/simple_publisher_09.rb +3 -1
- data/examples/simple_topic_08.rb +5 -3
- data/examples/simple_topic_09.rb +5 -3
- data/ext/amqp-0.8.json +616 -0
- data/ext/amqp-0.9.1.json +388 -0
- data/ext/config.yml +4 -0
- data/ext/qparser.rb +463 -0
- data/lib/bunny.rb +88 -66
- data/lib/bunny/channel08.rb +38 -38
- data/lib/bunny/channel09.rb +37 -37
- data/lib/bunny/client08.rb +184 -206
- data/lib/bunny/client09.rb +277 -363
- data/lib/bunny/consumer.rb +35 -0
- data/lib/bunny/exchange08.rb +37 -41
- data/lib/bunny/exchange09.rb +106 -124
- data/lib/bunny/queue08.rb +216 -202
- data/lib/bunny/queue09.rb +256 -326
- data/lib/bunny/subscription08.rb +30 -29
- data/lib/bunny/subscription09.rb +84 -83
- data/lib/bunny/version.rb +5 -0
- data/lib/qrack/amq-client-url.rb +165 -0
- data/lib/qrack/channel.rb +19 -17
- data/lib/qrack/client.rb +152 -151
- data/lib/qrack/errors.rb +5 -0
- data/lib/qrack/protocol/protocol08.rb +132 -130
- data/lib/qrack/protocol/protocol09.rb +133 -131
- data/lib/qrack/protocol/spec08.rb +2 -0
- data/lib/qrack/protocol/spec09.rb +2 -0
- data/lib/qrack/qrack08.rb +7 -10
- data/lib/qrack/qrack09.rb +7 -10
- data/lib/qrack/queue.rb +27 -40
- data/lib/qrack/subscription.rb +102 -101
- data/lib/qrack/transport/buffer08.rb +266 -264
- data/lib/qrack/transport/buffer09.rb +268 -264
- data/lib/qrack/transport/frame08.rb +13 -11
- data/lib/qrack/transport/frame09.rb +9 -7
- data/spec/spec_08/bunny_spec.rb +48 -45
- data/spec/spec_08/connection_spec.rb +10 -7
- data/spec/spec_08/exchange_spec.rb +145 -143
- data/spec/spec_08/queue_spec.rb +161 -161
- data/spec/spec_09/bunny_spec.rb +46 -44
- data/spec/spec_09/connection_spec.rb +15 -8
- data/spec/spec_09/exchange_spec.rb +147 -145
- data/spec/spec_09/queue_spec.rb +182 -184
- metadata +60 -41
- data/README.rdoc +0 -66
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
|
2
|
+
bundler_args: --without development
|
3
|
+
script: "bundle exec rspec spec"
|
4
|
+
rvm:
|
5
|
+
- 1.8.7
|
6
|
+
- 1.9.2
|
7
|
+
- jruby
|
8
|
+
- ree
|
9
|
+
- 1.8.7-p174
|
10
|
+
notifications:
|
11
|
+
recipients:
|
12
|
+
- celldee@gmail.com
|
13
|
+
- jakub@rabbitmq.com
|
14
|
+
- skaes@railsexpress.de
|
15
|
+
- eric@5stops.com
|
data/.yardopts
ADDED
data/CHANGELOG
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
source :rubygems
|
4
|
+
|
5
|
+
# Use local clones if possible.
|
6
|
+
# If you want to use your local copy, just symlink it to vendor.
|
7
|
+
# See http://blog.101ideas.cz/posts/custom-gems-in-gemfile.html
|
8
|
+
extend Module.new {
|
9
|
+
def gem(name, *args)
|
10
|
+
options = args.last.is_a?(Hash) ? args.last : Hash.new
|
11
|
+
|
12
|
+
local_path = File.expand_path("../vendor/#{name}", __FILE__)
|
13
|
+
if File.exist?(local_path)
|
14
|
+
super name, options.merge(:path => local_path).
|
15
|
+
delete_if { |key, _| [:git, :branch].include?(key) }
|
16
|
+
else
|
17
|
+
super name, *args
|
18
|
+
end
|
19
|
+
end
|
20
|
+
}
|
21
|
+
|
22
|
+
gem "SystemTimer", "1.2", :platform => :ruby_18
|
23
|
+
|
24
|
+
group :development do
|
25
|
+
gem "rake"
|
26
|
+
|
27
|
+
gem "yard", ">= 0.7.2"
|
28
|
+
|
29
|
+
# Yard tags this buddy along.
|
30
|
+
gem "RedCloth", :platform => :mri
|
31
|
+
|
32
|
+
gem "changelog"
|
33
|
+
end
|
34
|
+
|
35
|
+
group :test do
|
36
|
+
gem "rspec", "~> 2.6.0"
|
37
|
+
end
|
38
|
+
|
39
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bunny (0.7)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
RedCloth (4.2.7)
|
10
|
+
SystemTimer (1.2)
|
11
|
+
changelog (0.8)
|
12
|
+
diff-lcs (1.1.2)
|
13
|
+
rake (0.9.2)
|
14
|
+
rspec (2.6.0)
|
15
|
+
rspec-core (~> 2.6.0)
|
16
|
+
rspec-expectations (~> 2.6.0)
|
17
|
+
rspec-mocks (~> 2.6.0)
|
18
|
+
rspec-core (2.6.4)
|
19
|
+
rspec-expectations (2.6.0)
|
20
|
+
diff-lcs (~> 1.1.2)
|
21
|
+
rspec-mocks (2.6.0)
|
22
|
+
yard (0.7.2)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
RedCloth
|
29
|
+
SystemTimer (= 1.2)
|
30
|
+
bunny!
|
31
|
+
changelog
|
32
|
+
rake
|
33
|
+
rspec (~> 2.6.0)
|
34
|
+
yard (>= 0.7.2)
|
data/LICENSE
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
Copyright (c) 2009 Chris Duncan
|
2
|
-
|
1
|
+
Copyright (c) 2009 – 2011 Chris Duncan, Jakub Stastny aka botanicus,
|
2
|
+
Michael S. Klishin, Eric Lindvall, Stefan Kaes and contributors.
|
3
|
+
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
5
|
a copy of this software and associated documentation files (the
|
5
6
|
"Software"), to deal in the Software without restriction, including
|
@@ -7,10 +8,10 @@ without limitation the rights to use, copy, modify, merge, publish,
|
|
7
8
|
distribute, sublicense, and/or sell copies of the Software, and to
|
8
9
|
permit persons to whom the Software is furnished to do so, subject to
|
9
10
|
the following conditions:
|
10
|
-
|
11
|
+
|
11
12
|
The above copyright notice and this permission notice shall be
|
12
13
|
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
+
|
14
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
16
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
17
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
data/README.textile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
h1. About
|
2
|
+
|
3
|
+
Bunny is a synchronous "AMQP":http://bit.ly/hw2ELX client. It supports Ruby 1.9.2, 1.8.7, Ruby Enterprise Edition and JRuby. Protocol-wise, Bunny supports AMQP 0.9.1 and 0.8. Support for AMQP 0.8 will be dropped in the next version of Bunny (0.7) because most of popular AMQP brokers such as RabbitMQ already stopped or planning to stop supporting it in the near future.
|
4
|
+
|
5
|
+
Bunny is based on a great deal of useful code from the "amqp Ruby gem":http://github.com/ruby-amqp/amqp and "Carrot":http://github.com/famoseagle/carrot.
|
6
|
+
|
7
|
+
You can use Bunny to:
|
8
|
+
|
9
|
+
* Create and delete exchanges
|
10
|
+
* Create and delete queues
|
11
|
+
* Publish and consume messages
|
12
|
+
|
13
|
+
h1. Quick Start
|
14
|
+
|
15
|
+
<pre>
|
16
|
+
require "bunny"
|
17
|
+
|
18
|
+
b = Bunny.new(:logging => true)
|
19
|
+
|
20
|
+
# start a communication session with the amqp server
|
21
|
+
b.start
|
22
|
+
|
23
|
+
# declare a queue
|
24
|
+
q = b.queue("test1")
|
25
|
+
|
26
|
+
# publish a message to the queue
|
27
|
+
q.publish("Hello everybody!")
|
28
|
+
|
29
|
+
# get message from the queue
|
30
|
+
msg = q.pop[:payload]
|
31
|
+
|
32
|
+
puts "This is the message: " + msg + "\n\n"
|
33
|
+
|
34
|
+
# close the connection
|
35
|
+
b.stop
|
36
|
+
</pre>
|
37
|
+
|
38
|
+
... or just:
|
39
|
+
|
40
|
+
<pre>
|
41
|
+
require "bunny"
|
42
|
+
|
43
|
+
# Create a direct queue named "my_testq"
|
44
|
+
Bunny.run { |c| c.queue("my_testq") }
|
45
|
+
</pre>
|
46
|
+
|
47
|
+
Please see the @examples@ directory for additional usage information.
|
48
|
+
|
49
|
+
h1. Links
|
50
|
+
|
51
|
+
* "Source code":http://github.com/ruby-amqp/bunny
|
52
|
+
* "@rubyamqp":http://twitter.com/rubyamqp at Twitter
|
53
|
+
* "Ruby AMQP Google Group":http://groups.google.com/group/ruby-amqp
|
54
|
+
* "Blog":http://bunnyamqp.wordpress.com
|
data/Rakefile
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
desc "Run AMQP 0-8 rspec tests"
|
2
4
|
task :spec08 do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
puts "===== Running 0-8 tests ====="
|
7
|
+
RSpec::Core::RakeTask.new("spec08") do |t|
|
8
|
+
t.pattern = "spec/spec_08/*_spec.rb"
|
9
|
+
t.rspec_opts = ['--color']
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
desc "Run AMQP 0-9 rspec tests"
|
12
14
|
task :spec09 do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
require 'rspec/core/rake_task'
|
16
|
+
puts "===== Running 0-9 tests ====="
|
17
|
+
RSpec::Core::RakeTask.new("spec09") do |t|
|
18
|
+
t.pattern = "spec/spec_09/*_spec.rb"
|
19
|
+
t.rspec_opts = ['--color']
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
task :default => [ :spec08 ]
|
22
24
|
|
23
25
|
desc "Run all rspec tests"
|
24
|
-
task :all => [:spec08, :spec09]
|
26
|
+
task :all => [:spec08, :spec09]
|
data/bunny.gemspec
CHANGED
@@ -1,66 +1,47 @@
|
|
1
|
+
#!/usr/bin/env gem build
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "base64"
|
1
5
|
require File.expand_path("../lib/bunny/version", __FILE__)
|
2
6
|
|
3
7
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
8
|
+
s.name = "bunny"
|
5
9
|
s.version = Bunny::VERSION.dup
|
6
|
-
s.
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
|
10
|
+
s.homepage = "http://github.com/ruby-amqp/bunny"
|
11
|
+
s.summary = "Synchronous Ruby AMQP 0.9.1 client"
|
12
|
+
s.description = "A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers."
|
13
|
+
|
14
|
+
# Sorted alphabetically.
|
15
|
+
s.authors = [
|
16
|
+
"Chris Duncan",
|
17
|
+
"Eric Lindvall",
|
18
|
+
"Jakub Stastny aka botanicus",
|
19
|
+
"Michael S. Klishin",
|
20
|
+
"Stefan Kaes"]
|
21
|
+
|
22
|
+
s.email = [
|
23
|
+
"Y2VsbGRlZUBnbWFpbC5jb20=\n",
|
24
|
+
"ZXJpY0A1c3RvcHMuY29t\n",
|
25
|
+
"c3Rhc3RueUAxMDFpZGVhcy5jeg==\n",
|
26
|
+
"bWljaGFlbEBub3ZlbWJlcmFpbi5jb20=\n",
|
27
|
+
"c2thZXNAcmFpbHNleHByZXNzLmRl\n"].
|
28
|
+
map { |mail| Base64.decode64(mail) }
|
29
|
+
|
30
|
+
# Files.
|
10
31
|
s.has_rdoc = true
|
11
|
-
|
12
|
-
s.rdoc_options = [
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"examples/simple_ack_09.rb",
|
28
|
-
"examples/simple_consumer_09.rb",
|
29
|
-
"examples/simple_fanout_09.rb",
|
30
|
-
"examples/simple_publisher_09.rb",
|
31
|
-
"examples/simple_topic_09.rb",
|
32
|
-
"examples/simple_headers_09.rb",
|
33
|
-
"lib/bunny.rb",
|
34
|
-
"lib/bunny/channel08.rb",
|
35
|
-
"lib/bunny/channel09.rb",
|
36
|
-
"lib/bunny/client08.rb",
|
37
|
-
"lib/bunny/client09.rb",
|
38
|
-
"lib/bunny/exchange08.rb",
|
39
|
-
"lib/bunny/exchange09.rb",
|
40
|
-
"lib/bunny/queue08.rb",
|
41
|
-
"lib/bunny/queue09.rb",
|
42
|
-
"lib/bunny/subscription08.rb",
|
43
|
-
"lib/bunny/subscription09.rb",
|
44
|
-
"lib/qrack/client.rb",
|
45
|
-
"lib/qrack/channel.rb",
|
46
|
-
"lib/qrack/queue.rb",
|
47
|
-
"lib/qrack/subscription.rb",
|
48
|
-
"lib/qrack/protocol/protocol08.rb",
|
49
|
-
"lib/qrack/protocol/protocol09.rb",
|
50
|
-
"lib/qrack/protocol/spec08.rb",
|
51
|
-
"lib/qrack/protocol/spec09.rb",
|
52
|
-
"lib/qrack/qrack08.rb",
|
53
|
-
"lib/qrack/qrack09.rb",
|
54
|
-
"lib/qrack/transport/buffer08.rb",
|
55
|
-
"lib/qrack/transport/buffer09.rb",
|
56
|
-
"lib/qrack/transport/frame08.rb",
|
57
|
-
"lib/qrack/transport/frame09.rb",
|
58
|
-
"spec/spec_08/bunny_spec.rb",
|
59
|
-
"spec/spec_08/exchange_spec.rb",
|
60
|
-
"spec/spec_08/queue_spec.rb",
|
61
|
-
"spec/spec_08/connection_spec.rb",
|
62
|
-
"spec/spec_09/bunny_spec.rb",
|
63
|
-
"spec/spec_09/exchange_spec.rb",
|
64
|
-
"spec/spec_09/queue_spec.rb",
|
65
|
-
"spec/spec_09/connection_spec.rb"]
|
66
|
-
end
|
32
|
+
s.extra_rdoc_files = ["README.textile"]
|
33
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
34
|
+
s.files = `git ls-files`.split("\n")
|
35
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
|
38
|
+
begin
|
39
|
+
require "changelog"
|
40
|
+
s.post_install_message = CHANGELOG.new.version_changes
|
41
|
+
rescue LoadError
|
42
|
+
warn "You have to install the changelog gem for post install message."
|
43
|
+
end
|
44
|
+
|
45
|
+
# RubyForge
|
46
|
+
s.rubyforge_project = "bunny-amqp"
|
47
|
+
end
|
data/examples/simple_08.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
# simple_08.rb
|
2
4
|
|
3
5
|
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
@@ -19,7 +21,7 @@ b.start
|
|
19
21
|
q = b.queue('test1')
|
20
22
|
|
21
23
|
# publish a message to the queue
|
22
|
-
q.publish('Hello everybody
|
24
|
+
q.publish('➸ Hello everybody ☺!')
|
23
25
|
|
24
26
|
# get message from the queue
|
25
27
|
msg = q.pop[:payload]
|
@@ -27,4 +29,4 @@ msg = q.pop[:payload]
|
|
27
29
|
puts 'This is the message: ' + msg + "\n\n"
|
28
30
|
|
29
31
|
# close the client connection
|
30
|
-
b.stop
|
32
|
+
b.stop
|
data/examples/simple_09.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
# simple_09.rb
|
2
4
|
|
3
5
|
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
@@ -19,7 +21,7 @@ b.start
|
|
19
21
|
q = b.queue('test1')
|
20
22
|
|
21
23
|
# publish a message to the queue
|
22
|
-
q.publish('Hello everybody
|
24
|
+
q.publish('➸ Hello everybody ☺!')
|
23
25
|
|
24
26
|
# get message from the queue
|
25
27
|
msg = q.pop[:payload]
|
@@ -27,4 +29,4 @@ msg = q.pop[:payload]
|
|
27
29
|
puts 'This is the message: ' + msg + "\n\n"
|
28
30
|
|
29
31
|
# close the client connection
|
30
|
-
b.stop
|
32
|
+
b.stop
|
data/examples/simple_ack_08.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
# simple_ack_08.rb
|
2
4
|
|
3
5
|
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
@@ -30,4 +32,4 @@ q.ack
|
|
30
32
|
puts 'This is the message: ' + msg + "\n\n"
|
31
33
|
|
32
34
|
# close the client connection
|
33
|
-
b.stop
|
35
|
+
b.stop
|
data/examples/simple_ack_09.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
# simple_ack_09.rb
|
2
4
|
|
3
5
|
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
@@ -30,4 +32,4 @@ q.ack
|
|
30
32
|
puts 'This is the message: ' + msg + "\n\n"
|
31
33
|
|
32
34
|
# close the client connection
|
33
|
-
b.stop
|
35
|
+
b.stop
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
# simple_consumer_08.rb
|
2
4
|
|
3
5
|
# N.B. To be used in conjunction with simple_publisher.rb
|
@@ -46,8 +48,8 @@ q.bind(exch, :key => 'fred')
|
|
46
48
|
|
47
49
|
# subscribe to queue
|
48
50
|
q.subscribe(:consumer_tag => 'testtag1', :timeout => 30) do |msg|
|
49
|
-
|
51
|
+
puts "#{q.subscription.message_count}: #{msg[:payload]}"
|
50
52
|
end
|
51
53
|
|
52
54
|
# Close client
|
53
|
-
b.stop
|
55
|
+
b.stop
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
# simple_consumer_09.rb
|
2
4
|
|
3
5
|
# N.B. To be used in conjunction with simple_publisher.rb
|
@@ -46,8 +48,8 @@ q.bind(exch, :key => 'fred')
|
|
46
48
|
|
47
49
|
# subscribe to queue
|
48
50
|
q.subscribe(:consumer_tag => 'testtag1', :timeout => 30) do |msg|
|
49
|
-
|
51
|
+
puts "#{q.subscription.message_count}: #{msg[:payload]}"
|
50
52
|
end
|
51
53
|
|
52
54
|
# Close client
|
53
|
-
b.stop
|
55
|
+
b.stop
|