Class: TorqueBox::Messaging::Connection

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

Direct Known Subclasses

XaConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jms_connection, connection_factory) ⇒ Connection

Returns a new instance of Connection.



27
28
29
30
31
# File 'lib/torquebox/messaging/connection.rb', line 27

def initialize(jms_connection, connection_factory)
  @jms_connection = jms_connection
  @connection_factory = connection_factory
  @tm = TorqueBox.fetch('transaction-manager')
end

Instance Attribute Details

#jms_connectionObject

Returns the value of attribute jms_connection.



25
26
27
# File 'lib/torquebox/messaging/connection.rb', line 25

def jms_connection
  @jms_connection
end

Instance Method Details

#client_idObject



41
42
43
# File 'lib/torquebox/messaging/connection.rb', line 41

def client_id
  jms_connection.client_id
end

#client_id=(client_id) ⇒ Object



45
46
47
# File 'lib/torquebox/messaging/connection.rb', line 45

def client_id=(client_id)
  jms_connection.client_id = client_id
end

#closeObject



37
38
39
# File 'lib/torquebox/messaging/connection.rb', line 37

def close
  jms_connection.close
end

#create_sessionObject



59
60
61
# File 'lib/torquebox/messaging/connection.rb', line 59

def create_session
  Session.new( jms_connection.create_session( false, Session::AUTO_ACK ) )
end

#deactivateObject



67
68
69
# File 'lib/torquebox/messaging/connection.rb', line 67

def deactivate
  @connection_factory.deactivate
end

#startObject



33
34
35
# File 'lib/torquebox/messaging/connection.rb', line 33

def start
  jms_connection.start
end

#transactionObject



63
64
65
# File 'lib/torquebox/messaging/connection.rb', line 63

def transaction
  @tm && @tm.transaction
end

#with_session(&block) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/torquebox/messaging/connection.rb', line 49

def with_session(&block)
  begin
    session = create_session
    result = block.call( session )
  ensure
    session.close
  end
  result
end