Class: Istox::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/istox/helpers/publisher.rb

Class Method Summary collapse

Class Method Details

.initialize!(amqp_config_path) ⇒ Object



5
6
7
# File 'lib/istox/helpers/publisher.rb', line 5

def initialize!(amqp_config_path)
  @@amqp_config_path = amqp_config_path
end

.publish(exchange, routing_key, message) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/istox/helpers/publisher.rb', line 9

def publish(exchange, routing_key, message)
  Rails.logger.info 'Before publish retrieve data..'
  durable = data.fetch('publish')[exchange]['durable']
  Rails.logger.info "Publishing message: #{message} with exchange: #{exchange} routing key: #{routing_key}"
  enqueue do
    $channel
      .direct(exchange, durable: durable)
      .publish(message.to_json, routing_key: routing_key, durable: durable)
  end
end