Workflow handle caching

Hey,

We have a use case where we need to send constant signals to a workflow from a kafka consumer. For this purpose we are caching the workflow handle in our application and reusing it as needed and invalidating the cached workflow handle if and when send signal gives an exception. However, when trying to emulate this by doing the following:

  1. Start workflow
  2. Send signal; cache workflow handle
  3. Stop workflow; cached handle should become stale
  4. Start workflow again
  5. Send signal again
  6. Expected : Signal request failed due to stale workflow handle
    Actual : Signal request works successfully

My question is that is this expected? Is the workflow handle just a lightweight object which doesnt really hold any connection information; which is why it doesnt seem to give any issues when using stale handle?

Exactly. A workflow handle is just a helper class so you can have workflow-specific, typed methods by their ID (and optionally run ID). Obtaining a workflow handle does not make any client calls, hence why it is not async. It is just a “reference” or “pointer” or “handle” if you will. The only way to know if a handle represents a valid workflow is to make a call on it (e.g. get_result() or describe()).