Class: SongkickQueue::Producer

Inherits:
Object
  • Object
show all
Defined in:
lib/songkick_queue/producer.rb

Instance Method Summary collapse

Constructor Details

#initializeProducer

Returns a new instance of Producer



3
4
5
# File 'lib/songkick_queue/producer.rb', line 3

def initialize
  @client = Client.new
end

Instance Method Details

#publish(queue_name, message) ⇒ Object

Serializes the given message and publishes it to the default RabbitMQ exchange

Parameters:

  • queue_name (String)

    to publish to

  • message (#to_json)

    to serialize and enqueue



12
13
14
15
16
17
18
# File 'lib/songkick_queue/producer.rb', line 12

def publish(queue_name, message)
  payload = JSON.generate(message)

  client
    .default_exchange
    .publish(payload, routing_key: String(queue_name))
end