Hello,
I am trying to run temporal with spring boot. I have annotated my activities in temporal workflow with @Component. However have used no annotation on workflow.
When I try to run activity from workflow, I run into this exception which says
IllegalStateException("Operation allowed only while eventLoop is running");
@WorkflowInterface
public interface SampleWorkflow {
@WorkflowMethod
void startWorkflow(final Request workflowRequest);
}
public void startWorkflow(final Request workflowRequest) {
WorkflowOptions workflowOptions = WorkflowOptions
.newBuilder()
.setWorkflowId("SampleWorkflow")
.setTaskQueue("SampleQueue")
.build();
InvestCryptoReconWorkflow workflow = workflowClient.newWorkflowStub(SampleWorkflow.class, workflowOptions);
WorkflowClient.start(workflow::startWorkflow, workflowRequest);
}
PersistenceActivity is persisting a new record in database.
@Override
public void startWorkflow(final Request workflowRequest) {
try {
persistenceActivity = Workflow.newLocalActivityStub(PersistenceActivity.class, LocalActivityOptions
.newBuilder()
.setScheduleToCloseTimeout(Duration.ofSeconds(5))
.build()
);
persistenceActivity.saveRecord("hello", "world");
} catch (Exception e) {
log.error("Unable to run workflow due to " + e.getMessage());
}
}
I am not sure if this is due to spring boot or due to workflow. What are the best practices when using temporal with springboot ?
Exception Stacktrace
java.lang.RuntimeException: LocalActivity: failure executing MARKER_COMMAND_CREATED->RECORD_MARKER, transition history is [CREATED->CHECK_EXECUTION_STATE, EXECUTING->SCHEDULE, REQUEST_PREPARED->MARK_AS_SENT, REQUEST_SENT->HANDLE_RESULT]
io.temporal.internal.statemachines.StateMachine.executeTransition(StateMachine.java:140)
io.temporal.internal.statemachines.StateMachine.handleCommand(StateMachine.java:101)
io.temporal.internal.statemachines.EntityStateMachineBase.handleCommand(EntityStateMachineBase.java:51)
io.temporal.internal.statemachines.CancellableCommand.handleCommand(CancellableCommand.java:63)
io.temporal.internal.statemachines.WorkflowStateMachines.prepareImpl(WorkflowStateMachines.java:339)
io.temporal.internal.statemachines.WorkflowStateMachines.prepareCommands(WorkflowStateMachines.java:322)
io.temporal.internal.statemachines.WorkflowStateMachines.handleLocalActivityCompletion(WorkflowStateMachines.java:693)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.waitAndProcessLocalActivityCompletion(ReplayWorkflowRunTaskHandler.java:316)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.processLocalActivityRequests(ReplayWorkflowRunTaskHandler.java:292)
io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTask(ReplayWorkflowRunTaskHandler.java:151)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTaskWithEmbeddedQuery(ReplayWorkflowTaskHandler.java:201)
io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:114)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:319)
io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:279)
io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
Caused By: io.temporal.internal.sync.PotentialDeadlockException: Potential deadlock detected: workflow thread "workflow-method" didn't yield control for over a second. Other workflow threads:
com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap.<init>(ReadOnlyClassToSerializerMap.java:32)
com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap.from(ReadOnlyClassToSerializerMap.java:55)
com.fasterxml.jackson.databind.ser.SerializerCache._makeReadOnlyLookupMap(SerializerCache.java:62)
com.fasterxml.jackson.databind.ser.SerializerCache.getReadOnlyLookupMap(SerializerCache.java:54)
com.fasterxml.jackson.databind.SerializerProvider.<init>(SerializerProvider.java:233)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.<init>(DefaultSerializerProvider.java:70)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.<init>(DefaultSerializerProvider.java:614)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.createInstance(DefaultSerializerProvider.java:628)
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.createInstance(DefaultSerializerProvider.java:606)
com.fasterxml.jackson.databind.ObjectMapper._serializerProvider(ObjectMapper.java:4389)
com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4407)
com.fasterxml.jackson.databind.ObjectMapper.writeValueAsBytes(ObjectMapper.java:3685)
io.temporal.common.converter.JacksonJsonPayloadConverter.toData(JacksonJsonPayloadConverter.java:58)
io.temporal.common.converter.DefaultDataConverter.toPayload(DefaultDataConverter.java:117)
io.temporal.common.converter.DefaultDataConverter.toPayloads(DefaultDataConverter.java:157)
io.temporal.internal.sync.SyncWorkflowContext.executeLocalActivityOnce(SyncWorkflowContext.java:267)
io.temporal.internal.sync.SyncWorkflowContext.lambda$executeLocalActivity$8761989b$1(SyncWorkflowContext.java:260)
io.temporal.internal.sync.SyncWorkflowContext$Lambda$1034/1041228117.apply(Unknown Source)
io.temporal.internal.sync.WorkflowRetryerInternal.retryAsync(WorkflowRetryerInternal.java:232)
io.temporal.internal.sync.SyncWorkflowContext.executeLocalActivity(SyncWorkflowContext.java:258)
io.temporal.internal.sync.LocalActivityStubImpl.executeAsync(LocalActivityStubImpl.java:50)
io.temporal.internal.sync.ActivityStubBase.execute(ActivityStubBase.java:38)
io.temporal.internal.sync.LocalActivityStubImpl.execute(LocalActivityStubImpl.java:29)
io.temporal.internal.sync.LocalActivityInvocationHandler.lambda$getActivityFunc$0(LocalActivityInvocationHandler.java:72)
io.temporal.internal.sync.LocalActivityInvocationHandler$Lambda$1033/1050736163.apply(Unknown Source)
io.temporal.internal.sync.ActivityInvocationHandlerBase.invoke(ActivityInvocationHandlerBase.java:70)
com.sun.proxy.$Proxy155.saveTradeRecon(Unknown Source)
com.sofi.invest.crypto.recon.workflows.InvestCryptoReconWorkflowImpl.startTradeReconWorkflow(InvestCryptoReconWorkflowImpl.java:52)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
io.temporal.internal.sync.POJOWorkflowImplementationFactory$POJOWorkflowImplementation$RootWorkflowInboundCallsInterceptor.execute(POJOWorkflowImplementationFactory.java:338)
io.temporal.internal.sync.POJOWorkflowImplementationFactory$POJOWorkflowImplementation.execute(POJOWorkflowImplementationFactory.java:296)
io.temporal.internal.sync.WorkflowExecuteRunnable.run(WorkflowExecuteRunnable.java:53)
io.temporal.internal.sync.SyncWorkflow.lambda$start$0(SyncWorkflow.java:133)
io.temporal.internal.sync.SyncWorkflow$Lambda$1032/1288652219.run(Unknown Source)
io.temporal.internal.sync.CancellationScopeImpl.run(CancellationScopeImpl.java:101)
io.temporal.internal.sync.WorkflowThreadImpl$RunnableWrapper.run(WorkflowThreadImpl.java:107)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)