i’m facing a problem while receiving messages from rabbitMQ message broker to my symfony application, i set the different files and downloaded the needed libraries, but i can’t receive any message while i’m sure i have more than 1000 messages waiting . any help please ?
i will share with you my files responsible for the message handling and dispatching
this is my messenger.yaml :
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
transports:
# RabbitMQ transport configuration
async:
dsn: '%env(FTUSA_MESSENGER_URL)%'
serializer: 'AppMessageSerializerSerializer'
#options:
#queue:
#name: 'FTUSA_09' # Define the queue name here
failed: 'doctrine://default?queue_name=failed'
sync: 'sync://'
routing:
# Route your messages to the transports
'AppMessageSendNotification': async
'AppMessageMessageNotification': async
this is my SendNotification.php file :
<?php
namespace AppMessage;
class SendNotification
{
private string $message;
private string $action;
private string $folderRef;
private string $folderStatut;
private string $ApplicantSinistreNumber;
private string $folderId;
public function __construct(string $message, string $action, string $folderRef, string $folderStatut, string $ApplicantSinistreNumber, string $folderId)
{
$this->message = $message;
$this->action = $action;
$this->folderRef = $folderRef;
$this->folderStatut = $folderStatut;
$this->ApplicantSinistreNumber = $ApplicantSinistreNumber;
$this->folderId = $folderId;
}
public function getMessage(): string
{
return $this->message;
}
public function getAction(): string
{
return $this->action;
}
public function getFolderRef(): string
{
return $this->folderRef;
}
public function getFolderStatut(): string
{
return $this->folderStatut;
}
public function getApplicantSinistreNumber(): string
{
return $this->ApplicantSinistreNumber;
}
public function getFolderId(): string
{
return $this->folderId;
}
and this is my SendNotificationHandler.php :
<?php
namespace AppMessageHandler;
use AppEntityConnectorsActivitiesLog;
use AppMessageSendNotification;
##[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)]
use DateTime;
use DoctrineORMEntityManagerInterface;
use phpDocumentorReflectionTypesBoolean;
use PsrLogLoggerInterface;
use SymfonyComponentMessengerAttributeAsMessageHandler;
#[AsMessageHandler]
class SendNotificationHandler
{
/**
* @var EntityManagerInterface
*/
private EntityManagerInterface $entityManager;
/**
* @var LoggerInterface
*/
private LoggerInterface $logger;
public function __construct(EntityManagerInterface $entityManager, LoggerInterface $logger)
{
$this->entityManager = $entityManager;
$this->logger = $logger;
}
/**
* @param SendNotification $notification
*/
public function __invoke(SendNotification $notification): void
{
echo sprintf(
"Processing message: %snAction: %snFolder Ref: %snFolder Statut: %snApplicant Sinistre Number: %snFolder ID: %sn",
$notification->getMessage(),
$notification->getAction(),
$notification->getFolderRef(),
$notification->getFolderStatut(),
$notification->getApplicantSinistreNumber(),
$notification->getFolderId()
);
$this->logger->info('Processing message', [
'message' => $notification->getMessage(),
'action' => $notification->getAction(),
'folderRef' => $notification->getFolderRef(),
'folderStatut' => $notification->getFolderStatut(),
'ApplicantSinistreNumber' => $notification->getApplicantSinistreNumber(),
'folderId' => $notification->getFolderId(),
]);
$this->logger->info('I just got the logger');
$log = new ConnectorsActivitiesLog();
$log->setReference($notification->getFolderRef());
$log->setReference($notification->getApplicantSinistreNumber());
$log->setLogDetails('Action = ' . $notification->getAction() . ' AppSinNum = ' . $notification->getApplicantSinistreNumber() . ' ID = ' . $notification->getFolderId() . ' Message = ' . $notification->getMessage());
$log->setStatus($notification->getFolderStatut());
$log->setStartDateTime(new DateTime());
$log->setEndDateTime(new DateTime());
$this->entityManager->persist($log);
$this->entityManager->flush();
}
}
and this is my MessageNotification.php file :
<?php
namespace AppMessage;
class MessageNotification
{
public function __construct(
private string $content,
) {
}
public function getContent(): string
{
return $this->content;
}
}