Class: TorqueBox::Messaging::Connection
- Inherits:
-
Object
- Object
- TorqueBox::Messaging::Connection
- Defined in:
- lib/torquebox/messaging/connection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#jms_connection ⇒ Object
Returns the value of attribute jms_connection.
Instance Method Summary collapse
- #client_id ⇒ Object
- #client_id=(client_id) ⇒ Object
- #close ⇒ Object
- #create_session ⇒ Object
- #deactivate ⇒ Object
-
#initialize(jms_connection, connection_factory) ⇒ Connection
constructor
A new instance of Connection.
- #start ⇒ Object
- #transaction ⇒ Object
- #with_session(&block) ⇒ Object
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_connection ⇒ Object
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_id ⇒ Object
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 |
#close ⇒ Object
37 38 39 |
# File 'lib/torquebox/messaging/connection.rb', line 37 def close jms_connection.close end |
#create_session ⇒ Object
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 |
#deactivate ⇒ Object
67 68 69 |
# File 'lib/torquebox/messaging/connection.rb', line 67 def deactivate @connection_factory.deactivate end |
#start ⇒ Object
33 34 35 |
# File 'lib/torquebox/messaging/connection.rb', line 33 def start jms_connection.start end |
#transaction ⇒ Object
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 |