# Passing ActivityOptions task queue from configuration

**URL:** https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600
**Category:** Community Support
**Tags:** java-sdk
**Created:** [September 25, 2023, 2:55pm UTC](https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600 "2023-09-25T14:55:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_Fainshtein1](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/alex_fainshtein1/32/4343_2.png) [@Alex\_Fainshtein1](https://community.temporal.io/u/Alex_Fainshtein1)
#### Post date: [September 25, 2023, 2:55pm UTC](https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600/1 "2023-09-25T14:55:35Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)
#### Post date: [September 26, 2023, 2:49pm UTC](https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600/3 "2023-09-26T14:49:06Z")

</div>

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:

```auto
temporal:
    namespace: default
    connection:
      target: localhost:7233
    workers:
      - task-queue: WorkflowTaskQueue
        name:WorkflowWorker
        workflow-classes:
          - my.workflows.MyWorkflowImpl
        activity-beans:
      - task-queue: ActivityTaskQueue
        name: ActivityWorker
        workflow-classes:
        activity-beans:
          - MyActivities

```

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

In your workflow impl you can define then:

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

    @Override
    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...
    }

  @Override
      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](https://github.com/temporalio/sdk-java/issues/1647)

---

<div class="post-metadata">

### Author: ![Alex\_Fainshtein1](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/alex_fainshtein1/32/4343_2.png) [@Alex\_Fainshtein1](https://community.temporal.io/u/Alex_Fainshtein1)
#### Post date: [September 26, 2023, 3:37pm UTC](https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600/5 "2023-09-26T15:37:30Z")

</div>

Looks good!  
Will give it a try

---

<div class="post-metadata">

### Author: ![Alex\_Fainshtein1](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/alex_fainshtein1/32/4343_2.png) [@Alex\_Fainshtein1](https://community.temporal.io/u/Alex_Fainshtein1)
#### Post date: [September 27, 2023, 12:54pm UTC](https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600/6 "2023-09-27T12:54:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)
#### Post date: [September 27, 2023, 8:37pm UTC](https://community.temporal.io/t/passing-activityoptions-task-queue-from-configuration/9600/7 "2023-09-27T20:37:06Z")

</div>

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.
