We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On the encode function of the Serilizer, all stamps are used and sent in the header stamps.
encode
Serilizer
This seems to work correctly before. But now, there is a NonSendableStampInterface that should be used to find which stamp could be used in that case.
NonSendableStampInterface
The comment on that classe reads: A stamp that should not be included with the Envelope if sent to a transport.
A stamp that should not be included with the Envelope if sent to a transport.
In order to fix it, I updated the code like that:
use Symfony\Component\Messenger\Stamp\NonSendableStampInterface; $allStamps = []; foreach ($envelope->all() as $stamps) { $allStamps = array_merge($allStamps, $stamps); } // Filter to keep only correct stamps. $allStamps = array_filter($allStamps, function ($stamp) { return !is_object($stamp) || !($stamp instanceof NonSendableStampInterface); });
I wanted to send a pull request, but I cannot where this code is. It's referenced with some ID that I could not find in the repo...
The text was updated successfully, but these errors were encountered:
My code is like:
readonly class FooInterchangeableSerializer implements SerializerInterface { public function encode(Envelope $envelope): array { $envelope = $envelope->withoutStampsOfType(NonSendableStampInterface::class); [...] } public function decode(array $encodedEnvelope): Envelope { if (empty($encodedEnvelope['body'])) { throw new MessageDecodingFailedException('Encoded envelope should have at least a "body".'); } $headers = $encodedEnvelope['headers']; $stamps = []; if (isset($headers['stamps'])) { /** @var array $stamps */ $stamps = unserialize(base64_decode($headers['stamps'])); } /** * The method all() returns a different format that the one excepted by the {@see Envelope::__construct()}, * so normalize them. */ /** @var StampInterface[] $normalizedStamps */ $normalizedStamps = []; foreach ($stamps as $stamp) { if (!is_array($stamp)) { $normalizedStamps[] = $stamp; continue; } foreach ($stamp as $innerStamp) { $normalizedStamps[] = $innerStamp; } } $body = $encodedEnvelope['body']; $event = EventSerializer::decode($body); return new Envelope($event, $normalizedStamps); } }
Sorry, something went wrong.
No branches or pull requests
On the
encode
function of theSerilizer
, all stamps are used and sent in the header stamps.This seems to work correctly before.
But now, there is a
NonSendableStampInterface
that should be used to find which stamp could be used in that case.The comment on that classe reads:
A stamp that should not be included with the Envelope if sent to a transport.
In order to fix it, I updated the code like that:
I wanted to send a pull request, but I cannot where this code is.
It's referenced with some ID that I could not find in the repo...
The text was updated successfully, but these errors were encountered: