march_hare 2.18.0-java → 2.19.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2076b8b72612200ebc8693e5892120ea11f3b1f3
4
- data.tar.gz: 4f2063a3b9abcb4df84922abffe67de36cac90c2
3
+ metadata.gz: 8dc736328193c189024f9025c51e1950be461b72
4
+ data.tar.gz: 8c7997571606bddc54fefd82f4902cddda6b0605
5
5
  SHA512:
6
- metadata.gz: c01d61b114229154a305f1ea9f962b0417183730f66d53f4b63ccdd82d218b1c573745a7ac93b526406f637e48709595af223bd116315c0fee445a3ea98eb242
7
- data.tar.gz: a383c7dd10a7524881d62e88d18e3e08224317e2a852809b8b713b7acb85663039684514f48f5f9d69a18352636fdb1b3c326c1ab62507d8b8823558f157d50d
6
+ metadata.gz: 689c4fb17b918f9a1d7b46810ae034d0f39a5e1a57fa5bf3690da5d57382b2aac8752ae6a4f9ad98d95a41fc653e52531b1d9337c2e24b05d2525beecb6b9001
7
+ data.tar.gz: 84bf5d5c28da7fb429024f6978243362f075f31fbb1b14fd8856f4478db2ad6f64816adfe380a11eb0ea4b1a0726491a0caeb53dc285dad9751a9c27723267a4
Binary file
@@ -226,19 +226,19 @@ module MarchHare
226
226
  # Recovery feature.
227
227
  #
228
228
  def recover_prefetch_setting
229
- basic_qos(@prefetch_count) if @prefetch_count
229
+ basic_qos(@prefetch_count) if defined?(@prefetch_count) && @prefetch_count
230
230
  end
231
231
 
232
232
  # Recovers publisher confirms mode. Used by the Automatic Network Failure
233
233
  # Recovery feature.
234
234
  def recover_confirm_mode
235
- confirm_select if @confirm_mode
235
+ confirm_select if defined?(@confirm_mode) && @confirm_mode
236
236
  end
237
237
 
238
238
  # Recovers transaction mode. Used by the Automatic Network Failure
239
239
  # Recovery feature.
240
240
  def recover_tx_mode
241
- tx_select if @tx_mode
241
+ tx_select if defined?(@tx_mode) && @tx_mode
242
242
  end
243
243
 
244
244
  # Recovers exchanges. Used by the Automatic Network Failure
@@ -57,7 +57,7 @@ module MarchHare
57
57
  # @option opts [Boolean] :mandatory Should the message be returned if it cannot be routed to any queue?
58
58
  # @option opts [Hash] :properties Messages and delivery properties
59
59
  #
60
- # * :timestamp (Integer) A timestamp associated with this message
60
+ # * :timestamp (Time) A timestamp associated with this message
61
61
  # * :expiration (Integer) Expiration time after which the message will be deleted
62
62
  # * :type (String) Message type, e.g. what type of event or command this message represents. Can be any string
63
63
  # * :reply_to (String) Queue name other apps should send the response to
@@ -143,7 +143,7 @@ module MarchHare
143
143
  @channel.queue_purge(@name)
144
144
  end
145
145
 
146
- def get(options = {:block => false})
146
+ def get(options = {})
147
147
  response = @channel.basic_get(@name, !options.fetch(:ack, false))
148
148
 
149
149
  if response
@@ -36,6 +36,7 @@ module MarchHare
36
36
  #
37
37
  # @param [Hash] options Connection options
38
38
  #
39
+ # @option options [Numeric] :executor_shutdown_timeout (30.0) when recovering from a network failure how long should we wait for the current threadpool to finish handling its messages
39
40
  # @option options [String] :host ("127.0.0.1") Hostname or IP address to connect to
40
41
  # @option options [Integer] :port (5672) Port RabbitMQ listens on
41
42
  # @option options [String] :username ("guest") Username
@@ -125,6 +126,8 @@ module MarchHare
125
126
  # executors cannot be restarted after shutdown,
126
127
  # so we really need a factory here. MK.
127
128
  @executor_factory = opts[:executor_factory] || build_executor_factory_from(opts)
129
+ # we expect this option to be specified in seconds
130
+ @executor_shutdown_timeout = opts.fetch(:executor_shutdown_timeout, 30.0)
128
131
 
129
132
  @hosts = self.class.hosts_from(opts)
130
133
  @default_host_selection_strategy = lambda { |hosts| hosts.sample }
@@ -165,6 +168,14 @@ module MarchHare
165
168
  else
166
169
  @connection.create_channel
167
170
  end
171
+ if jc.nil?
172
+ error_message = <<-MSG
173
+ Unable to create a channel. This is likely due to having a channel_max setting
174
+ on the rabbitmq broker (see https://www.rabbitmq.com/configure.html).
175
+ There are currently #{@channels.size} channels on this connection.
176
+ MSG
177
+ raise ::MarchHare::ChannelError.new(error_message, false)
178
+ end
168
179
 
169
180
  ch = Channel.new(self, jc)
170
181
  register_channel(ch)
@@ -238,7 +249,7 @@ module MarchHare
238
249
 
239
250
  # @private
240
251
  def disable_automatic_recovery
241
- @connetion.remove_shutdown_listener(@automatic_recovery_hook) if @automatic_recovery_hook
252
+ @connection.remove_shutdown_listener(@automatic_recovery_hook) if @automatic_recovery_hook
242
253
  end
243
254
 
244
255
  # Begins automatic connection recovery (typically only used internally
@@ -257,7 +268,6 @@ module MarchHare
257
268
  end
258
269
  end
259
270
  end
260
- @thread_pool = ThreadPools.dynamically_growing
261
271
  self.recover_shutdown_hooks(new_connection)
262
272
 
263
273
  # sorting channels by id means that the cases like the following:
@@ -499,6 +509,7 @@ module MarchHare
499
509
 
500
510
  converting_rjc_exceptions_to_ruby do
501
511
  if @executor_factory
512
+ shut_down_executor_pool_and_await_timeout
502
513
  @executor = @executor_factory.call
503
514
  @cf.new_connection(@executor)
504
515
  else
@@ -512,6 +523,7 @@ module MarchHare
512
523
  @cf.uri = uri
513
524
  converting_rjc_exceptions_to_ruby do
514
525
  if @executor_factory
526
+ shut_down_executor_pool_and_await_timeout
515
527
  @executor = @executor_factory.call
516
528
  @cf.new_connection(@executor)
517
529
  else
@@ -522,7 +534,18 @@ module MarchHare
522
534
 
523
535
  # @private
524
536
  def maybe_shut_down_executor
525
- @executor.shutdown if @executor
537
+ @executor.shutdown if defined?(@executor) && @executor
538
+ end
539
+
540
+ def shut_down_executor_pool_and_await_timeout
541
+ return unless defined?(@executor) && @executor
542
+ ms_to_wait = (@executor_shutdown_timeout * 1000).to_i
543
+ @executor.shutdown()
544
+ unless @executor.awaitTermination(ms_to_wait, java.util.concurrent.TimeUnit::MILLISECONDS)
545
+ @executor.shutdownNow()
546
+ end
547
+ rescue java.lang.InterruptedException
548
+ #no op, just means we got a forced shutdown
526
549
  end
527
550
 
528
551
  # Makes it easier to construct executor factories.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module MarchHare
4
- VERSION = "2.18.0"
4
+ VERSION = "2.19.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: march_hare
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.0
4
+ version: 2.19.0
5
5
  platform: java
6
6
  authors:
7
7
  - Theo Hultberg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-14 00:00:00.000000000 Z
12
+ date: 2016-10-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: RabbitMQ client for JRuby built around the official RabbitMQ Java client
15
15
  email:
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  requirements: []
57
57
  rubyforge_project: march_hare
58
- rubygems_version: 2.4.8
58
+ rubygems_version: 2.6.4
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: RabbitMQ client for JRuby built around the official RabbitMQ Java client