Sha256: 0004cd88e1b00729778b4c90e41899dd2dd10f3c66ef8da874caf5e59d03c536

Contents?: true

Size: 1.21 KB

Versions: 25

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Janus
    module Transactions
      # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
      #
      # # Manage a transaction
      #
      # Manage a transaction with message if contains a session identifier
      class Session < Transaction
        # Initialize a transaction with handle
        #
        # @param [Fixnum] session
        #   Use a session identifier for created message
        def initialize(exclusive, session)
          super(session)
          @exclusive = exclusive
        end

        # Opening a short transaction with rabbitmq and close when is ending
        #
        # @yield Send a message to Janus
        def connect
          rabbit.transaction_short do
            choose_queue
            yield
          end
        end

        # Publish a message to "standard" RabbitMQ queue.
        def publish_message(type, options = {})
          msg = Janus::Messages::Standard.new(type, opts.merge!(options))
          response = read_response(publisher.publish(msg))
          Janus::Responses::Standard.new(response)
        end

        private

        def opts
          { 'session_id' => session }
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-4.0.1 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.1.pre.1265973744 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.1.pre.1265506307 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.1.pre.1265140558 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.1001345090 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.1001181479 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.1001132533 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.1001107243 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.1001043172 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.949167646 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.946892338 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.946565704 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.939149205 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.939137013 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.939133437 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.939119110 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.939113634 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-4.0.0.pre.850041590 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-3.0.1 lib/rrj/janus/transactions/session.rb