Sha256: 377c450b2c15d8df1630821525b2e1690b1b037c865da4f3e197d536ec3489f7
Contents?: true
Size: 959 Bytes
Versions: 6
Compression:
Stored size: 959 Bytes
Contents
require 'bunny' module GeoConcerns class RabbitMessagingClient attr_reader :amqp_url def initialize(amqp_url) @amqp_url = amqp_url end def publish(message) exchange_type = JSON.parse(message)['exchange'] send(exchange_type) @exchange.publish(message, persistent: true) rescue Rails.logger.warn "Unable to publish message to #{amqp_url}" end def geoblacklight exchange_name = GeoConcerns::Messaging.config['events']['exchange']['geoblacklight'] @exchange ||= channel.fanout(exchange_name, durable: true) end def geoserver exchange_name = GeoConcerns::Messaging.config['events']['exchange']['geoserver'] @exchange ||= channel.fanout(exchange_name, durable: true) end private def bunny_client @bunny_client ||= Bunny.new(amqp_url).tap(&:start) end def channel @channel ||= bunny_client.create_channel end end end
Version data entries
6 entries across 6 versions & 1 rubygems