Method: ActiveMessaging::Adapters::Jms::Connection#initialize
- Defined in:
- lib/activemessaging/adapters/jms.rb
#initialize(cfg = {}) ⇒ Connection
Returns a new instance of Connection.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/activemessaging/adapters/jms.rb', line 23 def initialize cfg={} @url = cfg[:url] @login = cfg[:login] @passcode = cfg[:passcode] #initialize our connection factory if cfg.has_key? :connection_factory #this initialize is probably activemq specific. There might be a more generic #way of getting this without resorting to jndi lookup. eval " @connection_factory = Java::\#{cfg[:connection_factory]}.new(@login, @passcode, @url)\n end_eval\n elsif cfg.has_key? :jndi\n @connection_factory = javax.naming.InitialContext.new().lookup(cfg[:jndi])\n else\n raise \"Either jndi or connection_factory has to be set in the config.\"\n end\n raise \"Connection factory could not be initialized.\" if @connection_factory.nil?\n \n @connection = @connection_factory.create_connection()\n @session = @connection.createSession(false, 1)\n @destinations = []\n @producers = {}\n @consumers = {}\n @connection.start\nend\n" |