Skip to content

Conversation

@constantable
Copy link

Allows to set timeout_wait flag for consumer
Inpired by the PR php-amqplib#559

composer.json Outdated
@@ -1,5 +1,5 @@
{
"name": "emag-tech-labs/rabbitmq-bundle",
"name": "constantable/rabbitmq-bundle",
Copy link
Collaborator

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
[![Latest Version](http://img.shields.io/packagist/v/emag-tech-labs/rabbitmq-bundle.svg?style=flat-square)](https://github.com/eMAGTechLabs/RabbitMqBundle/releases)
[![Build Status](https://travis-ci.org/eMAGTechLabs/RabbitMqBundle.svg?branch=master)](https://travis-ci.org/eMAGTechLabs/RabbitMqBundle)
[![Latest Version](http://img.shields.io/packagist/v/constantable/rabbitmq-bundle.svg?style=flat-square)](https://github.com/constantable/RabbitMqBundle/releases)
[![Build Status](https://travis-ci.org/constantable/RabbitMqBundle.svg?branch=master)](https://travis-ci.org/econstantable/RabbitMqBundle)
Copy link
Collaborator

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
Copy link
Collaborator

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",
Copy link
Collaborator

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()
Copy link
Collaborator

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

Copy link
Collaborator

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()
Copy link
Collaborator

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

Copy link
Collaborator

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

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;
use Symfony\Bridge\PhpUnit\ClockMock;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@constantable
Copy link
Author

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.
Fixed issues above, please review this again.
Thanks!

* Choose the timeout to use for the $this->getChannel()->wait() method.
* @return int
*/
public function getTimeoutWait()
Copy link
Collaborator

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

/**
* @param int $timeoutWait
*/
public function setTimeoutWait($timeoutWait)
Copy link
Collaborator

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.

* }
* @return int
*/
private function chooseWaitTimeout()
Copy link
Collaborator

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.

'timeoutType' => self::TIMEOUT_TYPE_IDLE,
'seconds' => $this->getIdleTimeout(),
);
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the comment.

Copy link
Author

@constantable constantable Oct 29, 2020

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?

Copy link
Collaborator

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

/**
* @return \DateTime|null
*/
protected function getLastActivityDateTime()
Copy link
Collaborator

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.

}

/**
* @param int $timeoutWait
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove comment

}

/**
* @return int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove comment.

/**
* Choose the timeout wait (in seconds) to use for the $this->getChannel()->wait() method.
*
* @return int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove comment.


/**
* @return \DateTime|null
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove comment.

@andreea-anamaria
Copy link
Collaborator

'timeoutType' => self::TIMEOUT_TYPE_GRACEFUL_MAX_EXECUTION,
'seconds' => $allowedExecutionSeconds,
);
if ($this->getTimeoutWait()) {
Copy link
Collaborator

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

@mihaileu mihaileu merged commit 5542098 into eMAGTechLabs:master Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants