Skip to content

Commit 4e3de14

Browse files
committed
[sqs] fix hanged tests.
1 parent 4853455 commit 4e3de14

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎bin/test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ php pkg/job-queue/Tests/Functional/app/console doctrine:database:create
3131
php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force
3232

3333
#php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue
34-
bin/phpunit --debug "$@"
34+
bin/phpunit "$@"

‎pkg/sqs/SqsConsumer.php‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,21 @@ public function getQueue()
9898
*/
9999
public function receive($timeout = 0)
100100
{
101-
$timeout /= 1000;
101+
$maxLongPollingTime = 20; // 20 is max allowed long polling value
102+
103+
if ($timeout === 0) {
104+
while (true) {
105+
if ($message = $this->receiveMessage($maxLongPollingTime)) {
106+
return $message;
107+
}
108+
}
109+
}
110+
111+
$timeout = (int) ceil($timeout / 1000);
112+
113+
if ($timeout > $maxLongPollingTime) {
114+
throw new \LogicException(sprintf('Max allowed SQS receive message timeout is: "%s"', $maxLongPollingTime));
115+
}
102116

103117
return $this->receiveMessage($timeout);
104118
}

0 commit comments

Comments
 (0)