Class: TorqueBox::Messaging::XaConnection

Inherits:
Connection
  • Object
show all
Defined in:
lib/torquebox/messaging/xa_connection.rb

Instance Attribute Summary

Attributes inherited from Connection

#jms_connection

Instance Method Summary collapse

Methods inherited from Connection

#client_id, #client_id=, #deactivate, #initialize, #start, #transaction

Constructor Details

This class inherits a constructor from TorqueBox::Messaging::Connection

Instance Method Details

#closeObject



44
45
46
# File 'lib/torquebox/messaging/xa_connection.rb', line 44

def close
  super if @complete
end

#complete!Object



48
49
50
51
# File 'lib/torquebox/messaging/xa_connection.rb', line 48

def complete!
  @complete = true
  close
end

#create_session(auto_enlist = true) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/torquebox/messaging/xa_connection.rb', line 30

def create_session(auto_enlist = true)
  jms_session = jms_connection.create_xa_session
  session = XaSession.new( jms_session, transaction, self )
  if auto_enlist
    transaction.enlist_resource( jms_session.xa_resource )
    transaction.registerSynchronization( session )
  end
  session
end

#session_transactionObject



40
41
42
# File 'lib/torquebox/messaging/xa_connection.rb', line 40

def session_transaction
  @session.nil? ? nil : @session.transaction
end

#with_session(&block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/torquebox/messaging/xa_connection.rb', line 22

def with_session(&block)
  # Re-use a single XaSession per XaConnection
  # This session gets closed by the afterCompletion
  # callback on XaSession
  @session ||= create_session
  block.call( @session )
end