Passing application.properties to temporal workflow

public class OrderFulfillmentWorkflowImpl implements OrderFulfillmentWorkflow {

  private Logger logger = Workflow.getLogger(this.getClass().getName());

  private final ActivityOptions shippingActivityOptions =
      ActivityOptions.newBuilder()
          .setStartToCloseTimeout(Duration.ofMinutes(1))
          .setTaskQueue(TaskQueue.SHIPPING_ACTIVITY_TASK_QUEUE.name())
          .setRetryOptions(RetryOptions.newBuilder().setMaximumAttempts(3).build())
          .build();
}

this snippet is from:

The requirement is to get the minutes from property file(application.properties from spring context). I know that this is possible through the spring context. But this is specific to temporal issue.

Please consider that the workflow implementation is not managed by the spring context.

Run local activity which can be a @Component and can return result thats annotated with @Value.

1 Like

Sorry, I am not sure if I understood the answer correctly.

The localActivity would not have been started yet. Here we are actually trying to load the activity properties and then start the workflow by passing in the workflow options.

What I understood was Workflow always have to start the Activity while it is getting constructed. It is not a good practice to pass the configuration as arguments to workflow method too, as then the arguments can change which would break the idempotency rule.

Also, workflow can never be a bean, so we cannot get anything from application context.

Would you explain what you mean by this? There is no requirement to invoke activities (or create their stubs) during construction. It can be done at any time during the workflow’s execution.