Created
February 20, 2019 09:58
-
-
Save himangSharatun/b4e0a4c7839c2abdf6a7c17a97d1c2ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MassUpdatePublisher | |
QUEUE_NAME = 'user.mass_update_using_csv'.freeze | |
def initialize(mutations) | |
@mutations = mutations | |
end | |
def publish(options = {}) | |
channel = RabbitQueueService.connection.create_channel | |
exchange = channel.exchange( | |
ENV['BUNNY_AMQP_EXCHANGE'], | |
type: 'x-delayed-message', | |
durable: true, | |
arguments: { | |
'x-delayed-type': 'direct', | |
} | |
) | |
headers = { 'x-delay' => options[:delay_time].to_i * 1_000 } if options[:delay_time].present? | |
exchange.publish(payload.to_json, routing_key: QUEUE_NAME, headers: headers) | |
end | |
private | |
def payload | |
{ | |
mutations: @mutations | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment