diff --git a/packages/sonata-integration-bundle/Messenger/Controller/MessageController.php b/packages/sonata-integration-bundle/Messenger/Controller/MessageController.php index d57ae430..b8a3a52d 100644 --- a/packages/sonata-integration-bundle/Messenger/Controller/MessageController.php +++ b/packages/sonata-integration-bundle/Messenger/Controller/MessageController.php @@ -4,17 +4,23 @@ namespace Draw\Bundle\SonataIntegrationBundle\Messenger\Controller; -use App\Entity\MessengerMessage; use Draw\Component\Messenger\Message\RetryFailedMessageMessage; +use Draw\Component\Messenger\Transport\Entity\DrawMessageInterface; use Sonata\AdminBundle\Controller\CRUDController; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Messenger\MessageBusInterface; class MessageController extends CRUDController { public function retryAction( - MessengerMessage $message, + Request $request, MessageBusInterface $messageBus - ) { + ): Response { + $message = $this->assertObjectExists($request, true); + + \assert($message instanceof DrawMessageInterface); + if ('failed' !== $message->getQueueName()) { $this->addFlash( 'sonata_flash_error', @@ -25,7 +31,7 @@ public function retryAction( } $messageBus->dispatch( - new RetryFailedMessageMessage($message->getId()) + new RetryFailedMessageMessage($message->getMessageId()) ); $this->addFlash( diff --git a/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php b/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php index a87bbdeb..2a880bac 100644 --- a/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php +++ b/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php @@ -44,11 +44,11 @@ public function testRetry(): void static::$client->request('GET', sprintf('/admin/app/messengermessage/%s/retry', $failedMessage->getId())); + static::assertResponseStatusCodeSame(302); + static::getTransportTester('async') ->assertMessageMatch(RetryFailedMessageMessage::class); - static::assertResponseStatusCodeSame(302); - static::$client->followRedirect(); static::assertSelectorTextContains('.alert-success', 'Retry message successfully dispatched.');