/**
  * Creates message queues for the defined queue bindings.
  *
  * @param QueueBindings $queueBindings
  */
 public function createIfNecessary(QueueBindings $queueBindings)
 {
     $addresses = array_merge($queueBindings->getReceivingAddresses(), $queueBindings->getSendingAddresses());
     foreach ($addresses as $address) {
         $this->routingTopology->setupForEndpointUse($this->brokerModel, $address);
     }
 }
Esempio n. 2
0
 /**
  * @param \AMQPEnvelope            $envelope
  * @param \AMQPQueue               $queue
  * @param PushPipe                 $pushPipe
  * @param string                   $errorQueue
  * @param ReceiveCancellationToken $cancellationToken
  * @param EndpointControlToken     $endpointControlToken
  *
  * @return bool
  */
 public function process(\AMQPEnvelope $envelope, \AMQPQueue $queue, PushPipe $pushPipe, $errorQueue, ReceiveCancellationToken $cancellationToken, EndpointControlToken $endpointControlToken)
 {
     try {
         $messageId = '';
         $headers = [];
         $pushMessage = false;
         try {
             $messageId = $this->messageConverter->retrieveMessageId($envelope);
             $headers = $this->messageConverter->retrieveHeaders($envelope);
             $pushMessage = true;
         } catch (\Exception $e) {
             $this->routingTopology->sendToQueue($this->brokerModel, $errorQueue, $envelope->getBody(), ['headers' => $envelope->getHeaders()]);
         }
         if ($pushMessage) {
             $pushPipe->push(new PushContext($messageId, $headers, $envelope->getBody() ?: '', $cancellationToken, $endpointControlToken));
         }
         if ($cancellationToken->isCancellationRequested()) {
             $queue->reject($envelope->getDeliveryTag(), AMQP_REQUEUE);
         } else {
             $queue->ack($envelope->getDeliveryTag());
         }
     } catch (CriticalErrorException $e) {
         // just ... die
         throw $e;
     } catch (\Exception $e) {
         $queue->reject($envelope->getDeliveryTag(), AMQP_REQUEUE);
     }
     if ($endpointControlToken->isShutdownRequested()) {
         return false;
     }
     return true;
 }
 /**
  * @param string $eventFqcn
  */
 public function unsubscribe($eventFqcn)
 {
     $this->routingTopology->tearDownSubscription($this->brokerModel, $eventFqcn, $this->localQueue);
 }
 /**
  * @param string $logicalAddress
  *
  * @return string
  */
 public function toTransportAddress($logicalAddress)
 {
     return RoutingTopology::getSafeName($logicalAddress);
 }
 /**
  * @param OutgoingPhysicalMessage $message
  * @param MulticastAddressTag     $addressTag
  */
 private function publishMessage(OutgoingPhysicalMessage $message, MulticastAddressTag $addressTag)
 {
     $attributes = $this->messageConverter->composeRabbitMqAttributes($message);
     $this->routingTopology->publish($this->brokerModel, $addressTag->getMessageType(), $message->getBody(), $attributes);
 }