Passing ActivityOptions task queue from configuration

We are using the spring boot starter and we are looking for a way to pass task queue name from the application configuration into ActivityOptions in a workflow implementation.
The activity task queue is different from the workflow task queue.
How is it possible to do that?

Would like to get your suggestion on how to make this easier but here is one way, let’s say you have in your application.yaml:

    namespace: default
      target: localhost:7233
      - task-queue: WorkflowTaskQueue
          - my.workflows.MyWorkflowImpl
      - task-queue: ActivityTaskQueue
        name: ActivityWorker
          - MyActivities

So WorkflowWorker will have only workflows registered and ActivityWorker just activities.

In your workflow impl you can define then:

@WorkflowImpl(taskQueues = "WorkflowTaskQueue")
public class MyWorkflowImpl implements MyWorkflow, ApplicationContextAware {
    private ApplicationContext ctx;

    public String yourWorkflowMethod() {
       TemporalProperties props = ctx.getBean(TemporalProperties.class);

       Optional<WorkerProperties> wp =
              props.getWorkers().stream().filter(w -> w.getName().equals("ActivityWorker")).findFirst();
       String taskQueue = wp.get().getTaskQueue();
      // apply taskQueue to your ActivityOptions when you create ActivityStub...

      public void setApplicationContext(ApplicationContext appContext)
              throws BeansException {
          ctx = appContext;

Note you have to use ApplicationContextAware as AutoWire would not work inside workflow impl (it’s not component).

This will become I think easier when we implement feature: Allow WorkflowImplementationOptions to be set via config for Spring Boot · Issue #1647 · temporalio/sdk-java · GitHub

Looks good!
Will give it a try

Worked well!
How it can be done if the activity implementation is on another service?

You can do it typed or untyped way. For typed your service only needs the activity interface and the impl can be on service B, then use normal activity stub.
Another approach is untyped where you use UntypedActivityStub and use the activity type name.
Let me know if you need example.