How to register a workflow with constructor parameters?

Hi,

I can’t seem to find examples of where a workflow has a constructor with parameters in Java. I have a case where I need to pass in some parameters. There are two places:

  1. Where you register the workflow
  2. Where you create the workflow via newWorkflowStub

In both cases how would you pass in the constructor parameters.

Thanks,
Derek

It is not supported as workflow constructor parameters can easily break workflow code determinism.

What are the parameters you are trying to pass to the workflow?

In my workflow, I have an activity that will publish some data to a datastore. However, when testing in dev environment (local), I want to disable this activity since it is only need to staging/prod. In this case, I want to be able to pass in a configuration or some sort of flag that will tell what environment it is.

I would rather mock the activity to be noop instead of changing the workflow logic.

This wouldn’t be in a unit test. How would you mock out the activity in the code?

You either register a different activity implementation with the worker based on config or let the activity implementation behave differently based on config. Passing config to an activity implementation object is fully supported.

If you still want to affect the workflow execution based on config then load the config through an activity or a SideEffect.