# Reusable components

**URL:** <https://community.temporal.io/t/reusable-components/7203>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [February 7, 2023, 5:22pm UTC](https://community.temporal.io/t/reusable-components/7203 "2023-02-07T17:22:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendryt](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/hendryt/32/3305_2.png) [@hendryt](https://community.temporal.io/u/hendryt)\
**Post date:** [February 7, 2023, 5:22pm UTC](https://community.temporal.io/t/reusable-components/7203/1 "2023-02-07T17:22:55Z")

</div>

I am wanting to have some reusable components (workflows/activities) for example have a workflow to raise a request in a request system, but I want to make it available to other workflows that will not be in the same application.  
so I have the following questions:

- Can I call a child workflow that has the worker running from another application to the client?
- Can I call an activity that is attached to a worker of another application to the client?
- Which is better assuming I can do either, child workflow or activity?

thank you

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [February 7, 2023, 6:06pm UTC](https://community.temporal.io/t/reusable-components/7203/3 "2023-02-07T18:06:21Z")

</div>

Hello @hendryt

> - Can I call a child workflow that has the worker running from another application to the client?

Yes, if the worker is different, ensure you set a different taskqueue for the childworkflow and have a worker listening to the taskqueue with the childWorkflow implementation.

If you don’t have access to the ChildWorklfow interface, you can create a `UntypedChildWorkflowStub`, see this example [https://github.com/tsurdilo/temporal-java-workshop/blob/b3f1d8e93238e0cb490cb24d681e482864653af5/src/main/java/io/workshop/c3s2/C3S2WorkflowImpl.java#L25](https://github.com/tsurdilo/temporal-java-workshop/blob/b3f1d8e93238e0cb490cb24d681e482864653af5/src/main/java/io/workshop/c3s2/C3S2WorkflowImpl.java#L25)

> - Can I call an activity that is attached to a worker of another application to the client?

Same as above.

If you don’t have access to the activity interface you can do

```auto

    private final ActivityStub activity =
        Workflow.newUntypedActivityStub(
            ActivityOptions.newBuilder().....build());

activity.execute(...)
//or

activity.executeAsync(...)

```

> - Which is better assuming I can do either, child workflow or activity?

What is your use case? what those childworkflows/activities have to do?

---

<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:** [February 8, 2023, 5:08am UTC](https://community.temporal.io/t/reusable-components/7203/4 "2023-02-08T05:08:43Z")

</div>

Just wanted to ask, i think you mean worker that polls on a separate task queues, right ? (you can have two workers each in different worker processes/apps that poll on same task queue as well, both would need to have all workflows and activities registered tho).

> - Which is better assuming I can do either, child workflow or activity?

If all the ChildWorklfow would do is invoke the activity (so no other business logic) and you dont need to set specific activity configs (so letting activity config being set in workflow is ok), then think you should invoke the activity directly.

---

<div class="post-metadata">

**Author:** ![hendryt](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/hendryt/32/3305_2.png) [@hendryt](https://community.temporal.io/u/hendryt)\
**Post date:** [February 10, 2023, 1:09pm UTC](https://community.temporal.io/t/reusable-components/7203/5 "2023-02-10T13:09:01Z")

</div>

This is a diagram of what I am trying to do.

 ![Onboarding Orechestration](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/7/71b8739f517fc89bb98081574f352ec69d6409ab.png)

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 10, 2023, 3:18pm UTC](https://community.temporal.io/t/reusable-components/7203/6 "2023-02-10T15:18:40Z")

</div>

You can implement this by using different task queue for each “system” workflow. Then when you have to specify the correct task queue name when creating the child workflow stub. For example:

```auto
      RequestSystemWorkflow requestSystem =
          Workflow.newChildWorkflowStub(
              RequestSystemWorkflow.class,
              ChildWorkflowOptions.newBuilder().setTaskQueue("request-system").build());

```
