Class: TorqueBox::Messaging::Connection

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

Direct Known Subclasses

XaConnection

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Connection) initialize(jms_connection, connection_factory)

Returns a new instance of Connection



27
28
29
30
31
# File 'messaging/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

- (Object) :jms_connection

Returns the value of attribute :jms_connection



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

def :jms_connection
  @:jms_connection
end

Instance Method Details

- (Object) client_id



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

def client_id
  jms_connection.client_id
end

- (Object) client_id=(client_id)



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

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

- (Object) close



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

def close
  jms_connection.close
end

- (Object) create_session



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

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

- (Object) deactivate



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

def deactivate
  @connection_factory.deactivate
end

- (Object) start



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

def start
  jms_connection.start
end

- (Object) transaction



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

def transaction
  @tm && @tm.transaction
end

- (Object) with_session(&block)



49
50
51
52
53
54
55
56
57
# File 'messaging/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