Skip to content

Commit ed22633

Browse files
Fix message from batch consumer command (#42)
* Fixed message in BatchConsumerCommand and removed amount property
1 parent 9988837 commit ed22633

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

Command/BatchConsumerCommand.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ final class BatchConsumerCommand extends BaseRabbitMqCommand
1616
*/
1717
protected $consumer;
1818

19-
/** @var int */
20-
protected $amount;
21-
2219
public function stopConsumer()
2320
{
2421
if ($this->consumer instanceof BatchConsumer) {
@@ -78,15 +75,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
7875
define('AMQP_DEBUG', (bool) $input->getOption('debug'));
7976
}
8077

81-
$this->amount = (int) $input->getOption('batches');
78+
$batchAmountTarget = (int) $input->getOption('batches');
8279

83-
if (0 > $this->amount) {
84-
throw new \InvalidArgumentException("The -b option should be null or greater than 0");
80+
if (0 > $batchAmountTarget) {
81+
throw new \InvalidArgumentException("The -b option should be greater than 0");
8582
}
8683

8784
$this->initConsumer($input);
8885

89-
return $this->consumer->consume($this->amount);
86+
return $this->consumer->consume($batchAmountTarget);
9087
}
9188

9289
/**

RabbitMq/BatchConsumer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class BatchConsumer extends BaseAmqp implements DequeuerInterface
7676
protected $gracefulMaxExecutionDateTime;
7777

7878
/** @var int */
79-
private $target;
79+
private $batchAmountTarget;
8080

8181
/**
8282
* @param \DateTime|null $dateTime
@@ -106,9 +106,9 @@ public function setCallback($callback)
106106
return $this;
107107
}
108108

109-
public function consume(int $batchAmount = 0)
109+
public function consume(int $batchAmountTarget = 0)
110110
{
111-
$this->target = $batchAmount;
111+
$this->batchAmountTarget = $batchAmountTarget;
112112

113113
$this->setupConsumer();
114114

@@ -372,7 +372,7 @@ protected function maybeStopConsumer()
372372
pcntl_signal_dispatch();
373373
}
374374

375-
if ($this->forceStop || ($this->batchAmount == $this->target && $this->target > 0)) {
375+
if ($this->forceStop || ($this->batchAmount == $this->batchAmountTarget && $this->batchAmountTarget > 0)) {
376376
$this->stopConsuming();
377377
}
378378

0 commit comments

Comments
 (0)