No description
Find a file
Ferdinand Kuhl 1e040c9082
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/functional-tests Pipeline was successful
Annotation replacement is not compatible with Flow 7.3, so remove compatibility
2023-02-18 23:01:43 +01:00
.woodpecker Annotation replacement is not compatible with Flow 7.3, so remove compatibility 2023-02-18 23:01:43 +01:00
Classes Replacing annotations with attributes 2023-02-18 22:53:05 +01:00
Configuration Replacing annotations with attributes 2023-02-18 22:53:05 +01:00
Tests/Functional Support "AsMessageHandler"-Attribute for autoconfiguration 2023-01-05 18:08:46 +01:00
.phpstorm.meta.php First working version of symfony/messenger bus 2021-04-19 00:52:05 +02:00
composer.json Annotation replacement is not compatible with Flow 7.3, so remove compatibility 2023-02-18 23:01:43 +01:00
README.md Preparing release (basic readme and some keywords) 2023-02-18 22:56:11 +01:00

DigiComp.FlowSymfonyBridge.Messenger

Build status

This packages brings a DI configuration for the symfony/messenger component, so it can be used easily in neos/flow projects.

To see how to use it, you probably want to have a look at the documentation of symfony/messenger.

Getting started

To get it integrated, you all need to do is to get message bus injected:

    #[Flow\Inject]
    protected MessageBusInterface $messageBus;

And later in your method:

    $this->messageBus->dispatch(new CustomMessage())

You should configure a routing, to let the messenger know, over which transport your message should be handled:

DigiComp:
  FlowSymfonyBridge:
    Messenger:
      transports:
        "custom-messages":
          dsn: "flow-doctrine://default?table_name=test_messenger_messages"
      routing:
        Acme\Vendor\Messenger\CustomMessage:
          - "custom-messages"

In this example we are using a doctrine transport (the speciality "flow-transport" is a transport which uses the already existing connection to doctrine instead of creating a new one - for the rest of the DSN-Format have a look in the documentation of symfony/messenger)

A handler for your CustomMessage could look like this:

use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
class CustomMessageHandler
{
    public function __invoke(CustomMessage $message)
    {
        //your code here
    }
}

It will be automatically found by Flow // the messenger and messages arriving at the bus will be handled by your handler.

Probably you'll want to consume the messengers with long living processes or as a cronjob. The Flow command for that task is messenger:consume (more help available)