Skip to content

Commit 528203b

Browse files
committed
do not allow change consumer tag after consumer init
1 parent 0b751a8 commit 528203b

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎pkg/amqp-ext/AmqpConsumer.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Interop\Amqp\AmqpMessage as InteropAmqpMessage;
77
use Interop\Amqp\AmqpQueue;
88
use Interop\Amqp\Impl\AmqpMessage;
9+
use Interop\Queue\Exception;
910
use Interop\Queue\InvalidMessageException;
1011
use Interop\Queue\PsrMessage;
1112

@@ -73,6 +74,10 @@ public function __construct(AmqpContext $context, AmqpQueue $queue, Buffer $buff
7374
*/
7475
public function setConsumerTag($consumerTag)
7576
{
77+
if ($this->isInit) {
78+
throw new Exception('Consumer tag is not mutable after it has been subscribed to broker');
79+
}
80+
7681
$this->consumerTag = $consumerTag;
7782
}
7883

‎pkg/amqp-lib/AmqpConsumer.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public function __construct(AMQPChannel $channel, InteropAmqpQueue $queue, Buffe
7373
*/
7474
public function setConsumerTag($consumerTag)
7575
{
76+
if ($this->isInit) {
77+
throw new Exception('Consumer tag is not mutable after it has been subscribed to broker');
78+
}
79+
7680
$this->consumerTag = $consumerTag;
7781
}
7882

0 commit comments

Comments
 (0)