1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Marwan Al-Soltany <[email protected]> |
5
|
|
|
* @copyright Marwan Al-Soltany 2020 |
6
|
|
|
* For the full copyright and license information, please view |
7
|
|
|
* the LICENSE file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace MAKS\AmqpAgent\Worker; |
13
|
|
|
|
14
|
|
|
use PhpAmqpLib\Connection\AMQPStreamConnection; |
15
|
|
|
use PhpAmqpLib\Channel\AMQPChannel; |
16
|
|
|
use PhpAmqpLib\Message\AMQPMessage; |
17
|
|
|
use PhpAmqpLib\Wire\AMQPTable; |
18
|
|
|
use MAKS\AmqpAgent\Worker\Consumer; |
19
|
|
|
use MAKS\AmqpAgent\Worker\AbstractWorkerSingleton; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* A singleton version of the Consumer class. |
23
|
|
|
* Static and constant properties are accessed via object operator (`->` not `::`). |
24
|
|
|
* |
25
|
|
|
* Example: |
26
|
|
|
* ``` |
27
|
|
|
* $consumer = ConsumerSingleton::getInstance(); |
28
|
|
|
* ``` |
29
|
|
|
* |
30
|
|
|
* @since 1.0.0 |
31
|
|
|
* @api |
32
|
|
|
* @see \MAKS\AmqpAgent\Worker\Consumer for the full API. |
33
|
|
|
* @method self connect() |
34
|
|
|
* @method self disconnect() |
35
|
|
|
* @method self reconnect() |
36
|
|
|
* @method self queue(?array $parameters = null, ?AMQPChannel $_channel = null) |
37
|
|
|
* @method ?AMQPStreamConnection getConnection() |
38
|
|
|
* @method self setConnection(AMQPStreamConnection $connection) |
39
|
|
|
* @method ?AMQPChannel getChannel() |
40
|
|
|
* @method self setChannel(AMQPChannel $channel) |
41
|
|
|
* @method ?AMQPChannel getNewChannel(array $parameters = null, ?AMQPStreamConnection $_connection = null) |
42
|
|
|
* @method ?AMQPChannel getChannelById(array $parameters = null) |
43
|
|
|
* @method self qos(?array $parameters = null, ?AMQPChannel $_channel = null) |
44
|
|
|
* @method self consume($callback = null, ?array $variables = null, ?array $parameters = null, ?AMQPChannel $_channel = null) |
45
|
|
|
* @method bool isConsuming(?AMQPChannel $_channel = null) |
46
|
|
|
* @method self wait(?array $parameters = null, ?AMQPChannel $_channel = null) |
47
|
|
|
* @method self waitForAll(?array $parameters = null, ?AMQPStreamConnection $_connection = null) |
48
|
|
|
* @method self prepare() |
49
|
|
|
* @method void work($callback) |
50
|
|
|
* @method static AMQPTable arguments(array $array) |
51
|
|
|
* @method static bool shutdown(...$object) |
52
|
|
|
* @method static array makeCommand(string $name, string $value, $parameters = null, string $argument = 'params') |
53
|
|
|
* @method static bool isCommand($data) |
54
|
|
|
* @method static bool hasCommand(array $data, string $name = null, ?string $value = null) |
55
|
|
|
* @method static mixed getCommand(array $data, string $key = 'params', ?string $sub = null) |
56
|
|
|
* @method static void ack(AMQPMessage $_message, ?array $parameters = null) |
57
|
|
|
* @method static void nack(?AMQPChannel $_channel = null, AMQPMessage $_message, ?array $parameters = null) |
58
|
|
|
* @method static ?AMQPMessage get(AMQPChannel $_channel, ?array $parameters = null) |
59
|
|
|
* @method static mixed cancel(AMQPChannel $_channel, ?array $parameters = null) |
60
|
|
|
* @method static mixed recover(AMQPChannel $_channel, ?array $parameters = null) |
61
|
|
|
* @method static void reject(AMQPMessage $_message, ?array $parameters = null) |
62
|
|
|
*/ |
63
|
|
|
final class ConsumerSingleton extends AbstractWorkerSingleton |
64
|
|
|
{ |
65
|
|
|
/** |
66
|
|
|
* Use ConsumerSingleton::getInstance() instead. |
67
|
|
|
*/ |
68
|
1 |
|
public function __construct() |
69
|
|
|
{ |
70
|
1 |
|
$this->worker = new Consumer(); |
71
|
1 |
|
} |
72
|
|
|
} |
73
|
|
|
|