Skip to content

Commit

Permalink
Fix RetryFailedMessageMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
DumitracheAdrian committed May 4, 2024
1 parent fd2eb8a commit e248588
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
24 changes: 4 additions & 20 deletions packages/messenger/Message/RetryFailedMessageMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,15 @@

namespace Draw\Component\Messenger\Message;

use App\Entity\MessengerMessage;
use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Message\DoctrineReferenceAwareInterface;
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;

class RetryFailedMessageMessage implements DoctrineReferenceAwareInterface
class RetryFailedMessageMessage
{
private ?MessengerMessage $message;

public function __construct(
MessengerMessage $message,
private string $messageId,
) {
$this->message = $message;
}

public function getMessage(): MessengerMessage
{
if (null === $this->message) {
throw new UnrecoverableMessageHandlingException('Message is not set.');
}

return $this->message;
}

public function getPropertiesWithDoctrineObject(): array
public function getMessageId(): string
{
return ['message'];
return $this->messageId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function handleRetryFailedMessageMessage(RetryFailedMessageMessage $messa
[
$this->consolePath,
'messenger:failed:retry',
$message->getMessage()->getId(),
$message->getMessageId(),
'--force',
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Draw\Component\Messenger\Tests\MessageHandler;

use App\Entity\MessengerMessage;
use Draw\Component\Messenger\Message\RetryFailedMessageMessage;
use Draw\Component\Messenger\MessageHandler\RetryFailedMessageMessageHandler;
use Draw\Contracts\Process\ProcessFactoryInterface;
Expand Down Expand Up @@ -56,9 +55,7 @@ public function testHandleRetryFailedMessageMessage(): void
->method('mustRun');

$this->handler->handleRetryFailedMessageMessage(
new RetryFailedMessageMessage(
(new MessengerMessage())->setId($messageId)
)
new RetryFailedMessageMessage($messageId)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function retryAction(
}

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

$this->addFlash(
Expand Down

0 comments on commit e248588

Please sign in to comment.