0

Query - Query is to expose this internal state to the external world. A query is exposed as an asynchronous callback that is invoked by external entities.

What do you mean by asynchronous callback?

And Doc says, Query has two limitations 1). Should not mutate the state of a Workflow 2). There won't be any blocking operation.

@Override
    public String queryGreeting() {
      greeting = "val";
      return greeting;
    }

But I did mutate the variable in the query method and It is changing the value.

Is it just a conviction that we should not write mutable or blocking code inside query method?

I didn't see any difference between query and signal. A query method will be called even after the completion of a workflow where as Signal won't?

Is my understanding correct?

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219

1 Answers1

0

The query should not mutate workflow variables. This is going to break workflow recovery.

The signal can mutate any workflow data as well as invoke blocking operations like activities.

Maxim Fateev
  • 6,458
  • 3
  • 20
  • 35
  • Thanks for the response!! Sorry, I mistyped it. It is synchronous callback not asynchronous. What does it mean? (query is exposed as a synchronous callback) – Anil Kumble May 18 '21 at 19:11
  • It means that the query caller blocks until the query function returns. – Maxim Fateev May 18 '21 at 20:19