|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ccovey\RabbitMQ; |
|
4
|
|
|
|
|
5
|
|
|
use Ccovey\RabbitMQ\Consumer\Consumable; |
|
6
|
|
|
use Ccovey\RabbitMQ\Producer\Publishable; |
|
7
|
|
|
use PhpAmqpLib\Channel\AMQPChannel; |
|
8
|
|
|
|
|
9
|
|
|
class Channel implements ChannelInterface |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var AMQPChannel |
|
13
|
|
|
*/ |
|
14
|
|
|
private $channel; |
|
15
|
|
|
|
|
16
|
14 |
|
public function __construct(AMQPChannel $channel) |
|
17
|
|
|
{ |
|
18
|
14 |
|
$this->channel = $channel; |
|
19
|
14 |
|
} |
|
20
|
|
|
|
|
21
|
2 |
|
public function wait() |
|
22
|
|
|
{ |
|
23
|
2 |
|
return $this->channel->wait(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
1 |
|
public function acknowledge(string $deliveryTag, bool $multiple = false) |
|
27
|
|
|
{ |
|
28
|
1 |
|
return $this->channel->basic_ack($deliveryTag, $multiple); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
3 |
|
public function nack(string $deliveryTag, bool $multiple = false, bool $requeue = false) |
|
32
|
|
|
{ |
|
33
|
3 |
|
return $this->channel->basic_nack($deliveryTag, $multiple, $requeue); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
2 |
|
public function consume(Consumable $consumable) : ChannelInterface |
|
37
|
|
|
{ |
|
38
|
2 |
|
$this->channel->basic_consume( |
|
39
|
2 |
|
$consumable->getQueueName(), |
|
40
|
2 |
|
$consumable->getConsumerTag(), |
|
41
|
2 |
|
$consumable->isNoLocal(), |
|
42
|
2 |
|
$consumable->isNoAck(), |
|
43
|
2 |
|
$consumable->isExclusive(), |
|
44
|
2 |
|
$consumable->isNoWait(), |
|
45
|
2 |
|
$consumable->getCallback(), |
|
46
|
2 |
|
$consumable->getTicket(), |
|
47
|
2 |
|
$consumable->getArguments() |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
2 |
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
2 |
|
public function publish(Publishable $message) : ChannelInterface |
|
54
|
|
|
{ |
|
55
|
2 |
|
if ($message->isDelayed()) { |
|
56
|
|
|
$queue = new Queue($message->getQueueName(), $message->getDelayedExchanged()); |
|
57
|
|
|
$message->setExchange($message->getDelayedExchanged()); |
|
|
|
|
|
|
58
|
|
|
$this->bindQueue($queue); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
2 |
|
$this->channel->basic_publish( |
|
62
|
2 |
|
$message->getMessage(), |
|
63
|
2 |
|
$message->getExchange(), |
|
64
|
2 |
|
$message->getQueueName(), |
|
65
|
2 |
|
$message->isMandatory(), |
|
66
|
2 |
|
$message->isImmediate(), |
|
67
|
2 |
|
$message->getTicket() |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
2 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param $prefetchSize |
|
75
|
|
|
* @param int $prefetchCount |
|
76
|
|
|
* @param $aGlobal |
|
77
|
|
|
* |
|
78
|
|
|
* @return mixed |
|
79
|
|
|
*/ |
|
80
|
1 |
|
public function basicQos($prefetchSize = null, int $prefetchCount = 1, $aGlobal = null) |
|
81
|
|
|
{ |
|
82
|
1 |
|
$this->channel->basic_qos($prefetchSize, $prefetchCount, $aGlobal); |
|
83
|
|
|
|
|
84
|
1 |
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param Queue $queue |
|
89
|
|
|
* |
|
90
|
|
|
* @return ChannelInterface |
|
91
|
|
|
*/ |
|
92
|
2 |
View Code Duplication |
public function declareQueue(Queue $queue) : ChannelInterface |
|
|
|
|
|
|
93
|
|
|
{ |
|
94
|
2 |
|
$this->channel->queue_declare( |
|
95
|
2 |
|
$queue->getQueueName(), |
|
96
|
2 |
|
$queue->isPassive(), |
|
97
|
2 |
|
$queue->isDurable(), |
|
98
|
2 |
|
$queue->isExclusive(), |
|
99
|
2 |
|
$queue->isAutoDelete(), |
|
100
|
2 |
|
$queue->isNoWait(), |
|
101
|
2 |
|
$queue->getArguments(), |
|
|
|
|
|
|
102
|
2 |
|
$queue->getTicket() |
|
103
|
|
|
); |
|
104
|
|
|
|
|
105
|
2 |
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
2 |
|
public function bindQueue(Queue $queue) : ChannelInterface |
|
109
|
|
|
{ |
|
110
|
2 |
|
$this->channel->queue_bind( |
|
111
|
2 |
|
$queue->getQueueName(), |
|
112
|
2 |
|
$queue->getExchange(), |
|
113
|
2 |
|
$queue->getQueueName(), |
|
114
|
2 |
|
$queue->isNoWait(), |
|
115
|
2 |
|
$queue->getArguments(), |
|
|
|
|
|
|
116
|
2 |
|
$queue->getTicket() |
|
117
|
|
|
); |
|
118
|
|
|
|
|
119
|
2 |
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
2 |
View Code Duplication |
public function declareExchange(Exchange $exchange) : ChannelInterface |
|
|
|
|
|
|
123
|
|
|
{ |
|
124
|
2 |
|
$this->channel->exchange_declare( |
|
125
|
2 |
|
$exchange->getExchange(), |
|
126
|
2 |
|
$exchange->getType(), |
|
127
|
2 |
|
$exchange->isPassive(), |
|
128
|
2 |
|
$exchange->isDurable(), |
|
129
|
2 |
|
$exchange->isAutoDelete(), |
|
130
|
2 |
|
$exchange->isInternal(), |
|
131
|
2 |
|
$exchange->isNoWait(), |
|
132
|
2 |
|
$exchange->getArguments(), |
|
133
|
2 |
|
$exchange->getTicket() |
|
134
|
|
|
); |
|
135
|
|
|
|
|
136
|
2 |
|
return $this; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return array |
|
141
|
|
|
*/ |
|
142
|
2 |
|
public function getCallbacks() : array |
|
143
|
|
|
{ |
|
144
|
2 |
|
return $this->channel->callbacks; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function setCallbacks(array $callbacks = []) |
|
148
|
|
|
{ |
|
149
|
|
|
$this->channel->callbacks = $callbacks; |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.