[Messenger][Scheduler] Add AsCronTask & AsPeriodicTask attributes#51525
[Messenger][Scheduler] Add AsCronTask & AsPeriodicTask attributes#51525fabpot merged 1 commit intosymfony:6.4from
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. |
| autoconfigure: true | ||
|
|
||
| Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyTask: | ||
| autoconfigure: true |
There was a problem hiding this comment.
@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.
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/AsPeriodicTaskon any registered & autoconfigured service.Example usage:
bin/console debug:scheduleoutput:And then run
bin/console messenger:consume scheduler_defaultto run the scheduler, like the usual.To-do (help needed):
RecurringMessages using DI)