Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger] Input for HandlerDescriptor should cause container rebuild #31409

Copy link
Copy link
Closed
@weaverryan

Description

@weaverryan
Issue body actions

Symfony version(s) affected: master (4.3)

Description
When creating a handler that implements MessageSubscriberInterface, which passes custom options about the handler (e.g. from_transport from #30958), if the user changes those options, they are not visible in the app. The problem is that this input is used to create an internal service (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php#L168), but the files these options were sourced from (the handler itself) is not added as a container resource.

How to reproduce

namespace App\MessageHandler;

use App\Message\SendEmail;
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;

class SendEmailHandler implements MessageSubscriberInterface
{
    public function __invoke(SendEmail $email)
    {
        //
    }

    public static function getHandledMessages(): iterable
    {
        yield SendEmail::class => [
            'from_transport' => 'async',
        ];
    }
}

Completely clear the cache. You can see that this handler is only called when coming from some async transport. Now, change to some other transport name and try again. It will still try to consume only from the original, async transport.

Possible Solution
If the config comes from the handler (i.e. if it implements MessageSubscriberInterface), it should be added as a resource. Doesn't this also affect normal MessageHandlerInterface handlers - if you changed the type-hint to __invoke(), would that cause a container rebuild?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.