hot_bunnies 2.0.0.pre4-java → 2.0.0.pre6-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,7 @@ module HotBunnies
14
14
  Session.connect(*args)
15
15
  end
16
16
  end
17
+ Hotbunnies = HotBunnies
17
18
 
18
19
  require 'hot_bunnies/channel'
19
20
  require 'hot_bunnies/queue'
@@ -71,6 +71,8 @@ module HotBunnies
71
71
 
72
72
  class CallbackConsumer < BaseConsumer
73
73
  def initialize(channel, callback)
74
+ raise ArgumentError, "callback must not be nil!" if callback.nil?
75
+
74
76
  super(channel)
75
77
  @callback = callback
76
78
  @callback_arity = @callback.arity
@@ -2,6 +2,12 @@ module HotBunnies
2
2
  class Exception < StandardError
3
3
  end
4
4
 
5
+ class NetworkException < Exception
6
+ end
7
+
8
+ class ConnectionRefused < NetworkException
9
+ end
10
+
5
11
  class ChannelLevelException < Exception
6
12
  attr_reader :channel_close
7
13
 
@@ -60,6 +66,9 @@ module HotBunnies
60
66
  class UnexpectedFrame < ConnectionLevelException
61
67
  end
62
68
 
69
+ class ChannelAlreadyClosed < Exception
70
+ end
71
+
63
72
 
64
73
 
65
74
  # Converts RabbitMQ Java client exceptions
@@ -77,9 +86,7 @@ module HotBunnies
77
86
  c
78
87
  end
79
88
  when com.rabbitmq.client.AlreadyClosedException then
80
- cmd = e.reason
81
-
82
- puts cmd.method.class.inspect
89
+ ChannelAlreadyClosed.new(e.reason)
83
90
  when com.rabbitmq.client.ShutdownSignalException then
84
91
  cmd = e.reason
85
92
 
@@ -38,13 +38,16 @@ module HotBunnies
38
38
  end
39
39
  end
40
40
 
41
+
41
42
  new(cf)
42
43
  end
43
44
 
44
45
 
45
46
  def initialize(connection_factory)
46
47
  @cf = connection_factory
47
- @connection = self.new_connection
48
+ @connection = converting_rjc_exceptions_to_ruby do
49
+ self.new_connection
50
+ end
48
51
  @channels = ConcurrentHashMap.new
49
52
  end
50
53
 
@@ -159,6 +162,8 @@ module HotBunnies
159
162
  def converting_rjc_exceptions_to_ruby(&block)
160
163
  begin
161
164
  block.call
165
+ rescue java.net.ConnectException => e
166
+ raise ConnectionRefused.new("Connection to #{@cf.host}:#{@cf.port} refused")
162
167
  rescue com.rabbitmq.client.PossibleAuthenticationFailureException => e
163
168
  raise PossibleAuthenticationFailureError.new(@cf.username, @cf.virtual_host, @cf.password.bytesize)
164
169
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module HotBunnies
4
- VERSION = "2.0.0.pre4"
4
+ VERSION = "2.0.0.pre6"
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.pre4
4
+ version: 2.0.0.pre6
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-06-28 00:00:00.000000000 Z
13
+ date: 2013-07-01 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: