Comments (8)
Could not decode message using PHP serialization
It seems like Symfony is trying to use unserialize()
(the PHP serialization format) over the message content, but the message content is JSON.
Maybe it's a matter of configuring Symfony Messenger so that it uses JSON as a format?
from symfony-messenger.
In that case I would recommend using a typed handler: https://bref.sh/docs/function/handlers.html#sns-events
Note that this typed handler can be a Symfony service, you can use the same trick to load a symfony service:
<?php declare(strict_types=1);
use Bref\Symfony\Messenger\Service\Sqs\SqsConsumer;
require dirname(__DIR__) . '/config/bootstrap.php';
$kernel = new \App\Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer()->get(MySnsHandlerService::class);
from symfony-messenger.
Thanks so much, you put me in the right direction!
Since Symfony 4.3 Symfony has moved from its serializer (JSON) to the PhpSerializer.
Symfony 4.3 & 4.4:
framework:
messenger:
serializer:
id: 'messenger.transport.symfony_serializer'
Though this doesn't work yet on Symfony 5, there you need to make the change as follows:
framework:
messenger:
serializer:
default_serializer: messenger.transport.symfony_serializer
symfony_serializer:
format: json
context: { }
Should I make a PR with this and add it to the readme?
from symfony-messenger.
After this, a lot more errors occur that have to do with the old integration of this module and the latest Symfony.
In the meantime, I've also written my own SnsConsumer and created my own Serializer. This works (sketchy) as of now, though am I doing something completely wrong, or is the integration with Symfony 5.x not fully tested yet?
from symfony-messenger.
I'm confused: is your Symfony Lambda worker handling events that were created by the Symfony application?
The principle is like this:
- Symfony emits a message to SQS, SNS or EventBridge
- SQS/SNS/EventBridge triggers Lambda -> Symfony processes the message
So the format of the message is defined by Symfony: if you publish it as JSON, your app will receive it as JSON. If you publish it as serialized, then your app will receive it as serialized.
Are you using another architecture?
from symfony-messenger.
Ah... That would explain a lot... My bad, sorry.
So the approach I'm taking and using this bridge/bundle for is to receive SES messages in SNS and process them with a Lambda function.
So in my case Symfony isn't creating a message in SNS, but SES is (or anything else I want to hook SES on).
Would you recommend another module/approach for this? Or is this uncommon and does it indeed require custom built software?
from symfony-messenger.
This explains a lot, thanks so much!
I'll probably write a blog post about it or something, in case others ever have the same situation.
from symfony-messenger.
Please do!
from symfony-messenger.
Related Issues (20)
- Use symfony/amazon-sqs-messenger Transport for sending messages HOT 6
- Switching from 0.2 to 0.3.1 handle a "Access to the resource https://sqs.eu-west-3.amazonaws.com" HOT 6
- Allow to stop retrying an SQS message HOT 7
- Not found bootstrap.php file HOT 4
- 403 Access denied after upgrading to 0.4.0 and bref 1.1.4 HOT 2
- Deprecation notice in Symfony >= 5.1 HOT 2
- SQS queue : Connection setup error HOT 7
- Sending message to a custom event bus HOT 11
- Support for Symfony 6 HOT 1
- Implement partial failure on SqsConsumer HOT 4
- Message handler does not seem to be working HOT 8
- Using with Monolog results in no mail?
- Road to 1.0
- PartialBatchFailure issue HOT 2
- Question about the DetailType parameter HOT 3
- Handling messages from SQS not working HOT 2
- SQS record with id "%s" failed to be processed. But failure was marked as unrecoverable. HOT 3
- Batch failure with Fifo queue
- Architectural Improvements for SNS-SQS-Lambda Integration with Symfony Messenger HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symfony-messenger.