jruby-hornetq 0.2.5.alpha → 0.3.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -15,7 +15,7 @@ module HornetQ::Client
|
|
15
15
|
# end
|
16
16
|
#
|
17
17
|
# Parameters:
|
18
|
-
# see regular session parameters from: HornetQ::Client::
|
18
|
+
# see regular session parameters from: HornetQ::Client::Connection::create_session
|
19
19
|
#
|
20
20
|
# Additional parameters for controlling the session pool itself
|
21
21
|
# :pool_name Name of the pool as it shows up in the logger.
|
@@ -30,12 +30,12 @@ module HornetQ::Client
|
|
30
30
|
# For example: Rails.logger
|
31
31
|
# Default: None.
|
32
32
|
# Example:
|
33
|
-
# session_pool =
|
33
|
+
# session_pool = connection.create_session_pool(config)
|
34
34
|
# session_pool.session do |session|
|
35
35
|
# ....
|
36
36
|
# end
|
37
37
|
class SessionPool
|
38
|
-
def initialize(
|
38
|
+
def initialize(connection, params={})
|
39
39
|
# Save Session params since it will be used every time a new session is
|
40
40
|
# created in the pool
|
41
41
|
session_params = params.nil? ? {} : params.dup
|
@@ -46,7 +46,7 @@ module HornetQ::Client
|
|
46
46
|
:pool_size => session_params[:pool_size] || 10,
|
47
47
|
:warn_timeout => session_params[:pool_warn_timeout] || 5,
|
48
48
|
:logger => session_params[:pool_logger]) do
|
49
|
-
s =
|
49
|
+
s = connection.create_session(session_params)
|
50
50
|
# Start the session since it will be used immediately upon creation
|
51
51
|
s.start
|
52
52
|
s
|
@@ -4,9 +4,9 @@ module HornetQ
|
|
4
4
|
#
|
5
5
|
private
|
6
6
|
|
7
|
-
# HornetQ requires a
|
7
|
+
# HornetQ requires a connection from which it can create a logger per thread and/or class
|
8
8
|
class LogDelegateFactory
|
9
|
-
include
|
9
|
+
include Java::org.hornetq.spi.core.logging::LogDelegateFactory
|
10
10
|
|
11
11
|
def createDelegate(klass)
|
12
12
|
LogDelegate.new(klass.name)
|
@@ -24,23 +24,25 @@ module HornetQ
|
|
24
24
|
|
25
25
|
# DRY, generate a method for each required log level
|
26
26
|
['debug', 'error', 'fatal', 'info', 'trace', 'warn'].each do |level|
|
27
|
-
eval
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
eval <<LOG_LEVEL_METHOD
|
28
|
+
def #{level}(message, t=nil)
|
29
|
+
logger = HornetQ::logger
|
30
|
+
if logger.#{level}?
|
31
|
+
if t
|
32
|
+
logger.#{level}("[\#{@class_name}] \#{message}. \#{t.toString}")
|
33
|
+
logger.#{level}(t.stack_trace.toString)
|
34
|
+
else
|
35
|
+
logger.#{level}{"[\#{@class_name}] \#{message}"}
|
36
36
|
end
|
37
37
|
end
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
LOG_LEVEL_METHOD
|
40
|
+
def is#{level.capitalize}Enabled
|
41
|
+
HornetQ::logger.#{level}?
|
43
42
|
end
|
44
43
|
|
44
|
+
LOG_LEVEL_METHOD
|
45
|
+
end
|
46
|
+
|
45
47
|
end
|
46
48
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module HornetQ
|
3
3
|
# Returns the logger being used by both HornetQ and jruby-hornetq
|
4
4
|
def self.logger
|
5
|
-
@logger ||= (rails_logger || default_logger)
|
5
|
+
@logger ||= (self.rails_logger || self.default_logger)
|
6
6
|
end
|
7
7
|
|
8
8
|
# Replace the logger for both HornetQ and jruby-hornetq
|
@@ -10,10 +10,26 @@ module HornetQ
|
|
10
10
|
def self.logger=(logger)
|
11
11
|
@logger = logger
|
12
12
|
# Also replace the HornetQ logger
|
13
|
-
|
13
|
+
if @logger
|
14
|
+
Java::org.hornetq.core.logging::Logger.setDelegateFactory(HornetQ::LogDelegateFactory.new)
|
15
|
+
else
|
16
|
+
Java::org.hornetq.core.logging::Logger.reset
|
17
|
+
end
|
14
18
|
# TODO org.hornetq.core.logging.Logger.setDelegateFactory(org.hornetq.integration.logging.Log4jLogDelegateFactory.new)
|
15
19
|
end
|
16
20
|
|
21
|
+
# Use the ruby logger, but add needed trace level logging which will result
|
22
|
+
# in debug log entries
|
23
|
+
def self.ruby_logger(level=nil, target=STDOUT)
|
24
|
+
require 'logger'
|
25
|
+
|
26
|
+
l = ::Logger.new(target)
|
27
|
+
l.instance_eval "alias :trace :debug"
|
28
|
+
l.instance_eval "alias :trace? :debug?"
|
29
|
+
l.level = level || ::Logger::INFO
|
30
|
+
l
|
31
|
+
end
|
32
|
+
|
17
33
|
private
|
18
34
|
def self.rails_logger
|
19
35
|
(defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
|
@@ -22,11 +38,8 @@ module HornetQ
|
|
22
38
|
|
23
39
|
# By default we use the HornetQ Logger
|
24
40
|
def self.default_logger
|
41
|
+
# Needs an actual Java class, so give it: org.hornetq.api.core.client::HornetQClient
|
25
42
|
Java::org.hornetq.core.logging::Logger.getLogger(org.hornetq.api.core.client::HornetQClient)
|
26
|
-
# require 'logger'
|
27
|
-
# l = Logger.new(STDOUT)
|
28
|
-
# l.level = Logger::INFO
|
29
|
-
# l
|
30
43
|
end
|
31
|
-
|
44
|
+
|
32
45
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Extend HornetQ Logger class to respond to standard Rails/Ruby log methods
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# The following methods are already implemented by the java class
|
4
4
|
# initialize
|
5
5
|
# delegate
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# The following methods are being replaced so that they can support blocks
|
8
8
|
# trace
|
9
9
|
# debug
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# warn
|
12
12
|
# error
|
13
13
|
# fatal
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# The following methods are new
|
16
16
|
# trace?
|
17
17
|
# debug?
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# warn?
|
20
20
|
# error?
|
21
21
|
# fatal?
|
22
|
-
#
|
22
|
+
#
|
23
23
|
|
24
24
|
# This has to be a "mix-in" because the class can return instances of itself
|
25
25
|
class org.hornetq.core.logging::Logger
|
@@ -29,21 +29,23 @@ class org.hornetq.core.logging::Logger
|
|
29
29
|
def #{level}?
|
30
30
|
#{level}_enabled?
|
31
31
|
end
|
32
|
-
|
33
|
-
#
|
32
|
+
|
33
|
+
alias :java_#{level} :#{level}
|
34
|
+
|
35
|
+
# Support logging with block parameters that only get evaluated if the
|
34
36
|
# matching log level is enabled
|
35
37
|
def #{level}(message=nil, &block)
|
36
38
|
if #{level}?
|
37
39
|
if block
|
38
|
-
|
40
|
+
java_#{level}(block.call.to_s.to_java_string)
|
39
41
|
else
|
40
|
-
|
42
|
+
java_#{level}(message.to_s.to_java_string)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
LOG_LEVEL_METHOD
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
private
|
48
50
|
# Implement since not implemented by Logger
|
49
51
|
def error_enabled?
|
data/lib/hornetq/server.rb
CHANGED
@@ -4,9 +4,92 @@ module HornetQ
|
|
4
4
|
def self.load_requirements
|
5
5
|
HornetQ.require_jar 'hornetq-core'
|
6
6
|
HornetQ.require_jar 'netty'
|
7
|
-
require 'hornetq/org_hornetq_core_server_hornet_q_server'
|
7
|
+
require 'hornetq/server/org_hornetq_core_server_hornet_q_server'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create_server(params={})
|
11
|
+
self.load_requirements
|
12
|
+
|
13
|
+
if params.kind_of?(String)
|
14
|
+
uri = HornetQ::URI.new(params)
|
15
|
+
params = uri.params
|
16
|
+
else
|
17
|
+
raise "Missing :uri param in HornetQ::Server.create_server" unless params[:uri]
|
18
|
+
uri = HornetQ::URI.new(params.delete(:uri))
|
19
|
+
# params override uri params
|
20
|
+
params = uri.params.merge(params)
|
21
|
+
end
|
22
|
+
config = Java::org.hornetq.core.config.impl.ConfigurationImpl.new
|
23
|
+
data_directory = params.delete(:data_directory) || HornetQ::DEFAULT_DATA_DIRECTORY
|
24
|
+
config.paging_directory = "#{data_directory}/paging"
|
25
|
+
config.bindings_directory = "#{data_directory}/bindings"
|
26
|
+
config.journal_directory = "#{data_directory}/journal"
|
27
|
+
config.large_messages_directory = "#{data_directory}/large-messages"
|
28
|
+
|
29
|
+
if uri.host == 'invm'
|
30
|
+
acceptor = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::INVM_ACCEPTOR_CLASS_NAME)
|
31
|
+
config.persistence_enabled = false
|
32
|
+
config.security_enabled = false
|
33
|
+
else
|
34
|
+
acceptor = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_ACCEPTOR_CLASS_NAME, {'host' => uri.host, 'port' => uri.port })
|
35
|
+
connector = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_CONNECTOR_CLASS_NAME, {'host' => uri.host, 'port' => uri.port })
|
36
|
+
connector_conf_map = java.util.HashMap.new
|
37
|
+
connector_conf_map.put('netty-connector', connector)
|
38
|
+
config.connector_configurations = connector_conf_map
|
39
|
+
end
|
40
|
+
acceptor_conf_set = java.util.HashSet.new
|
41
|
+
acceptor_conf_set.add(acceptor)
|
42
|
+
config.acceptor_configurations = acceptor_conf_set
|
43
|
+
|
44
|
+
if Java::org.hornetq.core.journal.impl.AIOSequentialFileFactory.isSupported
|
45
|
+
config.journal_type = Java::org.hornetq.core.server.JournalType::ASYNCIO
|
46
|
+
else
|
47
|
+
require 'rbconfig'
|
48
|
+
if Config::CONFIG['target_os'] == 'linux'
|
49
|
+
HornetQ.logger("AIO wasn't located on this platform, it will fall back to using pure Java NIO. Install LibAIO to enable the AIO journal")
|
50
|
+
end
|
51
|
+
config.journal_type = Java::org.hornetq.core.server.JournalType::NIO
|
52
|
+
end
|
53
|
+
|
54
|
+
if params[:backup]
|
55
|
+
HornetQ.logger.info "Creating backup server"
|
56
|
+
config.backup = true
|
57
|
+
config.shared_store = false
|
58
|
+
elsif uri.backup_host
|
59
|
+
HornetQ.logger.info "Creating live server"
|
60
|
+
#backup_params.put('reconnectAttempts', -1)
|
61
|
+
backup_connector = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_CONNECTOR_CLASS_NAME, {'host' => uri.backup_host, 'port' => uri.backup_port })
|
62
|
+
connector_conf_map.put('backup-connector', backup_connector)
|
63
|
+
config.backup_connector_name = 'backup-connector'
|
64
|
+
elsif uri.host == 'invm'
|
65
|
+
HornetQ.logger.info 'Creating invm server'
|
66
|
+
else
|
67
|
+
HornetQ.logger.info 'Creating standalone server'
|
68
|
+
end
|
69
|
+
|
70
|
+
params.each_pair do |key, val|
|
71
|
+
method = key.to_s+'='
|
72
|
+
if config.respond_to? method
|
73
|
+
config.send method, val
|
74
|
+
#HornetQ.logger.debug "#{key} = #{config.send key}" if config.respond_to? key.to_sym
|
75
|
+
else
|
76
|
+
HornetQ.logger.warn "Option:#{key} class=#{key.class} with value:#{val} is invalid and being ignored"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
return Java::org.hornetq.core.server.HornetQServers.newHornetQServer(config)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Start a new server instance and stop it once the supplied block completes
|
84
|
+
def self.start(params={}, &block)
|
85
|
+
server = nil
|
86
|
+
begin
|
87
|
+
server = self.create_server(params)
|
88
|
+
server.start
|
89
|
+
block.call(server)
|
90
|
+
ensure
|
91
|
+
server.stop if server
|
92
|
+
end
|
8
93
|
end
|
9
94
|
end
|
10
95
|
end
|
11
|
-
|
12
|
-
require 'hornetq/server/factory'
|
@@ -5,7 +5,7 @@ module Java::org.hornetq.core.server::HornetQServer
|
|
5
5
|
def enable_shutdown_on_signal
|
6
6
|
['HUP', 'INT', 'TERM'].each do |signal_name|
|
7
7
|
Signal.trap(signal_name) do
|
8
|
-
|
8
|
+
HornetQ.logger.info "Caught #{signal_name}, stopping server"
|
9
9
|
stop
|
10
10
|
end
|
11
11
|
end
|
data/lib/hornetq/uri.rb
CHANGED
@@ -0,0 +1,158 @@
|
|
1
|
+
# Allow examples to be run in-place without requiring a gem install
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'shoulda'
|
7
|
+
require 'hornetq'
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
class ClientConnectionTest < Test::Unit::TestCase
|
11
|
+
context 'Client Connection' do
|
12
|
+
|
13
|
+
setup do
|
14
|
+
# This test requires a hornetq running local on the default port
|
15
|
+
@config = 'hornetq://localhost'
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'Create Connection to the Server' do
|
19
|
+
connection = HornetQ::Client::Connection.new(@config)
|
20
|
+
#HornetQ::logger.info connection.to_s
|
21
|
+
assert_not_nil connection
|
22
|
+
connection.close
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'Create and start Connection to the Server with block' do
|
26
|
+
HornetQ::Client::Connection.connection(@config) do |connection|
|
27
|
+
assert_not_nil connection
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should 'Create and start Connection to the Server with block and start one session' do
|
32
|
+
HornetQ::Client::Connection.session(@config) do |session|
|
33
|
+
assert_not_nil session
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'Start and stop connection' do
|
38
|
+
# Connection is started when created
|
39
|
+
connection = HornetQ::Client::Connection.new(@config)
|
40
|
+
assert_not_nil connection
|
41
|
+
assert_nil connection.close
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'Create a session from the connection' do
|
45
|
+
connection = HornetQ::Client::Connection.new(@config)
|
46
|
+
session = connection.create_session
|
47
|
+
assert_not_nil session
|
48
|
+
|
49
|
+
assert_nil session.start
|
50
|
+
|
51
|
+
assert_equal session.auto_commit_acks?, true
|
52
|
+
assert_equal session.auto_commit_sends?, true
|
53
|
+
assert_equal session.block_on_acknowledge?, false
|
54
|
+
assert_equal session.closed?, false
|
55
|
+
assert_equal session.rollback_only?, false
|
56
|
+
assert_equal session.xa?, false
|
57
|
+
|
58
|
+
assert_nil session.stop
|
59
|
+
|
60
|
+
# Close the session
|
61
|
+
assert_nil session.close
|
62
|
+
assert_equal session.closed?, true
|
63
|
+
|
64
|
+
assert_nil connection.close
|
65
|
+
end
|
66
|
+
|
67
|
+
should 'Create a session with a block' do
|
68
|
+
connection = HornetQ::Client::Connection.new(@config)
|
69
|
+
|
70
|
+
connection.session do |session|
|
71
|
+
assert_not_nil session
|
72
|
+
assert_equal session.auto_commit_acks?, true
|
73
|
+
assert_equal session.auto_commit_sends?, true
|
74
|
+
assert_equal session.block_on_acknowledge?, false
|
75
|
+
assert_equal session.rollback_only?, false
|
76
|
+
|
77
|
+
assert_equal session.xa?, false
|
78
|
+
assert_equal session.closed?, false
|
79
|
+
end
|
80
|
+
|
81
|
+
assert_nil connection.close
|
82
|
+
end
|
83
|
+
|
84
|
+
should 'create a session without a block and throw exception' do
|
85
|
+
connection = HornetQ::Client::Connection.new(@config)
|
86
|
+
|
87
|
+
assert_raise(RuntimeError) { connection.session }
|
88
|
+
|
89
|
+
assert_nil connection.close
|
90
|
+
end
|
91
|
+
|
92
|
+
# should 'Create a session from the connection with params' do
|
93
|
+
# connection = HornetQ::Client::Connection.new(@config)
|
94
|
+
#
|
95
|
+
# session_parms = {
|
96
|
+
# :transacted => true,
|
97
|
+
# :options => javax.jms.Session::AUTO_ACKNOWLEDGE
|
98
|
+
# }
|
99
|
+
#
|
100
|
+
# session = connection.create_session(session_parms)
|
101
|
+
# assert_not_nil session
|
102
|
+
# assert_equal session.transacted?, true
|
103
|
+
# # When session is transacted, options are ignore, so ack mode must be transacted
|
104
|
+
# assert_equal session.acknowledge_mode, javax.jms.Session::SESSION_TRANSACTED
|
105
|
+
# assert_nil session.close
|
106
|
+
#
|
107
|
+
# assert_nil connection.stop
|
108
|
+
# assert_nil connection.close
|
109
|
+
# end
|
110
|
+
#
|
111
|
+
# should 'Create a session from the connection with block and params' do
|
112
|
+
# HornetQ::Client::Connection.start_session(@config) do |connection|
|
113
|
+
#
|
114
|
+
# session_parms = {
|
115
|
+
# :transacted => true,
|
116
|
+
# :options => javax.jms.Session::CLIENT_ACKNOWLEDGE
|
117
|
+
# }
|
118
|
+
#
|
119
|
+
# connection.session(session_parms) do |session|
|
120
|
+
# assert_not_nil session
|
121
|
+
# assert_equal session.transacted?, true
|
122
|
+
# # When session is transacted, options are ignore, so ack mode must be transacted
|
123
|
+
# assert_equal session.acknowledge_mode, javax.jms.Session::SESSION_TRANSACTED
|
124
|
+
# end
|
125
|
+
# end
|
126
|
+
# end
|
127
|
+
#
|
128
|
+
# should 'Create a session from the connection with block and params opposite test' do
|
129
|
+
# HornetQ::Client::Connection.start_session(@config) do |connection|
|
130
|
+
#
|
131
|
+
# session_parms = {
|
132
|
+
# :transacted => false,
|
133
|
+
# :options => javax.jms.Session::AUTO_ACKNOWLEDGE
|
134
|
+
# }
|
135
|
+
#
|
136
|
+
# connection.session(session_parms) do |session|
|
137
|
+
# assert_not_nil session
|
138
|
+
# assert_equal session.transacted?, false
|
139
|
+
# assert_equal session.acknowledge_mode, javax.jms.Session::AUTO_ACKNOWLEDGE
|
140
|
+
# end
|
141
|
+
# end
|
142
|
+
# end
|
143
|
+
#
|
144
|
+
# context 'HornetQ::Client Connection additional capabilities' do
|
145
|
+
#
|
146
|
+
# should 'start an on_message handler' do
|
147
|
+
# HornetQ::Client::Connection.start_session(@config) do |connection|
|
148
|
+
# value = nil
|
149
|
+
# connection.on_message(:transacted => true, :queue_name => :temporary) do |message|
|
150
|
+
# value = "received"
|
151
|
+
# end
|
152
|
+
# end
|
153
|
+
# end
|
154
|
+
#
|
155
|
+
# end
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|