-
-
Notifications
You must be signed in to change notification settings - Fork 504
Enable sync transport in messenger configuration #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Very little downside to enabling by default, as it's (almost) the same as not sending something through a transport at all.
|
Thanks for the PR 😍 How to test these changes in your application
Diff between recipe versionsIn order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. symfony/messenger4.1 vs 4.3diff --git a/symfony/messenger/4.1/config/packages/messenger.yaml b/symfony/messenger/4.3/config/packages/messenger.yaml
index c8078980..6b7319ce 100644
--- a/symfony/messenger/4.1/config/packages/messenger.yaml
+++ b/symfony/messenger/4.3/config/packages/messenger.yaml
@@ -1,9 +1,14 @@
framework:
messenger:
+ # Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
+ # failure_transport: failed
+
transports:
- # Uncomment the following line to enable a transport named "amqp"
- # amqp: '%env(MESSENGER_TRANSPORT_DSN)%'
+ # https://symfony.com/doc/current/messenger.html#transport-configuration
+ # async: '%env(MESSENGER_TRANSPORT_DSN)%'
+ # failed: 'doctrine://default?queue_name=failed'
+ # sync: 'sync://'
routing:
# Route your messages to the transports
- # 'App\Message\YourMessage': amqp
+ # 'App\Message\YourMessage': async
diff --git a/symfony/messenger/4.1/manifest.json b/symfony/messenger/4.3/manifest.json
index d0ff1732..dc045158 100644
--- a/symfony/messenger/4.1/manifest.json
+++ b/symfony/messenger/4.3/manifest.json
@@ -3,10 +3,13 @@
"config/": "%CONFIG_DIR%/"
},
"env": {
- "#1": "MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages"
+ "#1": "Choose one of the transports below",
+ "#2": "MESSENGER_TRANSPORT_DSN=doctrine://default",
+ "#3": "MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages",
+ "#4": "MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages"
},
"aliases": ["messenger"],
"conflict": {
- "symfony/framework-bundle": "<4.1"
+ "symfony/framework-bundle": "<4.3"
}
}
diff --git a/symfony/messenger/4.1/post-install.txt b/symfony/messenger/4.3/post-install.txt
index 6a2c8ade..8844fe7a 100644
--- a/symfony/messenger/4.1/post-install.txt
+++ b/symfony/messenger/4.3/post-install.txt
@@ -1,13 +1,11 @@
* You're ready to use the Messenger component. You can define your own message buses
- or start using the default one right now by injecting the messenger.bus.default service
- or typehinting Symfony\Component\Messenger\MessageBusInterface in your code.
+ or start using the default one right now by injecting the message_bus service
+ or type-hinting Symfony\Component\Messenger\MessageBusInterface in your code.
- * If you need to send messages to your broker, you can benefit from the built-in
- AMQP transport by:
+ * To send messages to a transport and handle them asynchronously:
- 1. Installing the AMQP pack by running composer require amqp;
- 2. Uncommenting the MESSENGER_TRANSPORT_DSN env var
- and framework.messenger.transports.amqp config;
- 3. Routing your messages to the amqp sender.
+ 1. Uncomment the MESSENGER_TRANSPORT_DSN env var in .env
+ and framework.messenger.transports.async in config/packages/messenger.yaml;
+ 2. Route your message classes to the async transport in config/packages/messenger.yaml.
- * Read the documentation at https://symfony.com/doc/master/messenger.html
+ * Read the documentation at https://symfony.com/doc/current/messenger.html4.3 vs 5.4diff --git a/symfony/messenger/4.3/config/packages/messenger.yaml b/symfony/messenger/5.4/config/packages/messenger.yaml
index 6b7319ce..ce25a11f 100644
--- a/symfony/messenger/4.3/config/packages/messenger.yaml
+++ b/symfony/messenger/5.4/config/packages/messenger.yaml
@@ -1,5 +1,8 @@
framework:
messenger:
+ # reset services after consuming messages
+ reset_on_message: true
+
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
diff --git a/symfony/messenger/4.3/manifest.json b/symfony/messenger/5.4/manifest.json
index dc045158..793ce278 100644
--- a/symfony/messenger/4.3/manifest.json
+++ b/symfony/messenger/5.4/manifest.json
@@ -4,9 +4,9 @@
},
"env": {
"#1": "Choose one of the transports below",
- "#2": "MESSENGER_TRANSPORT_DSN=doctrine://default",
- "#3": "MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages",
- "#4": "MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages"
+ "#2": "MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages",
+ "#3": "MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages",
+ "MESSENGER_TRANSPORT_DSN": "doctrine://default?auto_setup=0"
},
"aliases": ["messenger"],
"conflict": {5.4 vs 6.0diff --git a/symfony/messenger/5.4/config/packages/messenger.yaml b/symfony/messenger/6.0/config/packages/messenger.yaml
index ce25a11f..19db483d 100644
--- a/symfony/messenger/5.4/config/packages/messenger.yaml
+++ b/symfony/messenger/6.0/config/packages/messenger.yaml
@@ -1,8 +1,5 @@
framework:
messenger:
- # reset services after consuming messages
- reset_on_message: true
-
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
@@ -10,8 +7,16 @@ framework:
# https://symfony.com/doc/current/messenger.html#transport-configuration
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
- # sync: 'sync://'
+ sync: 'sync://'
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
+
+# when@test:
+# framework:
+# messenger:
+# transports:
+# # replace with your transport name here (e.g., my_transport: 'in-memory://')
+# # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
+# async: 'in-memory://'
diff --git a/symfony/messenger/5.4/post-install.txt b/symfony/messenger/6.0/post-install.txt
index 8844fe7a..186bec8a 100644
--- a/symfony/messenger/5.4/post-install.txt
+++ b/symfony/messenger/6.0/post-install.txt
@@ -4,8 +4,10 @@
* To send messages to a transport and handle them asynchronously:
- 1. Uncomment the MESSENGER_TRANSPORT_DSN env var in .env
+ 1. Update the MESSENGER_TRANSPORT_DSN env var in .env if needed
and framework.messenger.transports.async in config/packages/messenger.yaml;
- 2. Route your message classes to the async transport in config/packages/messenger.yaml.
+ 2. (if using Doctrine) Generate a Doctrine migration bin/console doctrine:migration:diff
+ and execute it bin/console doctrine:migration:migrate
+ 3. Route your message classes to the async transport in config/packages/messenger.yaml.
* Read the documentation at https://symfony.com/doc/current/messenger.html |
| # async: '%env(MESSENGER_TRANSPORT_DSN)%' | ||
| # failed: 'doctrine://default?queue_name=failed' | ||
| # sync: 'sync://' | ||
| sync: 'sync://' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about then moving it first ?
Very little downside to enabling by default, as it's (almost) the same as not sending something through a transport at all.