Reputation: 41
I have integrated symfony messenger bundle and i am trying to encode that message . It was working in Symfony 3.4.4 version . However it is giving above error in Symfony 3.4.28 version. I have traced in symfony serialzer component , it seems that jsonEncoder is not listing in serialzer.php and which is causing this issue.
What is the reason for excluding json encoder in symfony serializer component. See below DoctrineTransportSender:
public function send(Envelope $envelope)
{
$encodedMessage = $this->encoder->encode($envelope);
}
//messenger configuration:
messenger:
transports:
# DSN: doctrine://$repository_alias/$queue_name
# most likely we do not need more repositories (unless there's a need for splitting MySQL table with messages)
main: "doctrine://default/test"
routing:
# message type to transport routes
Bundle\QueueBundle\Message\TestMessage: [ main ]
serializer:
enabled: true
Upvotes: 4
Views: 6566
Reputation: 41
Thanks for the response. I have resolved above issue by adding customized serializer instead of calling messenger serializer(Which includes encoding as well decoding) and it works fine
Upvotes: 0
Reputation: 17166
Symfony Messenger switched to PHP's native serialization/deserialization by default. Using php serialization prevents problems, e.g. accidentally omitting properties from being serialized. It will also ensure the component can be used without Symfony Serializer, which is less of an issue with Symfony 3.4, but with Symfony 4 and Flex or when using the messenger outside of Symfony you would have to install this dependency manually leading to errors.
You can still use Symfony Serializer, but it has to be configured. Considering you are on Symfony 3.4 you will likely have to do this manually by providing an appropriate Serializer-instance to the TransportFactory, see:
In Symfony 4 you can use the configuration instead, see:
https://symfony.com/doc/current/messenger.html#serializing-messages
Upvotes: 1