bunny 0.7.12 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -2
- data/.travis.yml +7 -16
- data/CHANGELOG +3 -21
- data/Gemfile +2 -4
- data/README.textile +31 -9
- data/Rakefile +3 -3
- data/bunny.gemspec +6 -3
- data/examples/{simple_08.rb → simple.rb} +1 -1
- data/examples/{simple_ack_08.rb → simple_ack.rb} +1 -1
- data/examples/{simple_consumer_08.rb → simple_consumer.rb} +4 -4
- data/examples/{simple_fanout_08.rb → simple_fanout.rb} +1 -1
- data/examples/{simple_headers_08.rb → simple_headers.rb} +2 -2
- data/examples/{simple_publisher_09.rb → simple_publisher.rb} +1 -1
- data/examples/{simple_topic_09.rb → simple_topic.rb} +2 -2
- data/ext/amqp-0.9.1.json +1 -0
- data/ext/config.yml +3 -3
- data/ext/qparser.rb +9 -52
- data/lib/bunny.rb +15 -33
- data/lib/bunny/{channel08.rb → channel.rb} +0 -0
- data/lib/bunny/{client09.rb → client.rb} +34 -46
- data/lib/bunny/{exchange09.rb → exchange.rb} +16 -15
- data/lib/bunny/{queue09.rb → queue.rb} +26 -23
- data/lib/bunny/{subscription09.rb → subscription.rb} +11 -6
- data/lib/bunny/version.rb +1 -1
- data/lib/qrack/client.rb +30 -21
- data/lib/qrack/protocol/{protocol08.rb → protocol.rb} +2 -1
- data/lib/qrack/protocol/{spec09.rb → spec.rb} +8 -7
- data/lib/qrack/{qrack08.rb → qrack.rb} +4 -4
- data/lib/qrack/subscription.rb +58 -9
- data/lib/qrack/transport/{buffer08.rb → buffer.rb} +8 -0
- data/lib/qrack/transport/{frame08.rb → frame.rb} +7 -22
- data/spec/spec_09/bunny_spec.rb +10 -8
- data/spec/spec_09/connection_spec.rb +8 -3
- data/spec/spec_09/exchange_spec.rb +22 -19
- data/spec/spec_09/queue_spec.rb +32 -18
- metadata +69 -76
- checksums.yaml +0 -7
- data/examples/simple_09.rb +0 -32
- data/examples/simple_ack_09.rb +0 -35
- data/examples/simple_consumer_09.rb +0 -55
- data/examples/simple_fanout_09.rb +0 -41
- data/examples/simple_headers_09.rb +0 -42
- data/examples/simple_publisher_08.rb +0 -29
- data/examples/simple_topic_08.rb +0 -61
- data/ext/amqp-0.8.json +0 -616
- data/lib/bunny/channel09.rb +0 -39
- data/lib/bunny/client08.rb +0 -480
- data/lib/bunny/exchange08.rb +0 -177
- data/lib/bunny/queue08.rb +0 -403
- data/lib/bunny/subscription08.rb +0 -87
- data/lib/qrack/protocol/protocol09.rb +0 -135
- data/lib/qrack/protocol/spec08.rb +0 -828
- data/lib/qrack/qrack09.rb +0 -20
- data/lib/qrack/transport/buffer09.rb +0 -305
- data/lib/qrack/transport/frame09.rb +0 -97
- data/spec/spec_08/bunny_spec.rb +0 -75
- data/spec/spec_08/connection_spec.rb +0 -24
- data/spec/spec_08/exchange_spec.rb +0 -170
- data/spec/spec_08/queue_spec.rb +0 -239
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,20 +1,11 @@
|
|
1
|
-
language: ruby
|
2
1
|
bundler_args: --without development
|
3
|
-
cache: bundler
|
4
|
-
before_script: "./bin/ci/before_build"
|
5
2
|
script: "bundle exec rspec spec"
|
6
|
-
dist: trusty
|
7
3
|
rvm:
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
4
|
+
- 1.8.7
|
5
|
+
- ree
|
6
|
+
- 1.9.2
|
7
|
+
- 1.9.3
|
8
|
+
- rbx-18mode
|
9
|
+
# - rbx-19mode
|
11
10
|
notifications:
|
12
|
-
email:
|
13
|
-
- skaes@railsexpress.de
|
14
|
-
services:
|
15
|
-
- rabbitmq
|
16
|
-
branches:
|
17
|
-
only:
|
18
|
-
- 0.7.x-stable
|
19
|
-
env:
|
20
|
-
- CI=true
|
11
|
+
email: false
|
data/CHANGELOG
CHANGED
@@ -1,26 +1,7 @@
|
|
1
|
-
= Version 0.
|
1
|
+
= Version 0.8.0
|
2
2
|
|
3
|
-
|
3
|
+
* AMQP 0.8 client is removed. Bunny is an AMQP 0.9.1 client only now.
|
4
4
|
|
5
|
-
= Version 0.7.10
|
6
|
-
|
7
|
-
* handle messages larger than frame_max correctly
|
8
|
-
|
9
|
-
= Version 0.7.9
|
10
|
-
|
11
|
-
* parse a few more AMQ datatypes (related to federation plugin)
|
12
|
-
|
13
|
-
= Version 0.7.8
|
14
|
-
|
15
|
-
* test suite cleanup (eliminated some race conditions related to queue.message_count)
|
16
|
-
|
17
|
-
= Version 0.7.7
|
18
|
-
|
19
|
-
* avoid warnings caused by duplicating code from the amq-client gem
|
20
|
-
|
21
|
-
= Version 0.7.6
|
22
|
-
|
23
|
-
* API mismatch between Timer/SystemTimer on Ruby 1.9 vs Ruby 1.8 is resolved.
|
24
5
|
|
25
6
|
= Version 0.7.3
|
26
7
|
|
@@ -37,3 +18,4 @@
|
|
37
18
|
|
38
19
|
= Version 0.6.3
|
39
20
|
* Encoding of source files is set to UTF-8 on Ruby 1.9.
|
21
|
+
* Queue#publish deprecated.
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
source
|
3
|
+
source :rubygems
|
4
4
|
|
5
5
|
# Use local clones if possible.
|
6
6
|
# If you want to use your local copy, just symlink it to vendor.
|
@@ -30,12 +30,10 @@ group :development do
|
|
30
30
|
gem "RedCloth", :platform => :mri
|
31
31
|
|
32
32
|
gem "changelog"
|
33
|
-
|
34
|
-
gem "byebug"
|
35
33
|
end
|
36
34
|
|
37
35
|
group :test do
|
38
|
-
gem "rspec", "~>
|
36
|
+
gem "rspec", "~> 2.6.0"
|
39
37
|
end
|
40
38
|
|
41
39
|
gemspec
|
data/README.textile
CHANGED
@@ -1,16 +1,31 @@
|
|
1
|
-
h1. About
|
1
|
+
h1. About bunny
|
2
2
|
|
3
|
-
Bunny is a synchronous "AMQP":http://bit.ly/
|
3
|
+
Bunny is a synchronous "AMQP 0.8.0":http://bit.ly/amqp-model-explained 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.8) because most of popular AMQP brokers such as RabbitMQ have already stopped or are planning to stop supporting it in the near future.
|
4
4
|
|
5
|
-
|
5
|
+
h2. Limited Functionality Disclaimer
|
6
|
+
|
7
|
+
Bunny is very simplistic and does not support many features
|
6
8
|
|
7
9
|
You can use Bunny to:
|
8
10
|
|
9
11
|
* Create and delete exchanges
|
10
12
|
* Create and delete queues
|
11
|
-
* Publish and consume messages
|
13
|
+
* Publish and synchronously consume (basic.get) messages
|
14
|
+
|
15
|
+
But it does not support
|
16
|
+
|
17
|
+
* Arrays, hashes or even symbols in message headers
|
18
|
+
* Framing of large messages
|
19
|
+
* Many AMQP operations
|
20
|
+
* RabbitMQ extensions
|
21
|
+
* AMQP 0.9.1-only brokers
|
22
|
+
|
23
|
+
h2. Bunny is NOT actively maintained
|
24
|
+
|
25
|
+
Bunny is also **not actively maintained**. Consider using Hot Bunnies (JRuby) or amqp gem instead.
|
12
26
|
|
13
|
-
|
27
|
+
|
28
|
+
h2. Quick Start
|
14
29
|
|
15
30
|
<pre>
|
16
31
|
require "bunny"
|
@@ -23,8 +38,11 @@ b.start
|
|
23
38
|
# declare a queue
|
24
39
|
q = b.queue("test1")
|
25
40
|
|
26
|
-
#
|
27
|
-
|
41
|
+
# declare default direct exchange which is bound to all queues
|
42
|
+
e = b.exchange("")
|
43
|
+
|
44
|
+
# publish a message to the exchange which then gets routed to the queue
|
45
|
+
e.publish("Hello, everybody!", :key => 'test1')
|
28
46
|
|
29
47
|
# get message from the queue
|
30
48
|
msg = q.pop[:payload]
|
@@ -46,9 +64,13 @@ Bunny.run { |c| c.queue("my_testq") }
|
|
46
64
|
|
47
65
|
Please see the @examples@ directory for additional usage information.
|
48
66
|
|
49
|
-
|
67
|
+
h2. AMQP Resources
|
68
|
+
|
69
|
+
* "AMQP 0.9.1 model explained":http://bit.ly/amqp-model-explained - Introductory explanation of the AMQP v0.9.1 specification with particular reference to RabbitMQ
|
70
|
+
|
71
|
+
h2. Links
|
50
72
|
|
51
73
|
* "Source code":http://github.com/ruby-amqp/bunny
|
52
|
-
* "@rubyamqp":http://twitter.com/rubyamqp
|
74
|
+
* "Follow @rubyamqp":http://twitter.com/rubyamqp on Twitter
|
53
75
|
* "Ruby AMQP Google Group":http://groups.google.com/group/ruby-amqp
|
54
76
|
* "Blog":http://bunnyamqp.wordpress.com
|
data/Rakefile
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
|
5
|
-
desc "Run rspec tests"
|
5
|
+
desc "Run AMQP rspec tests"
|
6
6
|
task :spec do
|
7
7
|
require 'rspec/core/rake_task'
|
8
8
|
RSpec::Core::RakeTask.new("spec") do |t|
|
9
|
-
t.pattern = "spec/
|
10
|
-
t.rspec_opts = ['--color'
|
9
|
+
t.pattern = "spec/spec_09/*_spec.rb"
|
10
|
+
t.rspec_opts = ['--color']
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
data/bunny.gemspec
CHANGED
@@ -8,9 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.name = "bunny"
|
9
9
|
s.version = Bunny::VERSION.dup
|
10
10
|
s.homepage = "http://github.com/ruby-amqp/bunny"
|
11
|
-
s.summary = "Synchronous Ruby AMQP 0.
|
11
|
+
s.summary = "Synchronous Ruby AMQP 0.8.0 client"
|
12
12
|
s.description = "A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers."
|
13
|
-
s.license = "MIT"
|
14
13
|
|
15
14
|
# Sorted alphabetically.
|
16
15
|
s.authors = [
|
@@ -29,9 +28,10 @@ Gem::Specification.new do |s|
|
|
29
28
|
map { |mail| Base64.decode64(mail) }
|
30
29
|
|
31
30
|
# Files.
|
31
|
+
s.has_rdoc = true
|
32
32
|
s.extra_rdoc_files = ["README.textile"]
|
33
33
|
s.rdoc_options = ["--main", "README.rdoc"]
|
34
|
-
s.files = `git ls-files`.split("\n")
|
34
|
+
s.files = `git ls-files`.split("\n")
|
35
35
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
36
36
|
s.require_paths = ["lib"]
|
37
37
|
|
@@ -40,4 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.post_install_message = CHANGELOG.new.version_changes
|
41
41
|
rescue LoadError
|
42
42
|
end
|
43
|
+
|
44
|
+
# RubyForge
|
45
|
+
s.rubyforge_project = "bunny-amqp"
|
43
46
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
#
|
3
|
+
# simple_consumer.rb
|
4
4
|
|
5
5
|
# N.B. To be used in conjunction with simple_publisher.rb
|
6
6
|
|
@@ -15,11 +15,11 @@
|
|
15
15
|
#
|
16
16
|
# Open up two console windows start this program in one of them by typing -
|
17
17
|
#
|
18
|
-
# ruby
|
18
|
+
# ruby simple_consumer.rb
|
19
19
|
#
|
20
20
|
# Then switch to the other console window and type -
|
21
21
|
#
|
22
|
-
# ruby
|
22
|
+
# ruby simple_publisher.rb
|
23
23
|
#
|
24
24
|
# A message will be printed out by the simple_consumer and it will wait for the next message
|
25
25
|
# until the timeout interval is reached.
|
@@ -48,7 +48,7 @@ q.bind(exch, :key => 'fred')
|
|
48
48
|
|
49
49
|
# subscribe to queue
|
50
50
|
q.subscribe(:consumer_tag => 'testtag1', :timeout => 30) do |msg|
|
51
|
-
puts "#{q.
|
51
|
+
puts "#{q.default_consumer.message_count}: #{msg[:payload]}"
|
52
52
|
end
|
53
53
|
|
54
54
|
# Close client
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
#
|
3
|
+
# simple_headers.rb
|
4
4
|
|
5
5
|
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
6
6
|
# and that it is running on 'localhost'.
|
@@ -12,7 +12,7 @@ $:.unshift File.dirname(__FILE__) + '/../lib'
|
|
12
12
|
|
13
13
|
require 'bunny'
|
14
14
|
|
15
|
-
b = Bunny.new
|
15
|
+
b = Bunny.new(:logging => true)
|
16
16
|
|
17
17
|
# start a communication session with the amqp server
|
18
18
|
b.start
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
#
|
3
|
+
# simple_topic.rb
|
4
4
|
|
5
5
|
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
6
6
|
# and that it is running on 'localhost'.
|
@@ -12,7 +12,7 @@ $:.unshift File.dirname(__FILE__) + '/../lib'
|
|
12
12
|
|
13
13
|
require 'bunny'
|
14
14
|
|
15
|
-
b = Bunny.new(:
|
15
|
+
b = Bunny.new(:logging => true)
|
16
16
|
|
17
17
|
# start a communication session with the amqp server
|
18
18
|
b.start
|
data/ext/amqp-0.9.1.json
CHANGED
data/ext/config.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
---
|
2
|
-
:spec_out: '../lib/qrack/protocol/
|
3
|
-
:frame_out: '../lib/qrack/transport/
|
4
|
-
:spec_in: 'amqp-0.
|
2
|
+
:spec_out: '../lib/qrack/protocol/spec.rb'
|
3
|
+
:frame_out: '../lib/qrack/transport/frame.rb'
|
4
|
+
:spec_in: 'amqp-0.9.1.json'
|
data/ext/qparser.rb
CHANGED
@@ -5,17 +5,14 @@ require 'erb'
|
|
5
5
|
require 'pathname'
|
6
6
|
require 'yaml'
|
7
7
|
|
8
|
-
def spec_v8_0_0?(spec)
|
9
|
-
spec['major'] == '8' && spec['minor'] == '0' && spec['revision'] == '0'
|
10
|
-
end
|
11
|
-
|
12
8
|
def spec_details(spec)
|
13
9
|
meta = {}
|
14
10
|
|
15
11
|
meta['major'] = spec['major-version']
|
16
12
|
meta['minor'] = spec['minor-version']
|
17
|
-
meta['revision'] = spec['revision']
|
13
|
+
meta['revision'] = spec['revision']
|
18
14
|
meta['port'] = spec['port']
|
15
|
+
meta['ssl_port'] = spec['ssl_port']
|
19
16
|
meta['comment'] = "AMQ Protocol version #{meta['major']}.#{meta['minor']}.#{meta['revision']}"
|
20
17
|
|
21
18
|
meta
|
@@ -41,9 +38,7 @@ end
|
|
41
38
|
|
42
39
|
def domain_types(spec, major, minor, revision)
|
43
40
|
# AMQP domain types
|
44
|
-
|
45
|
-
# add types that may be missing in the spec version
|
46
|
-
dt_arr = add_types(spec)
|
41
|
+
dt_arr = []
|
47
42
|
spec["domains"].each do |domain|
|
48
43
|
# JSON spec gives domain types as two element arrays like ["channel-id", "longstr"]
|
49
44
|
dt_arr << domain.last
|
@@ -63,12 +58,8 @@ def classes(spec, major, minor, revision)
|
|
63
58
|
cls_hash[:fields] = fields(amqp_class) # are these amqp_class["properties"] ?
|
64
59
|
# Get methods for class
|
65
60
|
meth_arr = class_methods(amqp_class)
|
66
|
-
# Add missing methods
|
67
|
-
add_arr =[]
|
68
|
-
add_arr = add_methods(spec) if cls_hash[:name] == 'queue'
|
69
|
-
method_arr = meth_arr + add_arr
|
70
61
|
# Add array to class hash
|
71
|
-
cls_hash[:methods] =
|
62
|
+
cls_hash[:methods] = meth_arr
|
72
63
|
cls_hash
|
73
64
|
end
|
74
65
|
end
|
@@ -102,41 +93,6 @@ def fields(element)
|
|
102
93
|
end
|
103
94
|
end
|
104
95
|
|
105
|
-
def add_types(spec)
|
106
|
-
spec_v8_0_0?(spec) ? ['long', 'longstr', 'octet', 'timestamp'] : []
|
107
|
-
end
|
108
|
-
|
109
|
-
def add_methods(spec)
|
110
|
-
meth_arr = []
|
111
|
-
|
112
|
-
if spec_v8_0_0?(spec)
|
113
|
-
# Add Queue Unbind method
|
114
|
-
meth_hash = {:name => 'unbind',
|
115
|
-
:index => '50',
|
116
|
-
:fields => [{:name => 'ticket', :domain => 'short'},
|
117
|
-
{:name => 'queue', :domain => 'shortstr'},
|
118
|
-
{:name => 'exchange', :domain => 'shortstr'},
|
119
|
-
{:name => 'routing_key', :domain => 'shortstr'},
|
120
|
-
{:name => 'arguments', :domain => 'table'}
|
121
|
-
]
|
122
|
-
}
|
123
|
-
|
124
|
-
meth_arr << meth_hash
|
125
|
-
|
126
|
-
# Add Queue Unbind-ok method
|
127
|
-
meth_hash = {:name => 'unbind-ok',
|
128
|
-
:index => '51',
|
129
|
-
:fields => []
|
130
|
-
}
|
131
|
-
|
132
|
-
meth_arr << meth_hash
|
133
|
-
end
|
134
|
-
|
135
|
-
# Return methods
|
136
|
-
meth_arr
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
96
|
def convert_type(name)
|
141
97
|
type_arr = @type_conversion.select {|k,v| k == name}.flatten
|
142
98
|
end
|
@@ -219,7 +175,7 @@ spec_rb.puts(
|
|
219
175
|
ERB.new(%q[
|
220
176
|
# encoding: utf-8
|
221
177
|
|
222
|
-
|
178
|
+
|
223
179
|
#:stopdoc:
|
224
180
|
# this file was autogenerated on <%= Time.now.to_s %>
|
225
181
|
# using <%= specfile.ljust(16) %> (mtime: <%= File.mtime(specpath) %>)
|
@@ -233,6 +189,7 @@ ERB.new(%q[
|
|
233
189
|
VERSION_MINOR = <%= spec_info['minor'] %>
|
234
190
|
REVISION = <%= spec_info['revision'] %>
|
235
191
|
PORT = <%= spec_info['port'] %>
|
192
|
+
SSL_PORT = <%= spec_info['ssl_port'] %>
|
236
193
|
|
237
194
|
RESPONSES = {
|
238
195
|
<%- other_constants.each do |value, name| -%>
|
@@ -369,7 +326,7 @@ frame_rb.puts(
|
|
369
326
|
ERB.new(%q[
|
370
327
|
# encoding: utf-8
|
371
328
|
|
372
|
-
|
329
|
+
|
373
330
|
#:stopdoc:
|
374
331
|
# this file was autogenerated on <%= Time.now.to_s %>
|
375
332
|
#
|
@@ -418,10 +375,10 @@ ERB.new(%q[
|
|
418
375
|
end
|
419
376
|
end
|
420
377
|
|
421
|
-
def self.parse
|
378
|
+
def self.parse(buf, cancellator = nil)
|
422
379
|
buf = Transport::Buffer.new(buf) unless buf.is_a? Transport::Buffer
|
423
380
|
buf.extract do
|
424
|
-
id, channel, payload, footer = buf.read(:octet, :short, :longstr, :octet)
|
381
|
+
id, channel, payload, footer = buf.read(cancellator, :octet, :short, :longstr, :octet)
|
425
382
|
Qrack::Transport.const_get(@types[id]).new(payload, channel) if footer == FOOTER
|
426
383
|
end
|
427
384
|
end
|