jruby-hornetq 0.2.5.alpha → 0.3.0.alpha
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.
- data/HISTORY.md +12 -0
- data/Rakefile +13 -1
- data/bin/hornetq_server +2 -2
- data/examples/README +6 -0
- data/examples/{client/advanced → advanced}/batch_client.rb +18 -34
- data/examples/advanced/bytes_producer.rb +25 -0
- data/examples/advanced/client.rb +56 -0
- data/examples/{client/advanced/multi_client.rb → advanced/client_session_pooling.rb} +29 -25
- data/examples/advanced/consume_on_message.rb +50 -0
- data/examples/advanced/consumer.rb +31 -0
- data/examples/{client/advanced → advanced}/hornetq.yml +8 -6
- data/examples/advanced/multi_client.rb +71 -0
- data/examples/advanced/producer.rb +37 -0
- data/examples/advanced/server.rb +44 -0
- data/examples/client-server/client.rb +40 -0
- data/examples/client-server/server.rb +37 -0
- data/examples/producer-consumer/consume_all.rb +25 -0
- data/examples/producer-consumer/consume_on_message.rb +46 -0
- data/examples/producer-consumer/consumer.rb +27 -0
- data/examples/producer-consumer/producer.rb +32 -0
- data/examples/{client/resque → resque}/hornetq_job.rb +2 -2
- data/examples/{client/resque → resque}/processor.rb +1 -1
- data/examples/{client/resque → resque}/readme.md +0 -0
- data/examples/{client/resque → resque}/resque_conf.rb +0 -0
- data/examples/{client/resque → resque}/resque_worker.rb +0 -0
- data/examples/{client/resque → resque}/sleep_job.rb +0 -0
- data/examples/{server → server-config}/backup_server.yml +0 -0
- data/examples/{server → server-config}/live_server.yml +0 -0
- data/examples/{server → server-config}/standalone_server.yml +0 -0
- data/examples/{client → simple}/invm.rb +6 -7
- data/examples/{advanced/transaction-failover → transaction-failover}/README +0 -0
- data/examples/{advanced/transaction-failover → transaction-failover}/consumer.rb +4 -1
- data/examples/{advanced/transaction-failover → transaction-failover}/hornetq.yml +6 -3
- data/examples/{advanced/transaction-failover → transaction-failover}/producer.rb +8 -3
- data/examples/{simple_worker → worker}/README +0 -0
- data/examples/worker/hornetq.yml +26 -0
- data/examples/worker/producer.rb +71 -0
- data/examples/{simple_worker → worker}/test_object.rb +0 -0
- data/examples/worker/worker.rb +72 -0
- data/lib/hornetq/client.rb +1 -1
- data/lib/hornetq/client/{factory.rb → connection.rb} +153 -86
- data/lib/hornetq/client/message_handler.rb +3 -3
- data/lib/hornetq/client/org_hornetq_api_core_client_client_session.rb +187 -26
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_consumer_impl.rb +26 -9
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_message_impl.rb +190 -35
- data/lib/hornetq/client/session_pool.rb +4 -4
- data/lib/hornetq/common/log_delegate.rb +17 -15
- data/lib/hornetq/common/logging.rb +20 -7
- data/lib/hornetq/common/org_hornetq_core_logging_logger.rb +11 -9
- data/lib/hornetq/server.rb +86 -3
- data/lib/hornetq/{org_hornetq_core_server_hornet_q_server.rb → server/org_hornetq_core_server_hornet_q_server.rb} +1 -1
- data/lib/hornetq/uri.rb +4 -0
- data/test/client_connection_test.rb +158 -0
- data/test/logging_test.rb +32 -0
- data/test/server_test.rb +208 -0
- metadata +47 -48
- data/examples/client/advanced/bytes_producer.rb +0 -21
- data/examples/client/advanced/client.rb +0 -47
- data/examples/client/advanced/consumer.rb +0 -35
- data/examples/client/advanced/multi_consumer.rb +0 -54
- data/examples/client/advanced/producer.rb +0 -35
- data/examples/client/advanced/server.rb +0 -39
- data/examples/client/client.rb +0 -31
- data/examples/client/consumer.rb +0 -22
- data/examples/client/data/bindings/hornetq-bindings-1.bindings +0 -0
- data/examples/client/data/bindings/hornetq-bindings-2.bindings +0 -0
- data/examples/client/data/journal/hornetq-data-1.hq +0 -0
- data/examples/client/data/journal/hornetq-data-2.hq +0 -0
- data/examples/client/producer.rb +0 -21
- data/examples/client/server.rb +0 -31
- data/examples/simple_worker/hornetq.yml +0 -34
- data/examples/simple_worker/producer.rb +0 -54
- data/examples/simple_worker/worker.rb +0 -49
- data/lib/data/bindings/hornetq-bindings-1.bindings +0 -0
- data/lib/data/bindings/hornetq-bindings-2.bindings +0 -0
- data/lib/hornetq/server/factory.rb +0 -87
- data/test/server_factory_test.rb +0 -183
@@ -1,54 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Consumer:
|
3
|
-
# Multi-threaded Consumer
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'yaml'
|
11
|
-
require 'hornetq'
|
12
|
-
|
13
|
-
# Arguments: 'number of threads' 'timeout'
|
14
|
-
$thread_count = (ARGV[0] || 3).to_i
|
15
|
-
$timeout = (ARGV[1] || 1000).to_i
|
16
|
-
|
17
|
-
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
18
|
-
|
19
|
-
def worker(id, session)
|
20
|
-
begin
|
21
|
-
consumer = session.create_consumer('jms.queue.ExampleQueue')
|
22
|
-
session.start
|
23
|
-
|
24
|
-
count = 0
|
25
|
-
start_time = Time.now
|
26
|
-
while message = consumer.receive($timeout)
|
27
|
-
count = count + 1
|
28
|
-
message.acknowledge
|
29
|
-
#puts "=================================="
|
30
|
-
#text = message.body
|
31
|
-
#p text
|
32
|
-
#p message
|
33
|
-
puts "Durable" if message.durable
|
34
|
-
print "#{id}."
|
35
|
-
end
|
36
|
-
duration = Time.now - start_time - $timeout/1000
|
37
|
-
puts "\nReceived #{count} messages in #{duration} seconds at #{count/duration} messages per second"
|
38
|
-
rescue Exception => exc
|
39
|
-
puts "Thread #{id} Terminating"
|
40
|
-
p exc
|
41
|
-
ensure
|
42
|
-
session.close
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Create a HornetQ session
|
47
|
-
HornetQ::Client::Factory.create_factory(config[:connector]) do |factory|
|
48
|
-
threads = []
|
49
|
-
$thread_count.times do |i|
|
50
|
-
session = factory.create_session(config[:session])
|
51
|
-
threads << Thread.new { worker(i, session) }
|
52
|
-
end
|
53
|
-
threads.each {|t| t.join}
|
54
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Producer:
|
3
|
-
# Write messages to the queue
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'yaml'
|
11
|
-
require 'hornetq'
|
12
|
-
|
13
|
-
count = (ARGV[0] || 1).to_i
|
14
|
-
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
15
|
-
|
16
|
-
# Create a HornetQ session
|
17
|
-
HornetQ::Client::Factory.session(config) do |session|
|
18
|
-
producer = session.create_producer('jms.queue.ExampleQueue')
|
19
|
-
start_time = Time.now
|
20
|
-
|
21
|
-
puts "Sending messages"
|
22
|
-
(1..count).each do |i|
|
23
|
-
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
24
|
-
# Set the message body text
|
25
|
-
message.body = "#{Time.now}: ### Hello, World ###"
|
26
|
-
# Send message to the queue
|
27
|
-
producer.send(message)
|
28
|
-
#puts message
|
29
|
-
puts "#{i}\n" if i%1000 == 0
|
30
|
-
puts "Durable" if message.durable
|
31
|
-
end
|
32
|
-
|
33
|
-
duration = Time.now - start_time
|
34
|
-
puts "Delivered #{count} messages in #{duration} seconds at #{count/duration} messages per second"
|
35
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Consumer:
|
3
|
-
# Reply to a request
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'yaml'
|
11
|
-
require 'hornetq'
|
12
|
-
|
13
|
-
timeout = (ARGV[0] || 60000).to_i
|
14
|
-
|
15
|
-
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
16
|
-
|
17
|
-
# Create a HornetQ session
|
18
|
-
HornetQ::Client::Factory.session(config) do |session|
|
19
|
-
server = session.create_server('jms.queue.ExampleQueue', timeout)
|
20
|
-
session.start
|
21
|
-
|
22
|
-
count = 0
|
23
|
-
start_time = Time.now
|
24
|
-
puts "Server started and waiting for requests ..."
|
25
|
-
server.run do |request_message|
|
26
|
-
count += 1
|
27
|
-
print '.'
|
28
|
-
puts "#{count}" if count%1000 == 0
|
29
|
-
puts "Durable" if request_message.durable
|
30
|
-
reply_message = session.create_message(HornetQ::Client::Message::TEXT_TYPE, false)
|
31
|
-
reply_message.body = "Test Response"
|
32
|
-
reply_message
|
33
|
-
end
|
34
|
-
|
35
|
-
duration = Time.now - start_time - timeout/1000
|
36
|
-
puts "\nReceived #{count} requests in #{duration} seconds at #{count/duration} messages per second"
|
37
|
-
|
38
|
-
server.close
|
39
|
-
end
|
data/examples/client/client.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Requestor:
|
3
|
-
# Submit a request and wait for a reply
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'hornetq'
|
11
|
-
|
12
|
-
timeout = (ARGV[0] || 5000).to_i
|
13
|
-
|
14
|
-
HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
15
|
-
requestor = session.create_requestor('jms.queue.ExampleQueue')
|
16
|
-
|
17
|
-
# Create non-durable message
|
18
|
-
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
19
|
-
message.body = "Request Current Time"
|
20
|
-
|
21
|
-
# Send message to the queue
|
22
|
-
puts "Send request message and wait for Reply"
|
23
|
-
if reply = requestor.request(message, timeout)
|
24
|
-
puts "Received Response: #{reply.inspect}"
|
25
|
-
puts " Message: #{reply.body.inspect}"
|
26
|
-
else
|
27
|
-
puts "Time out, No reply received after #{timeout/1000} seconds"
|
28
|
-
end
|
29
|
-
|
30
|
-
requestor.close
|
31
|
-
end
|
data/examples/client/consumer.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Consumer:
|
3
|
-
# Write a single message to the queue
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'hornetq'
|
11
|
-
|
12
|
-
HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
13
|
-
consumer = session.create_consumer('jms.queue.ExampleQueue')
|
14
|
-
|
15
|
-
# Receive a single message, return immediately if no message available
|
16
|
-
if message = consumer.receive_immediate
|
17
|
-
puts "Received:[#{message.body}]"
|
18
|
-
message.acknowledge
|
19
|
-
else
|
20
|
-
puts "No message found"
|
21
|
-
end
|
22
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/examples/client/producer.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Producer:
|
3
|
-
# Write messages to the queue
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'hornetq'
|
11
|
-
|
12
|
-
HornetQ::Client::Factory.session('hornetq://localhost') do |session|
|
13
|
-
# Create Producer so that we can send messages to the Address 'jms.queue.ExampleQueue'
|
14
|
-
producer = session.create_producer('jms.queue.ExampleQueue')
|
15
|
-
|
16
|
-
# Create a non-durable message to send
|
17
|
-
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
18
|
-
message.body = "#{Time.now}: ### Hello, World ###"
|
19
|
-
|
20
|
-
producer.send(message)
|
21
|
-
end
|
data/examples/client/server.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# HornetQ Consumer:
|
3
|
-
# Reply to a request
|
4
|
-
#
|
5
|
-
|
6
|
-
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'hornetq'
|
11
|
-
|
12
|
-
timeout = (ARGV[0] || 60000).to_i
|
13
|
-
|
14
|
-
HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
15
|
-
server = session.create_server('jms.queue.ExampleQueue', timeout)
|
16
|
-
|
17
|
-
puts "Waiting for Requests..."
|
18
|
-
server.run do |request_message|
|
19
|
-
puts "Received:[#{request_message.body}]"
|
20
|
-
|
21
|
-
# Create Reply Message
|
22
|
-
reply_message = session.create_message(HornetQ::Client::Message::TEXT_TYPE, false)
|
23
|
-
reply_message.body = "Echo [#{request_message.body}]"
|
24
|
-
|
25
|
-
# The result of the block is the message to be sent back
|
26
|
-
reply_message
|
27
|
-
end
|
28
|
-
|
29
|
-
# Server will stop after timeout period after no messages received. Set to 0 to wait foreve
|
30
|
-
server.close
|
31
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
standalone_server:
|
2
|
-
:uri: hornetq://localhost:15445
|
3
|
-
:data_directory: ./data
|
4
|
-
:persistence_enabled: true
|
5
|
-
:security_enabled: false
|
6
|
-
|
7
|
-
client:
|
8
|
-
:connector:
|
9
|
-
:uri: hornetq://localhost:15445
|
10
|
-
:session:
|
11
|
-
:username: guest
|
12
|
-
:password: guest
|
13
|
-
:session_pool:
|
14
|
-
:pool_size: 3
|
15
|
-
:pool_warn_timeout: 0.25
|
16
|
-
:username: guest
|
17
|
-
:password: guest
|
18
|
-
|
19
|
-
:addresses:
|
20
|
-
address1:
|
21
|
-
:serialize: ruby_marshal
|
22
|
-
:unique: true
|
23
|
-
:durable: true
|
24
|
-
:queues:
|
25
|
-
queue1_1:
|
26
|
-
queue1_2:
|
27
|
-
|
28
|
-
address2:
|
29
|
-
:serialize: json
|
30
|
-
:unique: false
|
31
|
-
:durable: false
|
32
|
-
:queues:
|
33
|
-
queue2_1:
|
34
|
-
queue2_2:
|
@@ -1,54 +0,0 @@
|
|
1
|
-
#!/usr/bin/env jruby
|
2
|
-
#
|
3
|
-
# HornetQ Producer:
|
4
|
-
# Write messages to the queue
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'yaml'
|
9
|
-
require 'hornetq'
|
10
|
-
require 'logger'
|
11
|
-
require 'test_object'
|
12
|
-
|
13
|
-
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')
|
14
|
-
client = config['client']
|
15
|
-
|
16
|
-
# Create a HornetQ session
|
17
|
-
logger = Logger.new($stdout)
|
18
|
-
factory = HornetQ::Client::Factory.new(client[:connector])
|
19
|
-
session_pool = factory.create_session_pool(client[:session_pool])
|
20
|
-
producer_manager = HornetQ::Client::ProducerManager.new(session_pool, client[:addresses], true)
|
21
|
-
|
22
|
-
['HUP', 'INT', 'TERM'].each do |signal_name|
|
23
|
-
Signal.trap(signal_name) do
|
24
|
-
puts "caught #{signal_name}"
|
25
|
-
$stopped = true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
$stopped = false
|
30
|
-
threads = []
|
31
|
-
(1..5).each do |i|
|
32
|
-
threads << Thread.new(i) do |thread_count|
|
33
|
-
msg_count = 0
|
34
|
-
while !$stopped
|
35
|
-
msg_count += 1
|
36
|
-
obj = TestObject.new("Message ##{thread_count}-#{msg_count}")
|
37
|
-
producer_manager.send('address1', obj)
|
38
|
-
sleep 1
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
(6..10).each do |i|
|
43
|
-
threads << Thread.new(i) do |thread_count|
|
44
|
-
msg_count = 0
|
45
|
-
while !$stopped
|
46
|
-
msg_count += 1
|
47
|
-
obj = {:thread => thread_count, :message => msg_count}
|
48
|
-
producer_manager.send('address2', obj)
|
49
|
-
sleep 2
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
threads.each { |thread| thread.join }
|
@@ -1,49 +0,0 @@
|
|
1
|
-
#!/usr/bin/env jruby
|
2
|
-
#
|
3
|
-
# HornetQ Consumer:
|
4
|
-
# Write messages to the queue
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'yaml'
|
9
|
-
require 'hornetq'
|
10
|
-
require 'test_object'
|
11
|
-
|
12
|
-
$config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')
|
13
|
-
$client = $config['client']
|
14
|
-
factory = HornetQ::Client::Factory.new($client[:connector])
|
15
|
-
$consumer_manager = HornetQ::Client::ConsumerManager.new(factory, $client[:session], $client[:addresses])
|
16
|
-
|
17
|
-
['HUP', 'INT', 'TERM'].each do |signal_name|
|
18
|
-
Signal.trap(signal_name) do
|
19
|
-
puts "caught #{signal_name}"
|
20
|
-
consumer_manager.close
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
$threads = []
|
25
|
-
def create_workers(address, queue, count, sleep_time)
|
26
|
-
address_config = $client[:addresses][address]
|
27
|
-
queue_config = address_config[:queues][queue]
|
28
|
-
(1..count).each do |i|
|
29
|
-
$threads << Thread.new(i) do |thread_count|
|
30
|
-
prefix = "#{address}-#{queue}-#{thread_count}"
|
31
|
-
begin
|
32
|
-
$consumer_manager.each(address,queue) do |obj|
|
33
|
-
puts "#{prefix} read #{obj.inspect}"
|
34
|
-
sleep sleep_time
|
35
|
-
end
|
36
|
-
puts "#{prefix} end of thread"
|
37
|
-
rescue Exception => e
|
38
|
-
puts "#{prefix} Exception: #{e.message}\n#{e.backtrace.join("\n")}"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
create_workers('address1', 'queue1_1', 5, 1)
|
45
|
-
create_workers('address1', 'queue1_2', 5, 2)
|
46
|
-
create_workers('address2', 'queue2_1', 5, 2)
|
47
|
-
create_workers('address2', 'queue2_2', 5, 1)
|
48
|
-
|
49
|
-
$threads.each { |thread| thread.join }
|
Binary file
|
Binary file
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module HornetQ::Server
|
2
|
-
|
3
|
-
class Factory
|
4
|
-
def self.create_server(parms={})
|
5
|
-
HornetQ::Server.load_requirements
|
6
|
-
|
7
|
-
if parms.kind_of?(String)
|
8
|
-
uri = HornetQ::URI.new(parms)
|
9
|
-
parms = uri.params
|
10
|
-
else
|
11
|
-
raise "Missing :uri param in HornetQ::Server.create_server" unless parms[:uri]
|
12
|
-
uri = HornetQ::URI.new(parms.delete(:uri))
|
13
|
-
# parms override uri params
|
14
|
-
parms = uri.params.merge(parms)
|
15
|
-
end
|
16
|
-
config = Java::org.hornetq.core.config.impl.ConfigurationImpl.new
|
17
|
-
data_directory = parms.delete(:data_directory) || HornetQ::DEFAULT_DATA_DIRECTORY
|
18
|
-
config.paging_directory = "#{data_directory}/paging"
|
19
|
-
config.bindings_directory = "#{data_directory}/bindings"
|
20
|
-
config.journal_directory = "#{data_directory}/journal"
|
21
|
-
config.large_messages_directory = "#{data_directory}/large-messages"
|
22
|
-
|
23
|
-
if uri.host == 'invm'
|
24
|
-
acceptor = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::INVM_ACCEPTOR_CLASS_NAME)
|
25
|
-
config.persistence_enabled = false
|
26
|
-
config.security_enabled = false
|
27
|
-
else
|
28
|
-
acceptor = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_ACCEPTOR_CLASS_NAME, {'host' => uri.host, 'port' => uri.port })
|
29
|
-
connector = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_CONNECTOR_CLASS_NAME, {'host' => uri.host, 'port' => uri.port })
|
30
|
-
connector_conf_map = java.util.HashMap.new
|
31
|
-
connector_conf_map.put('netty-connector', connector)
|
32
|
-
config.connector_configurations = connector_conf_map
|
33
|
-
end
|
34
|
-
acceptor_conf_set = java.util.HashSet.new
|
35
|
-
acceptor_conf_set.add(acceptor)
|
36
|
-
config.acceptor_configurations = acceptor_conf_set
|
37
|
-
|
38
|
-
if Java::org.hornetq.core.journal.impl.AIOSequentialFileFactory.isSupported
|
39
|
-
config.journal_type = Java::org.hornetq.core.server.JournalType::ASYNCIO
|
40
|
-
else
|
41
|
-
puts("AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal");
|
42
|
-
config.journal_type = Java::org.hornetq.core.server.JournalType::NIO
|
43
|
-
end
|
44
|
-
|
45
|
-
if parms[:backup]
|
46
|
-
puts "backup"
|
47
|
-
config.backup = true
|
48
|
-
config.shared_store = false
|
49
|
-
elsif uri.backup_host
|
50
|
-
puts "live"
|
51
|
-
#backup_params.put('reconnectAttempts', -1)
|
52
|
-
backup_connector = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_CONNECTOR_CLASS_NAME, {'host' => uri.backup_host, 'port' => uri.backup_port })
|
53
|
-
connector_conf_map.put('backup-connector', backup_connector)
|
54
|
-
config.backup_connector_name = 'backup-connector'
|
55
|
-
elsif uri.host == 'invm'
|
56
|
-
puts 'invm'
|
57
|
-
else
|
58
|
-
puts 'standalone'
|
59
|
-
end
|
60
|
-
|
61
|
-
parms.each_pair do |key, val|
|
62
|
-
method = key.to_s+'='
|
63
|
-
if config.respond_to? method
|
64
|
-
config.send method, val
|
65
|
-
#puts "Debug: #{key} = #{config.send key}" if config.respond_to? key.to_sym
|
66
|
-
else
|
67
|
-
puts "Warning: Option:#{key} class=#{key.class} with value:#{val} is invalid and being ignored"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
return Java::org.hornetq.core.server.HornetQServers.newHornetQServer(config)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Start a new server instance and stop it once the supplied block completes
|
75
|
-
def self.start(params={}, &block)
|
76
|
-
server = nil
|
77
|
-
begin
|
78
|
-
server = self.create_server(params)
|
79
|
-
server.start
|
80
|
-
block.call(server)
|
81
|
-
ensure
|
82
|
-
server.stop if server
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|