Distributed Activities invoking from same workflow

I am new to Temporal and I have order application implementation where there is workflow(microservice) and there are various activities(microservices) which are invoked from the workflow service as shown below.


  1. Is this right expectation to have shared activity, if yes then how do I register activities? ( I get error if I do as below on same queue for all activities associated with a WF in a namespace)

microservice 1.1

Worker worker = factory.newWorker("OrderQueue");
   worker.registerWorkflowImplementationTypes(Workflow1.class, Workflow2.class, ChildWorkflow.class );

microservice 1.2

Worker worker = factory.newWorker("OrderQueue");
        worker.registerActivitiesImplementations(activity<1&2>, activity3);

shared microservice 1.3

Worker worker = factory.getWorker("OrderQueue");
  1. Is it right expectation to have WF and Activities in different services at all? If yes then how to perform unit testing on standalone activities? since I don’t get WF implementation class in standalone activity.

To invoke an activity or a child workflow, you need only their interface, not their implementation. So there is no need to register an activity or child workflow implementation with a worker that implements a workflow that calls it. It is also possible to call an activity or a child workflow by its string name if you want to avoid sharing any code.

Each service should listen to a different task queue. In the code snippets you posted, all the services listen to the same task queue, which is not going to work.

When creating the correspondent stub, You must specify the correct task queue using ActivityOptioins and the ChildWorkflowOptions.

BTW the diagram shows an activity creating a child workflow. Only workflows can create child workflows.

Thanks for correcting my concept, my queue issue is solved. However, can you elaborate on testing activity with string name. Below is my spring boot activity service implementation. Even if I am able to mock activity, I get stuck with completionClient mocking. One or the other is not fitting

public class OrderActivityImpl implements OrderActivity {

      private String path;

    private ManualActivityCompletionClient completionClient;
    private final WebClient springWebClient;

    public void getOrdersActivityMethod() {
        completionClient = Activity.getExecutionContext().useLocalManualCompletion();
                .subscribe(completionClient::complete, t -> completionClient.fail(Activity.wrap(t)));

my test class here

class OrderActivityImplTest {
    private static WireMockServer wireMockServer;

    private OrderActivity service;
   private TestActivityEnvironment testEnvironment;

    private WebClient getWebClientWireMock(int port) {
        return WebClient.builder().baseUrl("http://localhost:" + port).build();

    void setUp() {
        wireMockServer = new WireMockClassRule(Options.DYNAMIC_PORT);
        service = new OrderActivityImpl(getWebClientWireMock(wireMockServer.port()));
        ReflectionTestUtils.setField(service, "path", "/orders");
        testEnvironment = TestActivityEnvironment.newInstance();

    void test(TestActivityEnvironment env) {
        OrderActivity activity = testEnvironment.newActivityStub(OrderActivity.class);

    void tearDown() {

error I get

java.lang.NullPointerException: Cannot invoke “io.temporal.internal.worker.ActivityTaskHandler$Result$TaskFailedResult.getTaskFailedRequest()” because the return value of “io.temporal.internal.worker.ActivityTaskHandler$Result.getTaskFailed()” is null