Skip to content

Commit

Permalink
NEXT-39755 - Update messenger docs to use default symfony bus
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed Nov 28, 2024
1 parent 279e240 commit f8eb707
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion concepts/framework/messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shopware integrates with the [Symfony Messenger](https://symfony.com/doc/current

### Message Bus

The [Message bus](https://symfony.com/doc/current/components/messenger.html#bus) is used to dispatch your messages to your registered handlers. While dispatching your message it loops through the configured middleware for that bus. The message bus used inside Shopware can be found under the service tag `messenger.bus.shopware`. It is mandatory to use this message bus if your messages should be handled inside Shopware. However, if you want to send messages to external systems, you can define your custom message bus for that.
The [Message bus](https://symfony.com/doc/current/components/messenger.html#bus) is used to dispatch your messages to your registered handlers. While dispatching your message it loops through the configured middleware for that bus. The message bus used inside Shopware can be found under the service tag `messenger.default_bus`. It is mandatory to use this message bus if your messages should be handled inside Shopware. However, if you want to send messages to external systems, you can define your custom message bus for that.

### Middleware

Expand Down
6 changes: 3 additions & 3 deletions guides/hosting/infrastructure/message-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,17 @@ Sometimes, it also makes sense to route messages to a different transport to lim

### Message bus

The message bus is used to dispatch your messages to your registered handlers. While dispatching your message, it loops through the configured middleware for that bus. The message bus used inside Shopware can be found under the service tag `messenger.bus.shopware`. It is mandatory to use this message bus if your messages should be handled inside Shopware. However, if you want to send messages to external systems, you can define your custom message bus for that.
The message bus is used to dispatch your messages to your registered handlers. While dispatching your message, it loops through the configured middleware for that bus. The message bus used inside Shopware can be found under the service tag `messenger.bus.default`. It is mandatory to use this message bus if your messages should be handled inside Shopware. However, if you want to send messages to external systems, you can define your custom message bus for that.

You can configure an array of buses and define one default bus in your `framework.yaml`.

```yaml
// <platform root>/src/Core/Framework/Resources/config/packages/framework.yaml
framework:
messenger:
default_bus: messenger.bus.shopware
default_bus: my.messenger.bus

Check warning on line 174 in guides/hosting/infrastructure/message-queue.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] guides/hosting/infrastructure/message-queue.md#L174

You’ve repeated a verb. Did you mean to only write one of them? (REPEATED_VERBS[1]) Suggestions: `bus`, `buses` Rule: https://community.languagetool.org/rule/show/REPEATED_VERBS?lang=en-US&subId=1 Category: GRAMMAR
Raw output
guides/hosting/infrastructure/message-queue.md:174:34: You’ve repeated a verb. Did you mean to only write one of them? (REPEATED_VERBS[1])
 Suggestions: `bus`, `buses`
 Rule: https://community.languagetool.org/rule/show/REPEATED_VERBS?lang=en-US&subId=1
 Category: GRAMMAR
buses:
messenger.bus.shopware:
my.messenger.bus:
```

For more information on this check the [Symfony docs](https://symfony.com/doc/current/messenger/multiple_buses.html).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SmsNotification implements AsyncMessageInterface

## Send a message

After we've created our notification, we will create a service that will send our `SmsNotification`. We will name this service `ExampleSender`. In this service we need to inject the `Symfony\Component\Messenger\MessageBusInterface`, that is needed to send the message through the desired bus, which is called `messenger.bus.shopware`.
After we've created our notification, we will create a service that will send our `SmsNotification`. We will name this service `ExampleSender`. In this service we need to inject the `Symfony\Component\Messenger\MessageBusInterface`, that is needed to send the message through the desired bus, which is called `messenger.default_bus`.

```php
// <plugin root>/src/Service/ExampleSender.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ For each defined bus in our `framework.yaml`, we can define the middleware that
// <platform root>/src/Core/Framework/Resources/config/packages/framework.yaml
framework:
messenger:
default_bus: messenger.bus.shopware
buses:
messenger.bus.default:
middleware:
- 'Swag\BasicExample\MessageQueue\Middleware\ExampleMiddleware'
- 'Swag\BasicExample\MessageQueue\Middleware\AnotherExampleMiddleware'
messenger.bus.default:
middleware:
- 'Swag\BasicExample\MessageQueue\Middleware\ExampleMiddleware'
- 'Swag\BasicExample\MessageQueue\Middleware\AnotherExampleMiddleware'
```
## More interesting topics
Expand Down

0 comments on commit f8eb707

Please sign in to comment.