public function map(Envelope $envelope)
 {
     /* @var \Bernard\Message\DefaultMessage $message */
     $message = $envelope->getMessage();
     $serviceId = sprintf('simple_bus.bernard_bundle_bridge.%s_consumer', $message->get('type'));
     return $this->container->get($serviceId);
 }
 /**
  * {@inheritdoc}
  */
 public function map(Envelope $envelope)
 {
     if (!$this->consumerPluginManager->has($envelope->getName())) {
         throw new ReceiverNotFoundException(sprintf('Could not find the received for %s ', $envelope->getName()));
     }
     return $this->consumerPluginManager->get($envelope->getName());
 }
 /**
  * Returns the right Receiver (callable) based on the Envelope.
  *
  * @param  Envelope $envelope
  * @throws \InvalidArgumentException
  * @return array
  */
 public function map(Envelope $envelope)
 {
     $message = $envelope->getMessage();
     if (!$message instanceof BernardMessage) {
         throw new \InvalidArgumentException(sprintf("Routing the message %s failed due to wrong message type", $envelope->getName()));
     }
     return array($this, "routeMessage");
 }
Пример #4
0
 /**
  * {@inheritDoc}
  */
 public function map(Envelope $envelope)
 {
     $receiver = $this->get($envelope->getName());
     if (false == $receiver) {
         throw new ReceiverNotFoundException();
     }
     if (is_callable($receiver)) {
         return $receiver;
     }
     return array($receiver, lcfirst($envelope->getName()));
 }
 /**
  * @param  Envelope $envelope
  * @throws InvalidArgumentException
  * @return string
  */
 public function serialize(Envelope $envelope)
 {
     $message = $envelope->getMessage();
     if (!$message instanceof BernardMessage) {
         throw new InvalidArgumentException(sprintf("Serialize message %s failed due to wrong message type", $message->getName()));
     }
     $messageData = $this->messageConverter->convertToArray($message->getProophMessage());
     MessageDataAssertion::assert($messageData);
     $messageData['created_at'] = $message->getProophMessage()->createdAt()->format('Y-m-d\\TH:i:s.u');
     return json_encode(['message' => $messageData, 'timestamp' => $envelope->getTimestamp()]);
 }
Пример #6
0
 /**
  * @param Envelope $envelope
  */
 protected function verifyEnvelope(Envelope $envelope)
 {
     $queue = $envelope->getName();
     if (isset($this->queues[$queue])) {
         return;
     }
     throw new \DomainException('Unrecognized queue specified: ' . $queue);
 }
 /**
  * @param  Envelope  $envelope
  * @param  Exception $exception
  */
 protected function format(Envelope $envelope, Exception $exception)
 {
     $replacements = ['{class}' => get_class($exception), '{message}' => $exception->getMessage(), '{envelope}' => $envelope->getName()];
     return strtr('[bernard] caught exception {class}::{message} while processing {envelope}.', $replacements);
 }