-
Notifications
You must be signed in to change notification settings - Fork 10
Consumer timeout wait #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
composer.json
Outdated
| @@ -1,5 +1,5 @@ | |||
| { | |||
| "name": "emag-tech-labs/rabbitmq-bundle", | |||
| "name": "constantable/rabbitmq-bundle", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this.
README.md
Outdated
| [](https://github.com/eMAGTechLabs/RabbitMqBundle/releases) | ||
| [](https://travis-ci.org/eMAGTechLabs/RabbitMqBundle) | ||
| [](https://github.com/constantable/RabbitMqBundle/releases) | ||
| [](https://travis-ci.org/econstantable/RabbitMqBundle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this.
README.md
Outdated
|
|
||
| ```bash | ||
| $ composer require emag-tech-labs/rabbitmq-bundle | ||
| $ composer require constantable/rabbitmq-bundle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this.
README.md
Outdated
| { | ||
| "require": { | ||
| "emag-tech-labs/rabbitmq-bundle": "^2.0", | ||
| "constantable/rabbitmq-bundle": "^2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this.
| $consumer->consume(1); | ||
| } | ||
|
|
||
| public function testTimeoutWait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rerun this test and check the failing reason:
1) OldSound\RabbitMqBundle\Tests\RabbitMq\ConsumerTest::testTimeoutWait Expectation failed for method name is "wait" when invoked 2 time(s) Parameter 2 for invocation PhpAmqpLib\Channel\AbstractChannel::wait(null, false, 29) does not match expected value. Failed asserting that 29 matches expected 30. /home/travis/build/eMAGTechLabs/RabbitMqBundle/RabbitMq/Consumer.php:95 /home/travis/build/eMAGTechLabs/RabbitMqBundle/Tests/RabbitMq/ConsumerTest.php:398
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check also:
3) OldSound\RabbitMqBundle\Tests\RabbitMq\DynamicConsumerTest::testTimeoutWait Expectation failed for method name is "wait" when invoked 2 time(s) Parameter 2 for invocation PhpAmqpLib\Channel\AbstractChannel::wait(null, false, 29) does not match expected value. Failed asserting that 29 matches expected 30. /home/travis/build/eMAGTechLabs/RabbitMqBundle/RabbitMq/Consumer.php:95 /home/travis/build/eMAGTechLabs/RabbitMqBundle/Tests/RabbitMq/ConsumerTest.php:398
| $consumer->consume(1); | ||
| } | ||
|
|
||
| public function testTimeoutWaitWontWaitPastGracefulMaxExecutionTimeout() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rerun this test and check the failing reason:
2) OldSound\RabbitMqBundle\Tests\RabbitMq\ConsumerTest::testTimeoutWaitWontWaitPastGracefulMaxExecutionTimeout Expectation failed for method name is "wait" when invoked 1 time(s) Parameter 2 for invocation PhpAmqpLib\Channel\AbstractChannel::wait(null, false, 9) does not match expected value. Failed asserting that 9 matches expected 10. /home/travis/build/eMAGTechLabs/RabbitMqBundle/RabbitMq/Consumer.php:95 /home/travis/build/eMAGTechLabs/RabbitMqBundle/Tests/RabbitMq/ConsumerTest.php:435
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check also:
4) OldSound\RabbitMqBundle\Tests\RabbitMq\DynamicConsumerTest::testTimeoutWaitWontWaitPastGracefulMaxExecutionTimeout Expectation failed for method name is "wait" when invoked 1 time(s) Parameter 2 for invocation PhpAmqpLib\Channel\AbstractChannel::wait(null, false, 9) does not match expected value. Failed asserting that 9 matches expected 10. /home/travis/build/eMAGTechLabs/RabbitMqBundle/RabbitMq/Consumer.php:95 /home/travis/build/eMAGTechLabs/RabbitMqBundle/Tests/RabbitMq/ConsumerTest.php:435
Tests/RabbitMq/ConsumerTest.php
Outdated
| use PHPUnit\Framework\TestCase; | ||
| use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
| use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface; | ||
| use Symfony\Bridge\PhpUnit\ClockMock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…estTimeoutWait' tests
|
I'm sorry for the multiple unintended code changes. I was not expecting further code changes would be reflected on the PR once it has been submitted. |
RabbitMq/Consumer.php
Outdated
| * Choose the timeout to use for the $this->getChannel()->wait() method. | ||
| * @return int | ||
| */ | ||
| public function getTimeoutWait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return type here and not in comment, as:
public function getTimeoutWait(): int
RabbitMq/Consumer.php
Outdated
| /** | ||
| * @param int $timeoutWait | ||
| */ | ||
| public function setTimeoutWait($timeoutWait) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add return type and parameter type here and not in comment.
RabbitMq/Consumer.php
Outdated
| * } | ||
| * @return int | ||
| */ | ||
| private function chooseWaitTimeout() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return type here and not in comment.
RabbitMq/Consumer.php
Outdated
| 'timeoutType' => self::TIMEOUT_TYPE_IDLE, | ||
| 'seconds' => $this->getIdleTimeout(), | ||
| ); | ||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean I should completely remove @param annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Once you've added typehint for parameter, comment it's useless
RabbitMq/Consumer.php
Outdated
| /** | ||
| * @return \DateTime|null | ||
| */ | ||
| protected function getLastActivityDateTime() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return type here and not in comment.
RabbitMq/Consumer.php
Outdated
| } | ||
|
|
||
| /** | ||
| * @param int $timeoutWait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove comment
RabbitMq/Consumer.php
Outdated
| } | ||
|
|
||
| /** | ||
| * @return int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove comment.
RabbitMq/Consumer.php
Outdated
| /** | ||
| * Choose the timeout wait (in seconds) to use for the $this->getChannel()->wait() method. | ||
| * | ||
| * @return int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove comment.
RabbitMq/Consumer.php
Outdated
|
|
||
| /** | ||
| * @return \DateTime|null | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove comment.
|
Please checkout failing tests: https://scrutinizer-ci.com/g/eMAGTechLabs/RabbitMqBundle/inspections/4c087a48-4115-441e-abb3-40eb74100361 |
RabbitMq/Consumer.php
Outdated
| 'timeoutType' => self::TIMEOUT_TYPE_GRACEFUL_MAX_EXECUTION, | ||
| 'seconds' => $allowedExecutionSeconds, | ||
| ); | ||
| if ($this->getTimeoutWait()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if (!is_null($this->getTimeoutWait())) or if ($this->getTimeoutWait() !== null) because it returns an integer value. Check also: https://scrutinizer-ci.com/g/eMAGTechLabs/RabbitMqBundle/inspections/d889e465-34c7-4f57-bea6-6300aa404c64/issues/files/RabbitMq/Consumer.php?status=new&orderField=path&order=asc&honorSelectedPaths=0
Allows to set timeout_wait flag for consumer
Inpired by the PR php-amqplib#559