Class: RuoteNATS::CommandReceiver
- Inherits:
-
Object
- Object
- RuoteNATS::CommandReceiver
- Defined in:
- lib/ruote-nats/command_receiver.rb
Instance Method Summary collapse
-
#start(queue_name = 'remote.command') ⇒ Object
Starts to subscribe command queue.
Instance Method Details
#start(queue_name = 'remote.command') ⇒ Object
Starts to subscribe command queue.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruote-nats/command_receiver.rb', line 7 def start(queue_name = 'remote.command') NATS.subscribe(queue_name, queue: queue_name, max: 1) do |, reply| NATS.publish(reply, 'ACCEPT') do unpacked = MessagePack.unpack() workitem = Ruote::Workitem.new(unpacked) RuoteNATS.logger.info do "(#{workitem.sid}) receive command: #{lookup_executor(workitem)} (#{workitem.lookup('params')})" end dispatch(workitem) publish_reply(workitem) end end end |