Sha256: d17e3097b0b6f5ac057180af14c07424e07b0e0717c4783eb9477cf13c46cea6

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

module Basquiat
  module Adapters
    class RabbitMq
      module Strategies
        class DelayedDeliveryWIP
          def initialize(channel, message)
            @channel = channel
            @message = message
          end

          # Criar um exchange
          # Criar o queue (ou redeclara-lo)
          # O queue tem que ter um dlx para o exchange padrĂ£o
          # Publicar a mensagem no exchange com um ttl igual ao anterior **2
          # dar um unack caso o tempo estoure o maximo.
          def message_handler
            delay    = message[:headers][0][:expiration]**2
            exchange = channel.topic('basquiat.dd')
            queue    = channel.queue('delay', ttl: delay * 2)
            queue.bind(exchange, 'original_queue.delay.message_name')
            exchange.publish('original_queue.delay.message_name', message, ttl: delay, dlx: default_exchange)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
basquiat-1.2.0 lib/basquiat/adapters/rabbitmq/requeue_strategies/delayed_delivery.rb