lib/hornetq/client/connection.rb in jruby-hornetq-0.3.1 vs lib/hornetq/client/connection.rb in jruby-hornetq-0.3.2
- old
+ new
@@ -172,11 +172,12 @@
@connection = nil
@sessions = []
@consumers = []
# In-VM Transport has no fail-over or additional parameters
- if uri.host == 'invm'
+ @is_invm = uri.host == 'invm'
+ if @is_invm
transport = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::INVM_CONNECTOR_CLASS_NAME)
@connection = Java::org.hornetq.api.core.client.HornetQClient.create_client_session_factory(transport)
elsif params[:protocol]
# Auto-Discovery just has a host name and port
if params[:protocol] == 'discovery'
@@ -210,10 +211,15 @@
HornetQ.logger.warn "Warning: Option:#{key}, with value:#{val} is invalid and being ignored"
end
end
end
+ # Return true if this connection was configured in INVM transport protocol
+ def invm?
+ @is_invm
+ end
+
# Create a new HornetQ session
#
# Note: Remember to close the session once it is no longer used.
# Recommend using #session with a block over this method where possible
#
@@ -314,10 +320,11 @@
# * false: The caller is responsible for closing the session
# * Default: false
#
def create_session(params={})
raise "HornetQ::Client::Connection Already Closed" unless @connection
+ params ||= {}
session = @connection.create_session(
params[:username],
params[:password],
params[:xa] || false,
params[:auto_commit_sends].nil? ? true : params[:auto_commit_sends],
@@ -485,14 +492,14 @@
end
# Start all sessions managed by this connection
#
# Sessions created via #create_session are not managed unless
- # :auto_close => true was specified when the session was created
+ # :managed => true was specified when the session was created
#
# Session are Only managed when created through the following methods:
# Connection#on_message
- # Connection#create_session And :auto_close => true
+ # Connection#create_session And :managed => true
#
# This call does not do anything to sessions in a session pool
def start_managed_sessions
@sessions.each {|session| session.start}
end
\ No newline at end of file