Hello,
I have met some problems while implementing background jobs.
My use case:
In main workflow, execute sql upsert in Activity1. After that, start a background job in Activity2 (Async background jobs, no need to cut into main workflow no matter what the response is). Then end the workflow.
My current implementation:
public interface ActivityOne {
void dbUpsert();
}
public interface ActivityTwo {
void doSomething();
}
public class MainWorkflow {
void letsgo() {
activityOne.dbUpsert();
// If the async task is the last step, it never executes
Async.procedure(ActivityTwo::doSomething);
}
}
but async task never executes.
If I try adding an empty activity after Async Activity, it works:
public interface ActivityOne {
void dbUpsert();
}
public interface ActivityTwo {
void doSomething();
}
public class MainWorkflow {
void letsgo() {
activityOne.dbUpsert();
// Async task runs as expected
Async.procedure(ActivityTwo::doSomething);
activityThree.empty();
}
}
Is it a bug or it’s designed deliberately? And what’s the best practice for background running jobs.