Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b5d253

Browse files
bug#62812 [Messenger][AMQP] Fix negative delays with AMQP messenger transport (hockdudu)
This PR was merged into the 6.4 branch.Discussion----------[Messenger][AMQP] Fix negative delays with AMQP messenger transport| Q | A| ------------- | ---| Branch? | 6.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fix#60658| License | MITThis prevents the AMQP from creating delay queues in the past. When a delay is in the past, the message should be handled immediately, so we send it to the normal queue.Commits-------c4532b0 Fix negative delays with AMQP messenger transport
2 parents0818333 +c4532b0 commit5b5d253

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

‎src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,36 @@ public function testItDelaysTheMessage()
501501
$connection->publish('{}', ['x-some-headers' =>'foo'],5000);
502502
}
503503

504+
publicfunctiontestItPublishesImmediatelyWithNegativeDelay()
505+
{
506+
$factory =newTestAmqpFactory(
507+
$amqpConnection =$this->createMock(\AMQPConnection::class),
508+
$amqpChannel =$this->createMock(\AMQPChannel::class),
509+
$amqpQueue =$this->createMock(\AMQPQueue::class),
510+
$amqpExchange =$this->createMock(\AMQPExchange::class)
511+
);
512+
513+
$amqpQueue->expects($this->once())->method('setName')->with('messages');
514+
$amqpQueue->expects($this->never())->method('setArguments');
515+
516+
$amqpQueue->expects($this->once())->method('declareQueue');
517+
$amqpQueue->expects($this->once())->method('bind')->with('messages');
518+
519+
$amqpExchange->expects($this->once())
520+
->method('publish')
521+
->with('{}',null, \AMQP_NOPARAM, [
522+
'headers' => [
523+
'x-some-headers' =>'foo',
524+
],
525+
'delivery_mode' =>2,
526+
'timestamp' =>time(),
527+
]);
528+
529+
$connection = Connection::fromDsn('amqp://localhost', [],$factory);
530+
531+
$connection->publish('{}', ['x-some-headers' =>'foo'], -5000);
532+
}
533+
504534
publicfunctiontestItRetriesTheMessage()
505535
{
506536
$delayExchange =$this->createMock(\AMQPExchange::class);

‎src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function publish(string $body, array $headers = [], int $delayInMs = 0, ?
289289
}
290290

291291
$this->withConnectionExceptionRetry(function ()use ($body,$headers,$delayInMs,$amqpStamp) {
292-
if (0!==$delayInMs) {
292+
if (0<$delayInMs) {
293293
$this->publishWithDelay($body,$headers,$delayInMs,$amqpStamp);
294294

295295
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp