Can we use query for some update in business data in workflow execution?

Since workflow right now has no update yet, I wonder if we can use query as an update in some scenarios. For example, we have a blocking queue in workflow definition and the workflow execution is waiting on the getting message from the queue. And the query we want to validate and enqueue a message and return if the message is valid to the caller. (Signal cannot return data)

Does this case violates the rule of " * It can not modify Workflow state in any way." And I am actually not very sure what does this rule mean.

Yes, it violates It can not modify Workflow state in any way. rule. So the proposed solution is not possible.

So I guess the handlings of query and signal are totally different to make the case. Does anyone share a summary on the mechanics that result in this OR where is the code to read (I guess it is in the go-SDK handling of query/signal).

Note that we are working on the update feature that would be like a query that can mutate workflow state.

I have a follow-up question here. I guess the query event doesn’t get replayed in the workflow execution so it cannot change the internal states. Am I correct?

Another reason I am asking this question is we are doing a major re-construction of a first workflow definition and we want to remove old queries (clients will not call the queries except the history queries).

@maki_XIE queries are not written in event history.

You can test whether your workflow implementation is compatible with the running workflows with WorkflowReplayer functionality. Here an example samples-java/HelloActivityReplayTest.java at main · temporalio/samples-java · GitHub

1 Like

Removing and adding queries is backward compatible.