Chapters
48 Chapters
|
5:05:05
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial is built with Symfony 4.3, but will work well on Symfony 4.4 or 5.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // v1.8.0
"doctrine/doctrine-bundle": "^1.6.10", // 1.11.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.6.3
"intervention/image": "^2.4", // 2.4.2
"league/flysystem-bundle": "^1.0", // 1.1.0
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.1
"sensio/framework-extra-bundle": "^5.3", // v5.3.1
"symfony/console": "4.3.*", // v4.3.2
"symfony/dotenv": "4.3.*", // v4.3.2
"symfony/flex": "^1.9", // v1.21.6
"symfony/framework-bundle": "4.3.*", // v4.3.2
"symfony/messenger": "4.3.*", // v4.3.4
"symfony/property-access": "4.3.*", // v4.3.2
"symfony/property-info": "4.3.*", // v4.3.2
"symfony/serializer": "4.3.*", // v4.3.2
"symfony/validator": "4.3.*", // v4.3.2
"symfony/webpack-encore-bundle": "^1.5", // v1.6.2
"symfony/yaml": "4.3.*" // v4.3.2
},
"require-dev": {
"easycorp/easy-log-handler": "^1.0.7", // v1.0.7
"symfony/debug-bundle": "4.3.*", // v4.3.2
"symfony/maker-bundle": "^1.0", // v1.12.0
"symfony/monolog-bundle": "^3.0", // v3.4.0
"symfony/stopwatch": "4.3.*", // v4.3.2
"symfony/twig-bundle": "4.3.*", // v4.3.2
"symfony/var-dumper": "4.3.*", // v4.3.2
"symfony/web-profiler-bundle": "4.3.*" // v4.3.2
}
}
12 Comments
I really thought the
MessengerEnvelopeMetadataAwareContainerReaderInterfacething was real at first ..!Hi there
is there a way to get retry count on Symfony message handler.
Messenger consumer command throws an error and retries it 5 times according to configuration. So I want to get retry count in handler so I can add some logic accordingly.
Hi!
For anyone looking, this question (a very interesting question!) is answered over here: https://symfonycasts.com/sc...
Cheers!
Hi, I would like to track the state of all messages to a tracking table, does any one know if this functionality is implemented or is planned to? thanks a lot!
Hey SamuelVicent!
You have a few options here. The easiest, but the one that contains the least information, would be to use the "doctrine" transport so that your messages are stored in a database. Then you can query them to get some information. But, this table structure is "fixed" and it's meant to help Messenger - not to give you all the information that you need, for example :).
So, if you need more information or control, I would register an event listener (or several) and update a separate table as things happen. If you look in the Worker class - https://github.com/symfony/... - you'll see a number of different events you can listen to (search for dispatchEvent).
But, let's back up: what kind of tracking would you like to do?
Cheers!
Hi, first of all, thanks for the feedback.
Let me explain my experience on this:
A few weeks ago we created 2 listeners for WorkerMessageFailedEvent and WorkerMessageHandledEvent.
We use mariaDb as a database engine for tracking the state of each message (only track messages of type SendEmailMessage.)
It worked in some way, but had some problems with deadlocks tables. We saw a solution on symfony github issue 42345.
We have been working on some solution using a custom Middleware and playing with Stamps but still have not a robust code.
We will try to apply the github solution to see if the Event approach works.
That's the reason why I asked you if you know some message tracking implementation.
Thanks a lot :)
Hey SamuelVicent!
Hmm, that's very interesting about the deadlocks! Let me know how it goes, I'd like to know :).
Cheers!
Hi Ryan,
We finally used listeners for tracking handled and failed messages.
Had to use rabbitMq as transport for managing messages, an a database in mariadb for the tracking (for knowing which messages were send properly or not).
Apart from this, using MariaDb as transport gave us DeadLock problems in a master to master setup (sync db between 2 servers).
Hope it helps as a experience :)
Regards and merry christmas!
Thanks for sharing all of that! And yes, I think that, in the real world, using the database (at least MySQL/MariaDB - the Pgsql queue transport is much more robust in messenger... because pgsql is much more robust) can cause dead lock issues.
Anyways, I always like to hear solutions that work nicely - thanks for sharing and a merry christmas back to you!
I understand main idea about adding stamps without duplicates, but I don't understand code design in Messenger source code. It's very confusing to me :)
Why methods "last" and "with" have different signatures? Why we need check stamp by FQCN but can't instantiate stamp by FQCN inside "with" method? What's the purpose of keeping stamps in array by "FQCN" => "stamp instance" as "key" => "value" inside envelope?
Hey Dariia M.
The
with()method clones such Envelope and if you pass in any stamps it will add them to the new cloned envelope object. It's just a way to create your current envelope with more or the same stamps it already hasThe
last()method only finds the latest stamp added to your envelope by a FQCN. Since an envelope can have many stamps of the same type, storing them in an array indexed by their FQCN is a handy way to fetch them by typeCheers!
Hi MolloKhan
Thank you for detailed explanation, now everything is clear for me!
"Houston: no signs of life"
Start the conversation!