io.temporal.workflow.Workflow.newTimer(Duration.parse("PT5S")); raises exception

Hi,

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”

Any suggestions?

Thanks,

Kasi

In which method of the workflow are you calling newTimer function? Would you post the full stack trace of the exception?

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.

Thanks,

Kasi

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

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.

Workflow.sleep throws the same exception.

Then to help you we need at least the exception stack trace.

Hi Maxim,

Here is a snapshot of the error, can we webex for 10 minutes on this?

Thanks,

Kasi

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);
    }

running into same issue.

Thanks,

Kasi

I did the same change to the HelloAtivity and it runs fine for me. Would you point me to the repository with the code that reproduces your issue?