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



67
68
69
# File 'lib/alondra/message_queue_client.rb', line 67

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

#push_socketObject



59
60
61
62
63
64
65
# File 'lib/alondra/message_queue_client.rb', line 59

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

#send_message(message) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/alondra/message_queue_client.rb', line 51

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