Sha256: ad5bf3124f2ccc5a9be76d8debf8ac102a4bd88a23b5404b0434cf3580c4df16

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

require 'jms'

# Handle Messaging and Queuing
module Qwirk
  module Adapter
    module JMS
      class Connection
        # Initialize the messaging system and connection pool for this VM
        def initialize(config)
          @config = config
          @connection = ::JMS::Connection.new(config)
          @session_pool = @connection.create_session_pool(@config)
          @connection.start
        end

        # Create a session targeted for a consumer (producers should use the session_pool)
        def create_session
          @connection.create_session(@config || {})
        end

        def session_pool
          @session_pool
        end

        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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qwirk_jms_adapter-0.2.1-java lib/qwirk/adapter/jms/connection.rb
qwirk_jms_adapter-0.2.0-java lib/qwirk/adapter/jms/connection.rb