public function send(ZmqMessage $message)
 {
     $found = false;
     $zmq = $this->container->getParameter('jdare_clank.zmq_configuration');
     if (!$zmq['enabled']) {
         throw new \Exception("ZMQ is not enabled. Add zmq:\nenabled: true\n to the configuration for clank. in config.yml");
     }
     foreach ($this->container->get("jdare_clank.clank_handler_topic")->getTopicServices() as $service) {
         if ($message->getName() == $service['name']) {
             $found = true;
         }
     }
     if (false === $found) {
         throw new \Exception("Could not find topic service with name {$message->getName()}. Name should be equal to the topic: - name in clank configuration (config.yml).");
     }
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:{$zmq['port']}");
     $socket->send(json_encode(array('name' => $message->getName(), 'data' => $message->getData())));
 }
 public function onZMQMessage(ZmqMessage $message)
 {
     $serviceMatch = $message->getName();
     $handler = null;
     // If the lookup topic object isn't set there is no one to publish to
     if (!array_key_exists($serviceMatch, $this->subscribedTopics)) {
         return;
     }
     $topic = $this->subscribedTopics[$serviceMatch];
     foreach ($this->getTopicServices() as $topicService) {
         if ($topicService['name'] === $serviceMatch) {
             $handler = $this->getContainer()->get($topicService['service']);
         }
     }
     if ($handler) {
         if ($handler instanceof ZMQMessageReciever) {
             call_user_func(array($handler, 'onZMQMessage'), $topic, $message->getData());
         }
     }
 }