cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger a CronScheduledQueryBasedTemplateActionDefinition?

hbf
Champ on-the-rise
Champ on-the-rise
Hi list,

I have a scheduled action that is run via cron. I've implemented it in Java and configured it as indicated on the wiki. This works perfectly.

Is there a way, besides the automatic scheduling by cron, to programatically execute the job once? I mean: to execute it once in addition to the executions scheduled by cron.

Of course, I can run the action on a specific node, but I'd like to have the whole query executed and have all the resulting actions run. Is there a way to do this?

Many thanks!
Kaspar
4 REPLIES 4

hbf
Champ on-the-rise
Champ on-the-rise
Looking closer at the code (CronScheduledQueryBasedTemplateActionDefinition.java), it seems that one way to go would be to subclass CronScheduledQueryBasedTemplateActionDefinition and override getTrigger() to not create a CronTrigger but a SimpleTrigger. I would then have two "scheduled actions" in my configuration XML files: one for the cron job and another one for the SimpleTrigger. However, I am not sure how exactly this works: just setting/replaceing the trigger is probably not enough and I need to re-register the trigger with the scheduler. But how?

If the above is not an option, how can my service create a new "worker thread" with its own transaction to programatically select the nodes and work through them? Is there an example available? Maybe an already existing Alfresco Service I could take a look at?

Thanks,
Kaspar

andy
Champ on-the-rise
Champ on-the-rise
Hi

Is the requirement to run the job at application start up and then as defined by cron?

Andy

hbf
Champ on-the-rise
Champ on-the-rise
Is the requirement to run the job at application start up and then as defined by cron?
Actually, I need both ;-).

On the one hand, my custom service (for this) has a public method to schedule a cron job now (in addition to the normal running times).

On the other hand, I've run into the need to run a transaction (not necessarily a cron job) after module startup, see this post.

Kaspar

andy
Champ on-the-rise
Champ on-the-rise
Hi

I believe you should add extension bootstrap beans for amp initialisation.
See the RM amp for an example and the bootstrap context for where bootstrap extensions are found.

Andy