hot_bunnies 1.4.0.pre3-java → 1.4.0.pre4-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,15 @@
1
1
  # encoding: utf-8
2
2
 
3
+ module JavaConcurrent
4
+ java_import 'java.lang.Thread'
5
+ java_import 'java.lang.InterruptedException'
6
+ java_import 'java.util.concurrent.Executors'
7
+ java_import 'java.util.concurrent.LinkedBlockingQueue'
8
+ java_import 'java.util.concurrent.ArrayBlockingQueue'
9
+ java_import 'java.util.concurrent.TimeUnit'
10
+ java_import 'java.util.concurrent.atomic.AtomicBoolean'
11
+ end
12
+
3
13
  module HotBunnies
4
14
  class Queue
5
15
  attr_reader :name, :channel
@@ -59,8 +69,7 @@ module HotBunnies
59
69
  end
60
70
 
61
71
  class Subscription
62
- import 'java.util.concurrent.TimeUnit'
63
- import 'java.util.concurrent.atomic.AtomicBoolean'
72
+ include JavaConcurrent
64
73
 
65
74
  attr_reader :channel, :queue_name, :consumer_tag
66
75
 
@@ -133,7 +142,7 @@ module HotBunnies
133
142
  @executor = options[:executor]
134
143
  else
135
144
  @shut_down_executor = true
136
- @executor = java.util.concurrent.Executors.new_single_thread_executor
145
+ @executor = Executors.new_single_thread_executor
137
146
  end
138
147
  AsyncCallbackConsumer.new(@channel, callback, @executor)
139
148
  end
@@ -207,10 +216,7 @@ module HotBunnies
207
216
  end
208
217
 
209
218
  class BlockingCallbackConsumer < CallbackConsumer
210
- import 'java.util.concurrent.LinkedBlockingQueue'
211
- import 'java.util.concurrent.ArrayBlockingQueue'
212
- import 'java.util.concurrent.TimeUnit'
213
- import 'java.lang.InterruptedException'
219
+ include JavaConcurrent
214
220
 
215
221
  def initialize(channel, buffer_size, callback)
216
222
  super(channel, callback)
@@ -222,27 +228,31 @@ module HotBunnies
222
228
  end
223
229
 
224
230
  def start
225
- until @cancelled
231
+ interrupted = false
232
+ until @cancelled || JavaConcurrent::Thread.current_thread.interrupted?
226
233
  begin
227
234
  pair = @internal_queue.take
228
235
  callback(*pair) if pair
229
236
  rescue InterruptedException => e
230
- # time to stop
237
+ interrupted = true
231
238
  end
232
239
  end
233
240
  while (pair = @internal_queue.poll)
234
241
  callback(*pair)
235
242
  end
243
+ if interrupted
244
+ JavaConcurrent::Thread.current_thread.interrupt
245
+ end
236
246
  end
237
247
 
238
248
  def deliver(*pair)
239
- if @cancelling || @cancelled
249
+ if @cancelling || @cancelled || JavaConcurrent::Thread.current_thread.interrupted?
240
250
  @internal_queue.offer(pair)
241
251
  else
242
252
  begin
243
253
  @internal_queue.put(pair)
244
254
  rescue InterruptedException => e
245
- # time to stop
255
+ JavaConcurrent::Thread.current_thread.interrupt
246
256
  end
247
257
  end
248
258
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module HotBunnies
4
- VERSION = '1.4.0.pre3'
4
+ VERSION = '1.4.0.pre4'
5
5
  end
data/lib/hot_bunnies.rb CHANGED
@@ -6,13 +6,11 @@ require 'ext/rabbitmq-client'
6
6
 
7
7
 
8
8
  module HotBunnies
9
- import com.rabbitmq.client.ConnectionFactory
10
- import com.rabbitmq.client.Connection
11
- import com.rabbitmq.client.Channel
12
- import com.rabbitmq.client.DefaultConsumer
13
- import com.rabbitmq.client.QueueingConsumer
14
-
15
- import com.rabbitmq.client.AMQP
9
+ java_import 'com.rabbitmq.client.ConnectionFactory'
10
+ java_import 'com.rabbitmq.client.Connection'
11
+ java_import 'com.rabbitmq.client.Channel'
12
+ java_import 'com.rabbitmq.client.DefaultConsumer'
13
+ java_import 'com.rabbitmq.client.AMQP'
16
14
 
17
15
  def self.connect(options={})
18
16
  cf = ConnectionFactory.new
@@ -31,7 +29,6 @@ module HotBunnies
31
29
  cf.new_connection
32
30
  end
33
31
 
34
-
35
32
  protected
36
33
 
37
34
  def self.hostname_from(options)
metadata CHANGED
@@ -1,91 +1,83 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hot_bunnies
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.4.0.pre3
5
+ version: 1.4.0.pre4
6
6
  platform: java
7
- authors:
8
- - Theo Hultberg
9
- - Michael S. Klishin
10
- autorequire:
7
+ authors:
8
+ - Theo Hultberg
9
+ - Michael S. Klishin
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2012-06-29 00:00:00 Z
13
+ date: 2012-07-17 00:00:00.000000000 Z
15
14
  dependencies: []
16
-
17
15
  description: A object oriented interface to RabbitMQ that uses the Java driver under the hood
18
- email:
19
- - theo@burtcorp.com
16
+ email:
17
+ - theo@burtcorp.com
20
18
  executables: []
21
-
22
19
  extensions: []
23
-
24
20
  extra_rdoc_files: []
25
-
26
- files:
27
- - .gitignore
28
- - .rvmrc
29
- - .travis.yml
30
- - Gemfile
31
- - LICENSE
32
- - README.md
33
- - Rakefile
34
- - examples/blocking_subscription.rb
35
- - examples/non_blocking_subscription.rb
36
- - examples/non_blocking_subscription_with_executor.rb
37
- - hot_bunnies.gemspec
38
- - lib/ext/commons-io.jar
39
- - lib/ext/rabbitmq-client.jar
40
- - lib/hot_bunnies.rb
41
- - lib/hot_bunnies/channel.rb
42
- - lib/hot_bunnies/exchange.rb
43
- - lib/hot_bunnies/queue.rb
44
- - lib/hot_bunnies/version.rb
45
- - spec/integration/alternate_exchanges_spec.rb
46
- - spec/integration/basic_consume_spec.rb
47
- - spec/integration/connection_spec.rb
48
- - spec/integration/error_handling_by_consumers_spec.rb
49
- - spec/integration/exchange_bind_spec.rb
50
- - spec/integration/exchange_declare_spec.rb
51
- - spec/integration/message_metadata_access_spec.rb
52
- - spec/integration/publisher_confirmations_spec.rb
53
- - spec/integration/queue_bind_spec.rb
54
- - spec/integration/queue_declare_spec.rb
55
- - spec/integration/queue_delete_spec.rb
56
- - spec/integration/queue_purge_spec.rb
57
- - spec/integration/queue_unbind_spec.rb
58
- - spec/integration/sender_selected_distribution_spec.rb
59
- - spec/spec_helper.rb
21
+ files:
22
+ - .gitignore
23
+ - .rvmrc
24
+ - .travis.yml
25
+ - Gemfile
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - examples/blocking_subscription.rb
30
+ - examples/non_blocking_subscription.rb
31
+ - examples/non_blocking_subscription_with_executor.rb
32
+ - hot_bunnies.gemspec
33
+ - lib/ext/commons-io.jar
34
+ - lib/ext/rabbitmq-client.jar
35
+ - lib/hot_bunnies.rb
36
+ - lib/hot_bunnies/channel.rb
37
+ - lib/hot_bunnies/exchange.rb
38
+ - lib/hot_bunnies/queue.rb
39
+ - lib/hot_bunnies/version.rb
40
+ - spec/integration/alternate_exchanges_spec.rb
41
+ - spec/integration/basic_consume_spec.rb
42
+ - spec/integration/connection_spec.rb
43
+ - spec/integration/error_handling_by_consumers_spec.rb
44
+ - spec/integration/exchange_bind_spec.rb
45
+ - spec/integration/exchange_declare_spec.rb
46
+ - spec/integration/message_metadata_access_spec.rb
47
+ - spec/integration/publisher_confirmations_spec.rb
48
+ - spec/integration/queue_bind_spec.rb
49
+ - spec/integration/queue_declare_spec.rb
50
+ - spec/integration/queue_delete_spec.rb
51
+ - spec/integration/queue_purge_spec.rb
52
+ - spec/integration/queue_unbind_spec.rb
53
+ - spec/integration/sender_selected_distribution_spec.rb
54
+ - spec/spec_helper.rb
60
55
  homepage: http://github.com/iconara/hot_bunnies
61
56
  licenses: []
62
-
63
- post_install_message:
57
+ post_install_message:
64
58
  rdoc_options: []
65
-
66
- require_paths:
67
- - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ hash: 2
68
+ version: '0'
69
69
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 2
74
- segments:
75
- - 0
76
- version: "0"
77
- required_rubygems_version: !ruby/object:Gem::Requirement
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>'
73
+ - !ruby/object:Gem::Version
74
+ version: 1.3.1
78
75
  none: false
79
- requirements:
80
- - - ">"
81
- - !ruby/object:Gem::Version
82
- version: 1.3.1
83
76
  requirements: []
84
-
85
77
  rubyforge_project: hot_bunnies
86
78
  rubygems_version: 1.8.24
87
- signing_key:
79
+ signing_key:
88
80
  specification_version: 3
89
81
  summary: Ruby wrapper for the RabbitMQ Java driver
90
82
  test_files: []
91
-
83
+ ...