summaryrefslogtreecommitdiff
path: root/app/services/publisher.rb
blob: 1c384dddc7f871acdba77d19071a887391e12bcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Publisher
  def self.publish(message)
    exchange = channel.topic("malwer")
    exchange.publish(message.to_json, routing_key: message.routing_key)
  end

  def self.channel
    @channel ||= connection.create_channel
  end

  def self.connection
    @connection ||= Bunny.new.tap do |connection|
      connection.start
    end
  end
end