Introduce message class resolver#310
Conversation
vjik
commented
Jun 15, 2026
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ✔️ |
| Breaks BC? | ✔️ |
| Tests pass? | ✔️ |
| Fix #292 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #310 +/- ##
========================================
Coverage 0.00% 0.00%
+ Complexity 336 334 -2
========================================
Files 50 51 +1
Lines 920 918 -2
========================================
+ Misses 920 918 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| MessageClassResolverInterface::class => [ | ||
| 'class' => ArrayMessageClassResolver::class, | ||
| '__construct()' => [ | ||
| 'map' => $params['yiisoft/queue']['message-class-map'], |
There was a problem hiding this comment.
Since we have just handlers, "messages" makes more sense:
| 'map' => $params['yiisoft/queue']['message-class-map'], | |
| 'map' => $params['yiisoft/queue']['messages'], |
| 'middlewares-push' => [], | ||
| 'middlewares-consume' => [], | ||
| 'middlewares-fail' => [], | ||
| 'message-class-map' => [], |
There was a problem hiding this comment.
| 'message-class-map' => [], | |
| 'messages' => [], |
I'd also move that as 1st array key so it will be message, handlers etc. The drawback here is that we repeat the same thing two times:
'messages' => [
'process-pdf' => ProcessPdfMessage::class,
],
'handlers' => [
'process-pdf' => ProcessPdfMessageHandler::class,
],Could be possibly combined:
'messages' => [
'process-pdf' => [ProcessPdfMessage::class, ProcessPdfMessageHandler::class],
],|
|
||
| - **Queue names** — configure queue/back-end per logical queue name via [`yiisoft/queue.queues` config](queue-names.md) when you need to parallelize message handling or send some of them to a different application. | ||
| - **Named handlers or callable definitions** — map a short message type to a callable in [`yiisoft/queue.handlers` config](message-handler-advanced.md) when another application is the message producer and you cannot use FQCN as message type. | ||
| - **Message class map** — map message types to specific message classes so that `unserialize()` reconstructs the |
There was a problem hiding this comment.
Need to use the full interface name, or else unserialize() will be confused with the native PHP function.
| - **Queue names** — configure queue/back-end per logical queue name via [`yiisoft/queue.queues` config](queue-names.md) when you need to parallelize message handling or send some of them to a different application. | ||
| - **Named handlers or callable definitions** — map a short message type to a callable in [`yiisoft/queue.handlers` config](message-handler-advanced.md) when another application is the message producer and you cannot use FQCN as message type. | ||
| - **Message class map** — map message types to specific message classes so that `unserialize()` reconstructs the | ||
| original typed object instead of falling back to `GenericMessage`. Configure via `yiisoft/queue.message-class-map`: |
There was a problem hiding this comment.
| original typed object instead of falling back to `GenericMessage`. Configure via `yiisoft/queue.message-class-map`: | |
| original typed object instead of falling back to `GenericMessage`. Configure via `yiisoft/queue.messages`: |
| ```php | ||
| return [ | ||
| 'yiisoft/queue' => [ | ||
| 'message-class-map' => [ |
There was a problem hiding this comment.
| 'message-class-map' => [ | |
| 'messages' => [ |
| /** | ||
| * Resolves message classes from a predefined map of type-to-class associations. | ||
| */ | ||
| final class ArrayMessageClassResolver implements MessageClassResolverInterface |
There was a problem hiding this comment.
What other implementations do you see?