bunny 0.7.13 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +2 -2
  2. data/.travis.yml +7 -16
  3. data/CHANGELOG +3 -21
  4. data/Gemfile +2 -4
  5. data/README.textile +31 -9
  6. data/Rakefile +3 -3
  7. data/bunny.gemspec +6 -3
  8. data/examples/{simple_08.rb → simple.rb} +1 -1
  9. data/examples/{simple_ack_08.rb → simple_ack.rb} +1 -1
  10. data/examples/{simple_consumer_08.rb → simple_consumer.rb} +4 -4
  11. data/examples/{simple_fanout_08.rb → simple_fanout.rb} +1 -1
  12. data/examples/{simple_headers_08.rb → simple_headers.rb} +2 -2
  13. data/examples/{simple_publisher_09.rb → simple_publisher.rb} +1 -1
  14. data/examples/{simple_topic_09.rb → simple_topic.rb} +2 -2
  15. data/ext/amqp-0.9.1.json +1 -0
  16. data/ext/config.yml +3 -3
  17. data/ext/qparser.rb +9 -52
  18. data/lib/bunny/{client09.rb → client.rb} +34 -46
  19. data/lib/bunny/{exchange09.rb → exchange.rb} +16 -15
  20. data/lib/bunny/{queue09.rb → queue.rb} +26 -23
  21. data/lib/bunny/{subscription09.rb → subscription.rb} +11 -6
  22. data/lib/bunny/version.rb +1 -1
  23. data/lib/bunny.rb +15 -33
  24. data/lib/qrack/client.rb +31 -22
  25. data/lib/qrack/protocol/{protocol08.rb → protocol.rb} +2 -1
  26. data/lib/qrack/protocol/{spec09.rb → spec.rb} +8 -7
  27. data/lib/qrack/{qrack08.rb → qrack.rb} +4 -4
  28. data/lib/qrack/subscription.rb +58 -9
  29. data/lib/qrack/transport/{buffer08.rb → buffer.rb} +9 -1
  30. data/lib/qrack/transport/{frame08.rb → frame.rb} +7 -22
  31. data/spec/spec_09/amqp_url_spec.rb +1 -1
  32. data/spec/spec_09/bunny_spec.rb +11 -9
  33. data/spec/spec_09/connection_spec.rb +9 -4
  34. data/spec/spec_09/exchange_spec.rb +23 -25
  35. data/spec/spec_09/queue_spec.rb +33 -19
  36. metadata +71 -81
  37. checksums.yaml +0 -7
  38. data/examples/simple_09.rb +0 -32
  39. data/examples/simple_ack_09.rb +0 -35
  40. data/examples/simple_consumer_09.rb +0 -55
  41. data/examples/simple_fanout_09.rb +0 -41
  42. data/examples/simple_headers_09.rb +0 -42
  43. data/examples/simple_publisher_08.rb +0 -29
  44. data/examples/simple_topic_08.rb +0 -61
  45. data/ext/amqp-0.8.json +0 -616
  46. data/lib/bunny/channel09.rb +0 -39
  47. data/lib/bunny/client08.rb +0 -480
  48. data/lib/bunny/exchange08.rb +0 -177
  49. data/lib/bunny/queue08.rb +0 -403
  50. data/lib/bunny/subscription08.rb +0 -87
  51. data/lib/qrack/protocol/protocol09.rb +0 -135
  52. data/lib/qrack/protocol/spec08.rb +0 -828
  53. data/lib/qrack/qrack09.rb +0 -20
  54. data/lib/qrack/transport/buffer09.rb +0 -305
  55. data/lib/qrack/transport/frame09.rb +0 -97
  56. data/spec/spec_08/bunny_spec.rb +0 -75
  57. data/spec/spec_08/connection_spec.rb +0 -24
  58. data/spec/spec_08/exchange_spec.rb +0 -175
  59. data/spec/spec_08/queue_spec.rb +0 -239
  60. data/spec/spec_helper.rb +0 -8
  61. /data/lib/bunny/{channel08.rb → channel.rb} +0 -0
data/.gitignore CHANGED
@@ -4,9 +4,9 @@
4
4
  *.rbc
5
5
  *.gem
6
6
  /doc/
7
- /debug/
8
7
  .yardoc
9
8
  .rvmrc
10
9
  Gemfile.lock
11
10
  .rbx/*
12
- tmp/*
11
+ .tags
12
+ .tags_sorted_by_file
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
- - "2.4.1"
9
- - "2.3.4"
10
- - "2.2.7"
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.7.11
1
+ = Version 0.8.0
2
2
 
3
- * support boolean values in message headers
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 'https://rubygems.org'
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/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.
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
- 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.
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
- h1. Quick Start
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
- # publish a message to the queue
27
- q.publish("Hello everybody!")
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
- h1. Links
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 at Twitter
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/spec_*/*_spec.rb"
10
- t.rspec_opts = ['--color', '--format doc']
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.9.1 client"
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").reject { |f| f.match(%r{^bin/ci/}) }
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
- # simple_08.rb
3
+ # simple.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'.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # simple_ack_08.rb
3
+ # simple_ack.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'.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # simple_consumer_08.rb
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 simple_consumer_08.rb
18
+ # ruby simple_consumer.rb
19
19
  #
20
20
  # Then switch to the other console window and type -
21
21
  #
22
- # ruby simple_publisher_08.rb
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.subscription.message_count}: #{msg[:payload]}"
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
- # simple_fanout_08.rb
3
+ # simple_fanout.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'.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # simple_headers_08.rb
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
@@ -14,7 +14,7 @@ $:.unshift File.dirname(__FILE__) + '/../lib'
14
14
 
15
15
  require 'bunny'
16
16
 
17
- b = Bunny.new(:logging => true, :spec => '09')
17
+ b = Bunny.new(:logging => true)
18
18
 
19
19
  # start a communication session with the amqp server
20
20
  b.start
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # simple_topic_09.rb
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(:spec => '09')
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
@@ -4,6 +4,7 @@
4
4
  "minor-version": 9,
5
5
  "revision": 1,
6
6
  "port": 5672,
7
+ "ssl_port": 5671,
7
8
  "copyright": [
8
9
  "Copyright (C) 2008-2009 LShift Ltd, Cohesive Financial Technologies LLC,\n",
9
10
  "and Rabbit Technologies Ltd\n",
data/ext/config.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :spec_out: '../lib/qrack/protocol/spec08.rb'
3
- :frame_out: '../lib/qrack/transport/frame08.rb'
4
- :spec_in: 'amqp-0.8.json'
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'] || '0'
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] = method_arr
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 buf
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