lightbend / kalix-jvm-sdk

Java and Scala SDKs for Kalix
https://docs.kalix.io/java/index.html
Other
58 stars 39 forks source link

Workflows: access to workflowId from the step definition. #1753

Open aludwiko opened 1 year ago

aludwiko commented 1 year ago

Such code:

    Step withdraw =
        step("withdraw")
            .asyncCall(Withdraw.class, cmd -> {
              String workflowId = commandContext().workflowId();
              ...
            })

will throw an exception:

kalix.javasdk.impl.WorkflowExceptions$WorkflowException: unexpected exception [CommandContext is only available when handling a command.] while executing step [withdraw]
    at kalix.javasdk.impl.WorkflowExceptions$WorkflowException$.apply(WorkflowExceptions.scala:43)
    at kalix.javasdk.impl.workflow.WorkflowImpl.$anonfun$runWorkflow$6(WorkflowImpl.scala:323)
    at akka.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1430)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:542)
    at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:423)
    at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:650)

we should be able to access WorkflowContext from the step definition and execution.

antagonist112358 commented 2 weeks ago

@aludwiko - I randomly found this bug while looking through the backlog. It appears this is fixed in "later" (at least latest) versions of the SDK. I think we can close this as "done".

aludwiko commented 2 weeks ago

It appears this is fixed in "later"

sorry, I find it hard to load this context, where do you see the fix?