I’m setting up a scheduled tasks scheme in spring, using the task namespace.
I want to schedule most tasks to fire according to a cron expression, and some to fire just once, a fixed delay after startup, and then never again (i.e. what setting repeatCount to 0 on a SimpleTriggerBean would achieve).
Is it possible to achieve this within the task namespace, or do I need to revert to defining beans for my triggers?
If you have a look at the Task namespace XSD, you’ll see that there are only three different configuration types:
fixed-delay,fixed-rateandcron.And if you look at the source of ScheduledTasksBeanDefinitionParser, you’ll see that no more than one of these values are evaluated. Here is the relevant part:
So there is no way to combine these attributes. In short: the namespace won’t get you there.