hot_bunnies 2.0.0.pre3-java → 2.0.0.pre4-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ require 'hot_bunnies/exceptions'
9
9
  require 'hot_bunnies/session'
10
10
 
11
11
  module HotBunnies
12
+ # Delegates to {HotBunnies::Session.connect}
12
13
  def self.connect(*args)
13
14
  Session.connect(*args)
14
15
  end
@@ -1,8 +1,7 @@
1
1
  module HotBunnies
2
- class Exception < ::StandardError
2
+ class Exception < StandardError
3
3
  end
4
4
 
5
-
6
5
  class ChannelLevelException < Exception
7
6
  attr_reader :channel_close
8
7
 
@@ -23,13 +22,9 @@ module HotBunnies
23
22
  end
24
23
  end
25
24
 
26
-
25
+ # Raised when RabbitMQ closes network connection before
26
+ # finalizing the connection, typically indicating authentication failure.
27
27
  class PossibleAuthenticationFailureError < Exception
28
-
29
- #
30
- # API
31
- #
32
-
33
28
  attr_reader :username, :vhost
34
29
 
35
30
  def initialize(username, vhost, password_length)
@@ -37,8 +32,8 @@ module HotBunnies
37
32
  @vhost = vhost
38
33
 
39
34
  super("RabbitMQ closed TCP connection before authentication succeeded: this usually means authentication failure due to misconfiguration or that RabbitMQ version does not support AMQP 0.9.1. Please check your configuration. Username: #{username}, vhost: #{vhost}, password length: #{password_length}")
40
- end # initialize(settings)
41
- end # PossibleAuthenticationFailureError
35
+ end
36
+ end
42
37
 
43
38
 
44
39
  class PreconditionFailed < ChannelLevelException
@@ -68,6 +63,7 @@ module HotBunnies
68
63
 
69
64
 
70
65
  # Converts RabbitMQ Java client exceptions
66
+ #
71
67
  # @private
72
68
  class Exceptions
73
69
  def self.convert(e, unwrap_io_exception = true)
@@ -147,5 +143,5 @@ module HotBunnies
147
143
 
148
144
  klass.new(m.reply_text, m)
149
145
  end
150
- end # Exceptions
146
+ end
151
147
  end # HotBunnies
@@ -47,13 +47,28 @@ module HotBunnies
47
47
  end
48
48
  alias pop get
49
49
 
50
+ def build_consumer(opts, &block)
51
+ if opts[:block] || opts[:blocking]
52
+ BlockingCallbackConsumer.new(@channel, opts[:buffer_size], opts, block)
53
+ else
54
+ AsyncCallbackConsumer.new(@channel, opts, block, opts.fetch(:executor, JavaConcurrent::Executors.new_single_thread_executor))
55
+ end
56
+ end
57
+
50
58
  def subscribe(opts = {}, &block)
51
- consumer = if opts[:block] || opts[:blocking]
52
- BlockingCallbackConsumer.new(@channel, opts[:buffer_size], opts, block)
53
- else
54
- AsyncCallbackConsumer.new(@channel, opts, block, opts.fetch(:executor, JavaConcurrent::Executors.new_single_thread_executor))
55
- end
59
+ consumer = build_consumer(opts, &block)
60
+
61
+ @consumer_tag = @channel.basic_consume(@name, !(opts[:ack] || opts[:manual_ack]), consumer)
62
+ consumer.consumer_tag = @consumer_tag
63
+
64
+ @default_consumer = consumer
65
+ @channel.register_consumer(@consumer_tag, consumer)
66
+ consumer.start
67
+
68
+ consumer
69
+ end
56
70
 
71
+ def subscribe_with(consumer, opts = {})
57
72
  @consumer_tag = @channel.basic_consume(@name, !(opts[:ack] || opts[:manual_ack]), consumer)
58
73
  consumer.consumer_tag = @consumer_tag
59
74
 
@@ -9,6 +9,9 @@ module HotBunnies
9
9
  # API
10
10
  #
11
11
 
12
+ # Connects to a RabbitMQ node.
13
+ #
14
+ # @api public
12
15
  def self.connect(options={})
13
16
  cf = ConnectionFactory.new
14
17
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module HotBunnies
4
- VERSION = "2.0.0.pre3"
4
+ VERSION = "2.0.0.pre4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot_bunnies
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre3
4
+ version: 2.0.0.pre4
5
5
  prerelease: 6
6
6
  platform: java
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-31 00:00:00.000000000 Z
13
+ date: 2013-06-28 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: RabbitMQ client for JRuby built around the official RabbitMQ Java client
16
16
  email:
@@ -31,7 +31,7 @@ files:
31
31
  - lib/hot_bunnies/queue.rb
32
32
  - lib/hot_bunnies/session.rb
33
33
  - lib/hot_bunnies/version.rb
34
- homepage: http://github.com/ruby-amqp/hot_bunnies
34
+ homepage: http://hotbunnies.info
35
35
  licenses: []
36
36
  post_install_message:
37
37
  rdoc_options: []
@@ -56,3 +56,4 @@ signing_key:
56
56
  specification_version: 3
57
57
  summary: RabbitMQ client for JRuby built around the official RabbitMQ Java client
58
58
  test_files: []
59
+ has_rdoc: