march_hare 2.8.0-java → 2.9.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ext/rabbitmq-client.jar +0 -0
- data/lib/march_hare/session.rb +100 -36
- data/lib/march_hare/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b56968635df7028f84b2f18fef851cd0351e43e6
|
4
|
+
data.tar.gz: 3a582e08e4ea7eb61974083b24d8b901d986883e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e39d246d86194431e946266af68edbb78e9f7d3db7b28b722bfec92e4f1b0bebf898cea92c5772020a66820e5f68837e3db886067e86a5992a5236af18116c77
|
7
|
+
data.tar.gz: 5be0b472967ff510a4dbec511cba883fac48fd49911e58b6d5e6e7e50ce08a41e751411507f047dcec45593f74013b07dddb57d1fc802af19ee803ad4da18b68
|
data/lib/ext/rabbitmq-client.jar
CHANGED
Binary file
|
data/lib/march_hare/session.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require "march_hare/shutdown_listener"
|
3
3
|
require "set"
|
4
4
|
require "march_hare/thread_pools"
|
5
|
+
require "java"
|
5
6
|
|
6
7
|
module MarchHare
|
7
8
|
java_import com.rabbitmq.client.ConnectionFactory
|
@@ -41,20 +42,26 @@ module MarchHare
|
|
41
42
|
# @option options [String] :password ("guest") Password
|
42
43
|
# @option options [String] :vhost ("/") Virtual host to use
|
43
44
|
# @option options [Integer] :requested_heartbeat (580) Heartbeat timeout used. 0 means no heartbeat.
|
44
|
-
# @option options [Boolean] :tls (false) Set to true to use TLS/SSL connection
|
45
|
+
# @option options [Boolean, String] :tls (false) Set to true to use TLS/SSL connection or TLS version name as a string, e.g. "TLSv1.1".
|
46
|
+
# This will switch port to 5671 by default.
|
47
|
+
# @option options [String] :tls_certificate_path Path to a PKCS12 certificate.
|
45
48
|
# @option options [java.util.concurrent.ThreadFactory] :thread_factory Thread factory RabbitMQ Java client will use (useful in restricted PaaS platforms such as GAE)
|
46
49
|
#
|
47
50
|
# @see http://rubymarchhare.info/articles/connecting.html Connecting to RabbitMQ guide
|
48
|
-
def self.connect(options={})
|
51
|
+
def self.connect(options = {})
|
49
52
|
cf = ConnectionFactory.new
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
if options[:uri]
|
55
|
+
cf.uri = options[:uri] if options[:uri]
|
56
|
+
else
|
57
|
+
cf.host = hostname_from(options) if include_host?(options)
|
58
|
+
cf.port = options[:port].to_i if options[:port]
|
59
|
+
cf.virtual_host = vhost_from(options) if include_vhost?(options)
|
60
|
+
cf.username = username_from(options) if include_username?(options)
|
61
|
+
cf.password = password_from(options) if include_password?(options)
|
62
|
+
end
|
63
|
+
|
64
|
+
cf.connection_timeout = timeout_from(options) if include_timeout?(options)
|
58
65
|
|
59
66
|
cf.requested_heartbeat = heartbeat_from(options)
|
60
67
|
cf.connection_timeout = connection_timeout_from(options) if include_connection_timeout?(options)
|
@@ -67,44 +74,41 @@ module MarchHare
|
|
67
74
|
when true then
|
68
75
|
cf.use_ssl_protocol
|
69
76
|
when String then
|
77
|
+
# TODO: logging
|
78
|
+
$stdout.puts "Using TLS/SSL version #{tls}"
|
70
79
|
if options[:trust_manager]
|
71
80
|
cf.use_ssl_protocol(tls, options[:trust_manager])
|
72
|
-
elsif (
|
73
|
-
|
74
|
-
|
81
|
+
elsif (cert_path = tls_certificate_path_from(options)) && (password = tls_certificate_password_from(options))
|
82
|
+
ctx = SSLContext.get_instance(tls)
|
83
|
+
pwd = password.to_java.to_char_array
|
75
84
|
begin
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
key_manager_factory = KeyManagerFactory.get_instance("SunX509")
|
81
|
-
key_manager_factory.init(key_store, certificate_password)
|
85
|
+
is = File.new(cert_path).to_inputstream
|
86
|
+
ks = KeyStore.get_instance('PKCS12')
|
87
|
+
ks.load(is, pwd)
|
82
88
|
|
83
|
-
|
89
|
+
kmf = KeyManagerFactory.get_instance("SunX509")
|
90
|
+
kmf.init(ks, pwd)
|
84
91
|
|
85
|
-
|
92
|
+
ctx.init(kmf.get_key_managers, [NullTrustManager.new].to_java('javax.net.ssl.TrustManager'), nil)
|
86
93
|
|
87
|
-
cf.use_ssl_protocol(
|
88
|
-
|
89
|
-
rescue Java::JavaLang::Exception => e
|
94
|
+
cf.use_ssl_protocol(ctx)
|
95
|
+
rescue Java::JavaLang::Throwable => e
|
90
96
|
message = e.message
|
91
97
|
message << "\n"
|
92
98
|
message << e.backtrace.join("\n")
|
93
99
|
|
94
100
|
raise SSLContextException.new(message)
|
95
101
|
ensure
|
96
|
-
|
97
|
-
end
|
102
|
+
is.close if is
|
103
|
+
end
|
98
104
|
else
|
99
105
|
cf.use_ssl_protocol(tls)
|
100
106
|
end
|
101
107
|
end
|
102
108
|
|
103
|
-
|
104
109
|
new(cf, options)
|
105
110
|
end
|
106
111
|
|
107
|
-
|
108
112
|
class SSLContextException < StandardError
|
109
113
|
end
|
110
114
|
|
@@ -116,6 +120,8 @@ module MarchHare
|
|
116
120
|
# @private
|
117
121
|
def initialize(connection_factory, opts = {})
|
118
122
|
@cf = connection_factory
|
123
|
+
@uri = opts[:uri]
|
124
|
+
@uses_uri = !(@uri.nil?)
|
119
125
|
# executors cannot be restarted after shutdown,
|
120
126
|
# so we really need a factory here. MK.
|
121
127
|
@executor_factory = opts[:executor_factory] || build_executor_factory_from(opts)
|
@@ -124,7 +130,11 @@ module MarchHare
|
|
124
130
|
@default_host_selection_strategy = lambda { |hosts| hosts.sample }
|
125
131
|
@host_selection_strategy = opts[:host_selection_strategy] || @default_host_selection_strategy
|
126
132
|
|
127
|
-
@connection =
|
133
|
+
@connection = if @uses_uri
|
134
|
+
self.new_uri_connection_impl(opts[:uri])
|
135
|
+
else
|
136
|
+
self.new_connection_impl(@hosts, @host_selection_strategy)
|
137
|
+
end
|
128
138
|
@channels = JavaConcurrent::ConcurrentHashMap.new
|
129
139
|
|
130
140
|
# should automatic recovery from network failures be used?
|
@@ -240,7 +250,11 @@ module MarchHare
|
|
240
250
|
|
241
251
|
new_connection = converting_rjc_exceptions_to_ruby do
|
242
252
|
reconnecting_on_network_failures(ms) do
|
243
|
-
|
253
|
+
if @uses_uri
|
254
|
+
self.new_uri_connection_impl(options[:uri])
|
255
|
+
else
|
256
|
+
self.new_connection_impl(@hosts, @host_selection_strategy)
|
257
|
+
end
|
244
258
|
end
|
245
259
|
end
|
246
260
|
@thread_pool = ThreadPools.dynamically_growing
|
@@ -299,6 +313,35 @@ module MarchHare
|
|
299
313
|
# the call to #start. MK.
|
300
314
|
end
|
301
315
|
|
316
|
+
def username
|
317
|
+
@cf.username
|
318
|
+
end
|
319
|
+
alias user username
|
320
|
+
|
321
|
+
def vhost
|
322
|
+
@cf.virtual_host
|
323
|
+
end
|
324
|
+
|
325
|
+
def hostname
|
326
|
+
@cf.host
|
327
|
+
end
|
328
|
+
alias host hostname
|
329
|
+
|
330
|
+
def port
|
331
|
+
@cf.port
|
332
|
+
end
|
333
|
+
|
334
|
+
def tls?
|
335
|
+
if @uses_uri
|
336
|
+
u = java.net.URI.new(@uri.to_java_string)
|
337
|
+
|
338
|
+
u.scheme == "amqps"
|
339
|
+
else
|
340
|
+
self.port == ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT
|
341
|
+
end
|
342
|
+
end
|
343
|
+
alias ssl? tls?
|
344
|
+
|
302
345
|
def method_missing(selector, *args)
|
303
346
|
@connection.__send__(selector, *args)
|
304
347
|
end
|
@@ -450,7 +493,7 @@ module MarchHare
|
|
450
493
|
|
451
494
|
# @private
|
452
495
|
def new_connection_impl(hosts, host_selector)
|
453
|
-
if hosts && !hosts.empty?
|
496
|
+
if hosts && !hosts.empty? && !@uses_uri
|
454
497
|
@cf.host = host_selector.call(hosts)
|
455
498
|
end
|
456
499
|
|
@@ -464,6 +507,19 @@ module MarchHare
|
|
464
507
|
end
|
465
508
|
end
|
466
509
|
|
510
|
+
# @private
|
511
|
+
def new_uri_connection_impl(uri)
|
512
|
+
@cf.uri = uri
|
513
|
+
converting_rjc_exceptions_to_ruby do
|
514
|
+
if @executor_factory
|
515
|
+
@executor = @executor_factory.call
|
516
|
+
@cf.new_connection(@executor)
|
517
|
+
else
|
518
|
+
@cf.new_connection
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
467
523
|
# @private
|
468
524
|
def maybe_shut_down_executor
|
469
525
|
@executor.shutdown if @executor
|
@@ -480,15 +536,23 @@ module MarchHare
|
|
480
536
|
end
|
481
537
|
end
|
482
538
|
|
539
|
+
def self.tls_certificate_path_from(opts)
|
540
|
+
opts[:tls_cert] || opts[:ssl_cert] || opts[:tls_cert_path] || opts[:ssl_cert_path] || opts[:tls_certificate_path] || opts[:ssl_certificate_path]
|
541
|
+
end
|
542
|
+
|
483
543
|
# @private
|
484
|
-
def
|
485
|
-
opts
|
544
|
+
def tls_certificate_path_from(opts)
|
545
|
+
self.class.tls_certificate_path_from(opts)
|
486
546
|
end
|
487
|
-
|
547
|
+
|
548
|
+
def self.tls_certificate_password_from(opts)
|
549
|
+
opts[:tls_certificate_password] || opts[:ssl_certificate_password] || opts[:cert_password] || opts[:certificate_password]
|
550
|
+
end
|
551
|
+
|
488
552
|
# @private
|
489
|
-
def
|
490
|
-
opts
|
491
|
-
end
|
553
|
+
def tls_certificate_password_from(opts)
|
554
|
+
self.class.tls_certificate_password_from(opts)
|
555
|
+
end
|
492
556
|
|
493
557
|
# Ruby blocks-based BlockedListener that handles
|
494
558
|
# connection.blocked and connection.unblocked.
|
data/lib/march_hare/version.rb
CHANGED
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.
|
4
|
+
version: 2.9.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: 2015-
|
12
|
+
date: 2015-04-04 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:
|
@@ -60,3 +60,4 @@ signing_key:
|
|
60
60
|
specification_version: 4
|
61
61
|
summary: RabbitMQ client for JRuby built around the official RabbitMQ Java client
|
62
62
|
test_files: []
|
63
|
+
has_rdoc:
|