Skip to content

Commit

Permalink
[SonataIntegrationBundle] Fix retry message using interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoiriert committed May 10, 2024
1 parent bf76ce1 commit 209f7f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -25,7 +31,7 @@ public function retryAction(
}

$messageBus->dispatch(
new RetryFailedMessageMessage($message->getId())
new RetryFailedMessageMessage($message->getMessageId())
);

$this->addFlash(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down

0 comments on commit 209f7f0

Please sign in to comment.