Skip to content

Commit 938d944

Browse files
author
Bogdan Rancichi
committed
[change-req] implemented change requests
1 parent 599b675 commit 938d944

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

Command/BatchConsumerCommand.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
use Symfony\Component\Console\Input\InputOption;
1010
use Symfony\Component\Console\Output\OutputInterface;
1111

12-
class BatchConsumerCommand extends BaseRabbitMqCommand
12+
final class BatchConsumerCommand extends BaseRabbitMqCommand
1313
{
1414
/**
1515
* @var BatchConsumer
1616
*/
1717
protected $consumer;
1818

19-
/**
20-
* @return void
21-
*/
2219
public function stopConsumer()
2320
{
2421
if ($this->consumer instanceof BatchConsumer) {
@@ -32,12 +29,6 @@ public function stopConsumer()
3229
}
3330
}
3431

35-
public function restartConsumer()
36-
{
37-
// TODO: Implement restarting of consumer
38-
}
39-
40-
4132
protected function configure()
4233
{
4334
parent::configure();
@@ -97,7 +88,10 @@ protected function initConsumer(InputInterface $input)
9788
$this->consumer = $this->getContainer()
9889
->get(sprintf($this->getConsumerService(), $input->getArgument('name')));
9990

100-
if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) {
91+
if (null !== $input->getOption('memory-limit') &&
92+
ctype_digit((string) $input->getOption('memory-limit')) &&
93+
$input->getOption('memory-limit') > 0
94+
) {
10195
$this->consumer->setMemoryLimit($input->getOption('memory-limit'));
10296
}
10397
$this->consumer->setRoutingKey($input->getOption('route'));

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ batch_consumers:
776776
idle_timeout_exit_code: -2
777777
```
778778

779-
You can implement a batch consumer that will acknoledge all messages in one return or you can have control on what message to acknoledge.
779+
You can implement a batch consumer that will acknowledge all messages in one return or you can have control on what message to acknoledge.
780780

781781
```php
782782
namespace AppBundle\Service;
@@ -800,8 +800,9 @@ class DevckBasicConsumer implements BatchConsumerInterface
800800
return true;
801801
}
802802
}
803-
804803
```
804+
805+
```php
805806
namespace AppBundle\Service;
806807
807808
use OldSound\RabbitMqBundle\RabbitMq\BatchConsumerInterface;

RabbitMq/BatchConsumer.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,57 @@
77
use PhpAmqpLib\Exception\AMQPTimeoutException;
88
use PhpAmqpLib\Message\AMQPMessage;
99

10-
class BatchConsumer extends BaseAmqp implements DequeuerInterface
10+
final class BatchConsumer extends BaseAmqp implements DequeuerInterface
1111
{
1212
/**
1313
* @var int
1414
*/
15-
protected $consumed = 0;
15+
private $consumed = 0;
1616

1717
/**
1818
* @var \Closure|callable
1919
*/
20-
protected $callback;
20+
private $callback;
2121

2222
/**
2323
* @var bool
2424
*/
25-
protected $forceStop = false;
25+
private $forceStop = false;
2626

2727
/**
2828
* @var int
2929
*/
30-
protected $idleTimeout = 0;
30+
private $idleTimeout = 0;
3131

3232
/**
3333
* @var int
3434
*/
35-
protected $idleTimeoutExitCode;
35+
private $idleTimeoutExitCode;
3636

3737
/**
3838
* @var int
3939
*/
40-
protected $memoryLimit = null;
40+
private $memoryLimit = null;
4141

4242
/**
4343
* @var int
4444
*/
45-
protected $prefetchCount;
45+
private $prefetchCount;
4646

4747
/**
4848
* @var int
4949
*/
50-
protected $timeoutWait = 3;
50+
private $timeoutWait = 3;
5151

5252
/**
5353
* @var array
5454
*/
55-
protected $messages = array();
55+
private $messages = array();
5656

5757
/**
5858
* @var int
5959
*/
60-
protected $batchCounter = 0;
60+
private $batchCounter = 0;
6161

6262
/**
6363
* @param \Closure|callable $callback
@@ -86,7 +86,7 @@ public function execute(AMQPMessage $msg)
8686

8787
$this->maybeStopConsumer();
8888

89-
if (!is_null($this->getMemoryLimit()) && $this->isRamAlmostOverloaded()) {
89+
if (null !== $this->getMemoryLimit() && $this->isRamAlmostOverloaded()) {
9090
$this->stopConsuming();
9191
}
9292
}
@@ -188,7 +188,7 @@ protected function handleProcessMessages($processFlags = null)
188188
$this->consumed++;
189189
$this->maybeStopConsumer();
190190

191-
if (!is_null($this->getMemoryLimit()) && $this->isRamAlmostOverloaded()) {
191+
if (null !== $this->getMemoryLimit() && $this->isRamAlmostOverloaded()) {
192192
$this->stopConsuming();
193193
}
194194
}

0 commit comments

Comments
 (0)