Class: TorqueBox::Messaging::XaConnection

Inherits:
Connection
  • Object
show all
Defined in:
messaging/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

- (Object) close



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

def close
  super if @complete
end

- (Object) complete!



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

def complete!
  @complete = true
  close
end

- (Object) create_session(auto_enlist = true)



30
31
32
33
34
35
36
37
38
# File 'messaging/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

- (Object) session_transaction



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

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

- (Object) with_session(&block)



22
23
24
25
26
27
28
# File 'messaging/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