When I am trying to create a timer, using the above syntax I am seeing the following exception, I am trying to create a Delay of 5 seconds without an await condition
“java.lang.IllegalStateException: Operation allowed only while eventLoop is running”
in the starting workflow method, the first execution is introducing a timer delay,
startWorkflow is a workflow method,
public String startWorkflow(String data) {
// will have to call other activities and stuff here
System.out.println("Inside workflow");
this.data = data;
// we need a state machine which navigates thru the actions
io.temporal.workflow.Workflow.newTimer(Duration.parse("PT5S"));
The exception thrown is part of java.lang.reflect.InvocationTargetException.
I’ve just tested Workflow.newTimer and it worked fine for me. What is the stack trace of the IllegalStateException?
BTW. Workflow.newTimer(Duration.parse("PT5S")) returns a Promise that you are ignoring in the above sample, so your code is not going to block. Either call get on the returned promise or use Workflow.sleep.
Also, on a separate note, I used to be able to run the workflow in IDEA debugger, now I am seeing deadlock exception when running in debugger
Add TEMPORAL_DEBUG=true environment variable to disable the deadlock detector.
I made changes to existing HelloActivity from temporal samples project,
@Override
public String getGreeting(String name) {
// This is a blocking call that returns only after the activity has completed.
Workflow.sleep(Duration.parse("PT5S"));
Workflow.await(Duration.parse("PT5S"), () -> proceed);
return activities.composeGreeting("Hello", name);
}