Esempio n. 1
0
 public function test_publish_with_valid_message_type()
 {
     $message = new Message();
     $eventDispatcher = $this->prophesize('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $eventDispatcher->dispatch(Argument::exact('swarrot.message_published'), Argument::exact(new MessagePublishedEvent('message_type', $message, 'connection', 'exchange', 'routing_key')))->shouldBeCalledTimes(1);
     $logger = $this->prophesize('Psr\\Log\\LoggerInterface');
     $logger->debug(Argument::exact('Publish message in {exchange}:{routing_key} (connection {connection})'), Argument::exact(array('exchange' => 'exchange', 'routing_key' => 'routing_key', 'connection' => 'connection')))->shouldBeCalledTimes(1);
     $messagePublisher = $this->prophesize('Swarrot\\Broker\\MessagePublisher\\MessagePublisherInterface');
     $messagePublisher->publish($message, 'routing_key')->shouldBeCalledTimes(1);
     $factory = $this->prophesize('Swarrot\\SwarrotBundle\\Broker\\FactoryInterface');
     $factory->getMessagePublisher('exchange', 'connection')->shouldBeCalledTimes(1)->willReturn($messagePublisher->reveal());
     $publisher = new Publisher($factory->reveal(), $eventDispatcher->reveal(), array('message_type' => array('connection' => 'connection', 'exchange' => 'exchange', 'routing_key' => 'routing_key')), $logger->reveal());
     $publisher->publish('message_type', $message);
 }
 public function send()
 {
     $data = $this->serializer->serialize($this->certification, 'json');
     $this->publisher->publish('compute_certification', new Message($data));
 }
 public function onManifestPush(ManifestEvent $event)
 {
     $manifest = $event->getManifest();
     $message = new Message($this->serializer->serialize($manifest, 'json', ['groups' => ['manifest_push']]));
     $this->publisher->publish('manifest_push', $message);
     $manifest->setUpdatedAt(new \DateTime());
     $this->om->flush();
 }