summaryrefslogtreecommitdiff
path: root/app/services/publisher.rb
blob: 704f1e3d5bdef326a9ae3abc808bfd66b6ffe761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Publisher
  def self.publish(routing_key, message = {})
    exchange = channel.topic("malwer")
    exchange.publish(message.to_json, routing_key: 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