/** * {@inheritdoc} */ public function call(LocationInterface $location, Request $request) { $reply = $this->invoker->call($this->createMessage($location, $request), $this->exchange, $request->getTopic()); return new Response\Promise(function ($timeout) use($reply) { return $this->createResponse($reply->resolve($timeout)); }, function () use($reply) { $this->invoker->dequeue($reply); }); }
/** * Driver should create response promise which will resolve AMQP reply and decode response. * This test ensures an exception is thrown when response contain x-error header. */ public function testCallErrorResponse() { $this->expectException(ReplyException::class); $this->expectExceptionMessage('foo'); $this->expectExceptionCode(129); $reply = $this->getMockBuilder(Invoker\Reply::class)->disableOriginalConstructor()->getMock(); $this->invoker->expects($this->once())->method('call')->willReturn($reply); $reply->expects($this->once())->method('resolve')->willReturn(new AMQPMessage('', ['application_headers' => new AMQPTable(['x-error' => 'foo', 'x-error-code' => 129])])); $this->driver->call(new Location('calc'), $this->createRequest())->resolve(); }
public function testCallReplyResolving() { $message = $this->createMessage(); $this->channel->expects($this->once())->method('basic_publish'); $this->invoker->call($message, '', '')->resolve(10); }
/** * {@inheritdoc} */ public function __destruct() { $this->invoker->dequeue($this); }