java_import org.zeromq.ZMQ require 'zmachine' require 'zoomq/server/connection' module ZooMQ class Server class Worker attr_reader :server def initialize(server) @server = server end def run ZMachine.run { initialize_socket } end def initialize_socket $log.info("zoomq:server:worker", bind: "tcp://*:*") ZMachine.start_server("tcp://*:*", ZMQ::ROUTER, Connection) do |handler| identity = "#{@server.fqdn}:#{handler.channel.port}" $log.info("zoomq:server:worker", announce: identity) Thread.current.name = "ZMQ::Server::Worker (#{identity})" handler.channel.identity = identity handler.server = @server @server.announce(identity) end end end end end