Running a workflow at Scheduled Times under Spring

41 views
Skip to first unread message

Ron Schultz

unread,
Apr 21, 2021, 4:32:46 PM4/21/21
to COPPER Engine
Is there an approach or example to schedule the running of a Copper workflow, or a method within a Copper workflow, using the Spring @Scheduled annotation?

I was looking to do something like the following within my workflow:

@Scheduled(fixedDelay=60000)
public void main() throws Interrupt {
// Perform my application logic here
}

Regards,
Ron


Michael Austermann

unread,
Apr 22, 2021, 2:22:56 AM4/22/21
to copper...@googlegroups.com
It's not as simple as with an annotation, but you could use the following approach:

public void main() throws Interrupt {
    for(;;) {
// Perform my application logic here
// sleep for one minute 
wait(WaitMode.ALL, 60000, getEngine().createUUID());
    }
}

An instance of this workflow would run vor ever.

If it's a persistent workflow, you have to keep two things in mind:
- make sure that the workflow is lauched only once, because it will survive process restarts.
- if the workflow changes in the future, you may have to delete its "stale" instance in the database, before launching the new version

/Michael


Von: "Ron Schultz" <rcasc...@gmail.com>
An: "COPPER Engine" <copper...@googlegroups.com>
Gesendet: Mittwoch, 21. April 2021 22:32:45
Betreff: [COPPER Users] Running a workflow at Scheduled Times under Spring

--
You received this message because you are subscribed to the Google Groups "COPPER Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copper-engin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copper-engine/c23dc74a-84bb-4e13-a1f0-be67911f3e48n%40googlegroups.com.

cka...@gmail.com

unread,
Apr 27, 2021, 3:41:39 PM4/27/21
to COPPER Engine
Hi Ron,

Just saw this message together with the previous one, I think I might know what you are trying to do and I want to say a few words.

I have been there trying to use copper to make Persistent schedulers, such that the work would resume even if the application goes down before the task could finish. Now that I think back, I think it's a bit over engineering.
I think we shouldn't rely on the engine to persistent the data in flow, rather we should make the services more robust so that it could pick up from where it left-off last time. 

In other words, put the smartness inside the services instead of relying on the engine, since it's more overhead and might introduce data consistency issue - the data kept in your workflow might be changed in other places and you don't know it.

Cheers,

Howie

Reply all
Reply to author
Forward
0 new messages