-
Notifications
You must be signed in to change notification settings - Fork 0
/
NullAsyncCallback.php
48 lines (42 loc) · 1.23 KB
/
NullAsyncCallback.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php declare(strict_types=1);
namespace RabbitMqBundle\Consumer\Callback;
use Exception;
use GuzzleHttp\Promise\Promise;
use GuzzleHttp\Promise\PromiseInterface;
use PhpAmqpLib\Message\AMQPMessage;
use RabbitMqBundle\Connection\Connection;
use RabbitMqBundle\Consumer\AsyncCallbackInterface;
use RabbitMqBundle\Utils\Message;
/**
* Class NullAsyncCallback
*
* @package RabbitMqBundle\Consumer\Callback
*/
final class NullAsyncCallback implements AsyncCallbackInterface
{
/**
* @param AMQPMessage $message
* @param Connection $connection
* @param int $channelId
*
* @return PromiseInterface
* @throws Exception
*/
public function processMessage(AMQPMessage $message, Connection $connection, int $channelId): PromiseInterface
{
$promise = new Promise(
static function () use (&$promise): void {
if ($promise) {
$promise->resolve('waited');
}
},
);
$promise
->then(
static function () use (&$message, $connection, $channelId): void {
Message::ack($message, $connection, $channelId);
}
);
return $promise;
}
}