/** * {@inheritdoc} */ public function call(Identity $identity, Request $request) { $url = Url::parse($identity->getUrl(['amqps', 'amqp'])); $reply = $this->invoker->call($this->createRequest($request), $url->getQueryParameter('exchange', $this->exchange), $request->getMethod()); return new 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 Delivery($this->channel, 'consumer', 1, false, 'inbox', 'topic', '{"result": 63}', ['headers' => ['x-error' => 'foo', 'x-error-code' => 129]])); $this->driver->call($this->createIdentity(), $this->createRequest())->resolve(); }
public function testCallReplyResolving() { $message = $this->createMessage(); $this->channel->expects($this->once())->method('publish'); $this->invoker->call($message, '', '')->resolve(10); }
/** * {@inheritdoc} */ public function __destruct() { $this->invoker->dequeue($this); }