Ejemplo n.º 1
0
 /**
  * @param RpcResponseMessage $response
  *
  * @return void
  */
 protected function sendResponse(RpcResponseMessage $response)
 {
     if ($this->currentRequest instanceof RpcRequestMessage) {
         $correlationId = $this->currentRequest->getCorrelationId();
         $response->setCorrelationId($correlationId);
         // Publish reponse message
         $this->connector->basicPublish($response, '', $this->currentRequest->getReplyTo());
     } else {
         $this->logger->warning('Imposible to send response! Invalid request.');
     }
 }
Ejemplo n.º 2
0
 public function test_getPayload_returnsPayloadInterface()
 {
     $message = new RpcRequestMessage('', [MessageInterface::PROPERTY_CONTENT_TYPE => MessageInterface::CONTENT_TYPE_PLAIN_TEXT]);
     $payload = $message->getPayload();
     $this->assertTrue($payload instanceof PayloadInterface);
 }
Ejemplo n.º 3
0
 /**
  * @param RpcRequestMessage $request
  * @param string $routingKey
  */
 protected final function sendRequest(RpcRequestMessage $request, $routingKey)
 {
     $this->correlarionId = $request->getCorrelationId();
     // Publish request message
     $this->connector->basicPublish($request, $this->exchange, $routingKey);
     // Wait for response
     $this->logger->debug('Waiting for response...', ['body' => $request->getBody(), 'properties' => $request->getProperties()]);
     $this->connector->basicConsume($this->responsesQueue, $this->getCallback());
     while (!$this->rpcResponse) {
         $this->connector->wait($this->getTimeOut());
     }
 }