Class: Alondra::SyncMessageQueueClient

Inherits:
MessageQueueClient show all
Defined in:
lib/alondra/message_queue_client.rb

Instance Method Summary collapse

Methods inherited from MessageQueueClient

async_instance, instance, push, sync_instance

Instance Method Details

#contextObject



71
72
73
# File 'lib/alondra/message_queue_client.rb', line 71

def context
  @context ||= ZMQ::Context.new(1)
end

#push_socketObject



63
64
65
66
67
68
69
# File 'lib/alondra/message_queue_client.rb', line 63

def push_socket
  @push_socket ||= begin
    socket = context.socket(ZMQ::PUSH)
    socket.connect(Alondra.config.queue_socket)
    socket
  end
end

#send_message(message) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/alondra/message_queue_client.rb', line 55

def send_message(message)
  begin
    push_socket.send_string(message.to_json)
  rescue Exception => ex
    Log.error "Exception while sending message to message queue: #{ex.message}"
  end
end