-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger][Scheduler] Add AsCronTask & AsPeriodicTask attributes #51525
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&rd 8000 quo;, 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
Conversation
fd2967e
to
d6a2819
Compare
What could also be a cool feature here is add |
This looks nice! I'll give a proper review and help finish up for 6.4 when I have some time. What are you thinking for commands? I was thinking: #[AsCronTask(expression: '* * * * *', arguments: 'arg --option')]
class MyCommand extends Command
{
} |
I was hoping we don't need such, as business logic usually is wrapped in a separate class and commands just act as an entry point, just like controllers. But I think this is only my reality. About the attribute syntax for commands, |
Looking good! Glad you got commands working - using |
6341a0a
to
cd499ee
Compare
Hmm, ok it does not seem possible after all, if transportNames are not defined, then the message is not dispatched to any transport – unlike the Messenger docs are stating. |
cd499ee
to
ed27b20
Compare
Thank you @valtzu. |
@@ -10,6 +10,9 @@ services: | |||
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummySchedule: | |||
autoconfigure: true | |||
|
|||
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyTask: | |||
autoconfigure: true |
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.
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.
@fabpot I'm not too familiar with the framework tests yet, and I'm also a bit busy now. I would need a week or two, if that's ok then I can try.
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.
Sure, there is no rush. Ping me if you need help.
… schedule (valtzu) This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle][Scheduler] Add test for autoconfigured schedule | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT Add functional tests for autoconfigured schedules / tasks, as discussed in #51525 (comment). Commits ------- ea2a8cd Add test for autoconfigured schedule
… schedule (valtzu) This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle][Scheduler] Add test for autoconfigured schedule | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT Add functional tests for autoconfigured schedules / tasks, as discussed in symfony/symfony#51525 (comment). Commits ------- ea2a8cd7255 Add test for autoconfigured schedule
… Symfony command (W0rma) This PR was merged into the 6.4 branch. Discussion ---------- [Scheduler] Add example about how to pass arguments to a Symfony command We recently wanted to pass arguments to a Symfony command which is configured for the scheduler component with the `#[AsPeriodicTask]` attribute. The syntax mentioned in symfony/symfony#51525 (comment) worked. This PR adds an example to the docs. Commits ------- fc90d83 [Scheduler] Add example about how to pass arguments to a Symfony command
Simplify scheduler usage by allowing to declare an attribute
AsCronTask
/AsPeriodicTask
on any registered & autoconfigured service.Example usage:
bin/console debug:schedule
output:And then run
bin/console messenger:consume scheduler_default
to run the scheduler, like the usual.To-do (help needed):
RecurringMessage
s using DI)