Class: TorqueBox::Messaging::ConnectionFactory
- Inherits:
-
Object
- Object
- TorqueBox::Messaging::ConnectionFactory
- Defined in:
- lib/torquebox/messaging/connection_factory.rb
Instance Attribute Summary collapse
-
#internal_connection_factory ⇒ Object
readonly
Returns the value of attribute internal_connection_factory.
Class Method Summary collapse
Instance Method Summary collapse
- #create_connection(options) ⇒ Object
- #create_connection_factory(host, port) ⇒ Object
-
#initialize(internal_connection_factory = nil) ⇒ ConnectionFactory
constructor
A new instance of ConnectionFactory.
- #to_s ⇒ Object
- #with_new_connection(options, &block) ⇒ Object
Constructor Details
#initialize(internal_connection_factory = nil) ⇒ ConnectionFactory
Returns a new instance of ConnectionFactory.
32 33 34 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 32 def initialize(internal_connection_factory = nil) @internal_connection_factory = internal_connection_factory end |
Instance Attribute Details
#internal_connection_factory ⇒ Object (readonly)
Returns the value of attribute internal_connection_factory.
25 26 27 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 25 def internal_connection_factory @internal_connection_factory end |
Class Method Details
.new(internal_connection_factory = nil) ⇒ Object
27 28 29 30 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 27 def self.new(internal_connection_factory = nil) return internal_connection_factory if internal_connection_factory.is_a?( ConnectionFactory ) super end |
Instance Method Details
#create_connection(options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 49 def create_connection() host = [:host] || "localhost" port = [:port] || 5445 username = [:username] password = [:password] if !@internal_connection_factory @internal_connection_factory = create_connection_factory( host, port ) end Connection.new( @internal_connection_factory.create_connection( username, password ) ) end |
#create_connection_factory(host, port) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 61 def create_connection_factory(host, port) connect_opts = { "host" => host, "port" => port } transport_config = org.hornetq.api.core.TransportConfiguration.new("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", connect_opts) org.hornetq.api.jms.HornetQJMSClient.createConnectionFactoryWithoutHA( org.hornetq.api.jms::JMSFactoryType::CF, transport_config ) end |
#to_s ⇒ Object
70 71 72 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 70 def to_s "[ConnectionFactory: internal_connection_factory=#{internal_connection_factory}]" end |
#with_new_connection(options, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/torquebox/messaging/connection_factory.rb', line 36 def with_new_connection(, &block) client_id = [:client_id] connection = create_connection( ) connection.client_id = client_id if client_id connection.start begin result = block.call( connection ) ensure connection.close end return result end |