Class: Istox::Publisher
- Inherits:
-
Object
- Object
- Istox::Publisher
- Defined in:
- lib/istox/helpers/publisher.rb
Class Method Summary collapse
- .initialize!(amqp_config_path) ⇒ Object
- .publish(exchange, routing_key, message) ⇒ Object
- .publish_to_fanout(exchange, message) ⇒ Object
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, ) Rails.logger.info 'Before publish retrieve data..' durable = data.fetch('publish')[exchange]['durable'] Rails.logger.info "Publishing message: #{} with exchange: #{exchange} routing key: #{routing_key}" enqueue do $channel .direct(exchange, durable: durable) .publish(.to_json, routing_key: routing_key, durable: durable) end end |
.publish_to_fanout(exchange, message) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/istox/helpers/publisher.rb', line 20 def publish_to_fanout(exchange, ) Rails.logger.info 'Before publish retrieve data..' durable = data.fetch('publish')[exchange]['durable'] enqueue do $channel .fanout(exchange, durable: durable) .publish(.to_json, durable: durable) end end |