Class: Qwirk::Adapter::JMS::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/qwirk/adapter/jms/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Connection

Initialize the messaging system and connection pool for this VM



9
10
11
12
13
14
# File 'lib/qwirk/adapter/jms/connection.rb', line 9

def initialize(config)
  @config = config
  @connection = ::JMS::Connection.new(config)
  @session_pool = @connection.create_session_pool(@config)
  @connection.start
end

Instance Method Details

#closeObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/qwirk/adapter/jms/connection.rb', line 25

def close
  return if @closed
  Qwirk.logger.info "Closing JMS connection"
  @session_pool.close if @session_pool
  if @connection
    @connection.stop
    @connection.close
  end
  @closed = true
end

#create_sessionObject

Create a session targeted for a consumer (producers should use the session_pool)



17
18
19
# File 'lib/qwirk/adapter/jms/connection.rb', line 17

def create_session
  @connection.create_session(@config || {})
end

#session_poolObject



21
22
23
# File 'lib/qwirk/adapter/jms/connection.rb', line 21

def session_pool
  @session_pool
end