I have setup a Messaging queue with Symfony which used to work well. However I have changed the format. I have removed a field in it and now I get an error that I cannot decode the envelope.
My yaml config
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
routing:
# Route your messages to the transports
'AppMessageLogData': async
My LogData
final class LogData
{
/**
* @param string $serviceName
* @param DateTimeInterface $timestamp
* @param string $requestMethod
* @param string $requestUri
* @param int $statusCode
*/
public function __construct (
private readonly string $serviceName,
private readonly DateTimeInterface $timestamp,
private readonly string $requestMethod,
private readonly string $requestUri,
private readonly int $statusCode
) {}
public function getServiceName(): string
{
return $this->serviceName;
}
public function getTimestamp(): DateTimeInterface
{
return $this->timestamp;
}
public function getRequestUri(): string
{
return $this->requestUri;
}
public function getRequestMethod(): string
{
return $this->requestMethod;
}
public function getStatusCode(): int
{
return $this->statusCode;
}
}
I have a command that reads from a file and calls the consume
$this->importer->importLocalLogFile();
$output->writeln('Logs saved in the background.');
shell_exec('php bin/console messenger:consume async --limit=20 -v');
After the shell_exec it gets an error during envelope decoding
[SymfonyComponentMessengerExceptionMessageDecodingFailedException]
Could not decode Envelope: Creation of dynamic property AppMessageLogData::$requestHeader is deprecated
Where the $requestHeader
is the removed property
I know I dont set it in the envelope since it doesn’t exist in the class. For the envelope I am doing
return new LogData(
$serviceName,
$timestamp,
$requestMethod,
$requestUri,
$responseCode
);
and then
$logsData = $this->logParser->parseLocalFile($filePath);
foreach ($logsData as $logData) {
$this->messageBus->dispatch($logData);
}
I am running my app in docker and I remove all containers and trigger the build again and then i trigger the command in the container and thats the result.