/**
  * Publish the given Message by serializing it and handing it over to a RabbitMQ producer
  *
  * @{inheritdoc}
  */
 public function publish($message)
 {
     $serializedMessage = $this->serializer->wrapAndSerialize($message);
     $routingKey = $this->routingKeyResolver->resolveRoutingKeyFor($message);
     $additionalProperties = $this->additionalPropertiesResolver->resolveAdditionalPropertiesFor($message);
     $this->producer->publish($serializedMessage, $routingKey, $additionalProperties);
 }
 /**
  * @param App\CoreBundle\Event\BuildFinishedEvent
  */
 public function onBuildKilled(BuildKilledEvent $event)
 {
     $build = $event->getBuild();
     /** @todo write a producer that accepts Message objects */
     $this->logger->info('sending build.killed message', ['build' => $build->getId()]);
     $message = $this->factory->createBuildKilled($build);
     $this->producer->publish((string) $message);
 }
Пример #3
0
 public function parse($sourceType, $sourceUrl)
 {
     $this->producer->publish('Hello world');
     //        switch ($sourceType) {
     //            case self::PARSE_TYPE_CATALOG:
     //                $this
     //        }
 }
Пример #4
0
 public function generateInvoice(Order $order)
 {
     $document = $this->createDocumentFromOrder($order);
     $this->eventDispatcher->dispatch(DocumentEvent::INVOICE_GENERATE_START, new DocumentEvent($document));
     $this->documentManager->persist($document);
     $this->documentManager->flush();
     $this->documentProducer->publish($document->getId(), 'document.invoice');
 }
Пример #5
0
 /**
  * @param Campaign $campaign
  * @param          $event
  */
 public function preFlush(Campaign $campaign, $event)
 {
     if ($campaign->getHashId() && $campaign->getStatus() !== $campaign->getOldStatus()) {
         if ($campaign->isNew() && $campaign->getStatus() == Campaign::STATUS_ON) {
             //                $campaign->setIsNew(false);
             $this->rabbitProducer->publish($campaign->getId());
         }
     }
 }
Пример #6
0
 public function publish($msgBody, $routingKey = '', $additionalProperties = array())
 {
     try {
         parent::publish($msgBody, $routingKey, $additionalProperties);
     } catch (\Exception $e) {
         if (isset($this->logger)) {
             $this->logger->error("Can't publish message. Error is " . $e->getMessage());
         }
     }
 }
Пример #7
0
 /**
  * @param Bundle $bundle
  *
  * @return boolean
  */
 public function removeRepo(Bundle $bundle)
 {
     if ($this->bundleUpdateProducer) {
         // Create a Message object
         $message = array('bundle_id' => $bundle->getId(), 'action' => 'remove');
         // RabbitMQ, publish my message!
         $this->bundleUpdateProducer->publish(json_encode($message));
         return true;
     }
     return false;
 }
Пример #8
0
 /**
  * {@inheritDoc}
  */
 public function execute(AMQPMessage $msg)
 {
     if ($this->logger) {
         $this->logger->info('[GithubHookConsumer] Received a github post push hook');
     }
     if (null === ($message = json_decode($msg->body))) {
         if ($this->logger) {
             $this->logger->err('[GithubHookConsumer] Unable to decode payload');
         }
         return;
     }
     $payload = $message->payload;
     $bundle = $this->manager->getRepository('KnpBundlesBundle:Bundle')->findOneBy(array('name' => $payload->repository->name, 'ownerName' => $payload->repository->owner->name));
     if (!$bundle) {
         if ($this->logger) {
             $this->logger->warn(sprintf('[GithubHookConsumer] unknown bundle %s/%s', $payload->repository->name, $payload->repository->owner->name));
         }
         return;
     }
     $this->producer->publish(serialize(array('bundle_id' => $bundle->getId())));
 }
 /**
  * @param JobCalendarDeletedEvent $event
  */
 public function deleted(JobCalendarDeletedEvent $event)
 {
     $entity = $event->getEntity();
     foreach ($entity->getCalendar()->getGoogleConnections() as $connection) {
         $googleLink = $this->getGoogleLink($connection, $entity);
         if (null === $googleLink) {
             continue;
         }
         $message = new GoogleCalendarEvent();
         $message->setConnection($connection)->setLinkId($googleLink->getId());
         $this->googleDeleteProducer->publish($this->serializer->serialize($message, 'json'));
     }
 }
 public function delayedPublish($delay, $msgBody, $routingKey = '', $additionalProperties = array())
 {
     if (!is_integer($delay) || $delay < 0) {
         throw new \UnexpectedValueException('Publish delay should be a positive integer.');
     }
     # expire the queue a little bit after the delay, but minimum 1 second
     $expiration = 1000 + floor(1.1 * $delay);
     $name = sprintf('%s-exchange', $this->prefix);
     $id = sprintf('%s-waiting-queue-%s-%d', $this->prefix, $routingKey, $delay);
     $producer = new Producer($this->connection);
     $producer->setExchangeOptions(array('name' => $name, 'type' => 'direct'));
     $producer->setQueueOptions(array('name' => $id, 'routing_keys' => array($id), 'arguments' => array('x-message-ttl' => array('I', $delay), 'x-dead-letter-exchange' => array('S', $this->destination_exchange), 'x-dead-letter-routing-key' => array('S', $routingKey), 'x-expires' => array('I', $expiration))));
     $producer->setupFabric();
     $producer->publish($msgBody, $id, $additionalProperties);
 }
 /**
  * @param \stdClass $content
  */
 public function process($content)
 {
     $this->producer->publish(json_encode($content->payload));
 }
 /**
  * @param $data
  */
 public function process($data)
 {
     $this->producer->publish(json_encode($data));
 }