14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ruote-nats/participant.rb', line 14
def consume(workitem)
queue_name = workitem.lookup('params.queue') || 'remote.command'
message = MessagePack.pack(workitem.to_h)
sid = NATS.request(queue_name, message) do |reply|
RuoteNATS.logger.info do
executor = workitem.lookup('params.executor') || 'RuoteNATS::ShellExecutor'
"(#{workitem.sid}) request: #{executor} (#{workitem.lookup('params')})"
end
end
timeout = (workitem.lookup('params.timeout') || DEFALUT_TIMEOUT).to_i
NATS.timeout(sid, timeout) do
handle_error(workitem)
end
rescue
RuoteNATS.logger.error($!.message)
raise $!
end
|