class EventHub::ActorPublisher
Heartbeat class
Public Class Methods
new()
click to toggle source
# File lib/eventhub/actor_publisher.rb, line 9 def initialize EventHub.logger.info("Publisher is starting...") @connection = nil end
Public Instance Methods
cleanup()
click to toggle source
# File lib/eventhub/actor_publisher.rb, line 41 def cleanup EventHub.logger.info("Publisher is cleaning up...") @connection&.close end
publish(args = {})
click to toggle source
# File lib/eventhub/actor_publisher.rb, line 14 def publish(args = {}) # keep connection once established unless @connection @connection = create_bunny_connection @connection.start end message = args[:message] return if message.nil? exchange_name = args[:exchange_name] || EH_X_INBOUND channel = @connection.create_channel channel.confirm_select exchange = channel.direct(exchange_name, durable: true) exchange.publish(message, persistent: true) success = channel.wait_for_confirms unless success raise "Published message from Listener actor "\ "has not been confirmed by the server" end ensure channel&.close end