I want unserilize the Symfony messages in the table messenger_messages.
I tried with unserialize() function but I've got a notice saying: "unserialize(): Error at offset 0 of 1380 bytes in ..." (message cut).
I had as result only the notice and not the unserilized string I passed to the function.
Here an example I tried to unserialize (I changed some data for privacy):
O:36:\"Symfony\\Component\\Messenger\\Envelope\":2:{s:44:\"\0Symfony\\Component\\Messenger\\Envelope\0stamps\";a:1:{s:46:\"Symfony\\Component\\Messenger\\Stamp\\BusNameStamp\";a:1:{i:0;O:46:\"Symfony\\Component\\Messenger\\Stamp\\BusNameStamp\":1:{s:55:\"\0Symfony\\Component\\Messenger\\Stamp\\BusNameStamp\0busName\";s:26:\"messenger.bus.pimcore-core\";}}}s:45:\"\0Symfony\\Component\\Messenger\\Envelope\0message\";O:36:\"App\\Hubspot\\TransactionalMailMessage\":1:{s:45:\"\0App\\Hubspot\\TransactionalMailMessage\0payload\";a:4:{s:7:\"emailId\";i:53540933612;s:9:\"recipient\";a:7:{s:5:\"email\";s:23:\"[email protected]\";s:5:\"phone\";s:10:\"3289736434\";s:9:\"firstName\";s:5:\"Sequi\";s:8:\"lastName\";s:7:\"Lorenzo\";s:12:\"customerType\";s:7:\"privato\";s:17:\"newsletterConsent\";b:1;s:5:\"admin\";b:0;}s:4:\"data\";a:13:{s:11:\"ID_ANNUNCIO\";i:5920;s:14:\"TOKEN_ANNUNCIO\";s:15:\"PR65E095202E52F\";s:15:\"TITOLO_ANNUNCIO\";s:41:\"Agazzini ENDURO CARBON CANE CREEK EDITION\";s:12:\"EMAIL_AUTORE\";s:23:\"[email protected]\";s:15:\"TELEFONO_AUTORE\";s:10:\"3289736434\";s:12:\"URL_ANNUNCIO\";s:39:\"http://localhost/announcement/5920/view\";s:17:\"URL_ANNUNCIO_EDIT\";s:39:\"http://localhost/announcement/5920/edit\";s:18:\"URL_ANNUNCIO_ADMIN\";s:65:\"https://www.ebikemood.com/admin/login/deeplink?object_5920_object\";s:6:\"STATUS\";s:6:\"review\";s:15:\"NOTE_UNAPPROVED\";s:0:\"\";s:13:\"NOTE_REJECTED\";s:0:\"\";s:11:\"OFFER_PRICE\";s:0:\"\";s:17:\"OFFER_DESCRIPTION\";s:0:\"\";}s:6:\"sendId\";N;}}}
First, check which serializer is used in your config, e.g.
If not explicitly set, messenger component uses its default internal Serializer:
Symfony\Component\Messenger\Transport\Serialization\Serializer
Now, the tricky part is that it expects an encoded envelope of a specific format:
If you don't use any additional metadata (like stamps, etc.), you can now simply inject Serializer and try to create the envelope manually and decode the message:
Otherwise, you'll need to populate 'headers' element with all headers from the message (if you can obtain from wherever you have it bypassing the messenger component).