Camunda Platform 8 - Executable BPMN with 2 pools

I’m trying to use 2 pools and generate a new instance of my process, the following image shows whatmy process currently is

To send the message, I’m using this code in Java

package io.camunda.getstarted.tutorial;
import java.util.HashMap;
import java.util.Map;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.impl.ZeebeClientBuilderImpl;
import io.camunda.zeebe.client.impl.oauth.OAuthCredentialsProvider;
import io.camunda.zeebe.client.impl.oauth.OAuthCredentialsProviderBuilder;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.spring.client.EnableZeebeClient;
import io.camunda.zeebe.spring.client.annotation.ZeebeWorker;

@SpringBootApplication
@EnableZeebeClient
public class Worker {
  private static final String zeebeAPI = "fbe78958-209f-4daa-8278-3d81bf161e06.bru-2.zeebe.camunda.io";
  private static final String clientId = "z5jW~eX.ShwRx7G1S5pBmUEZW-a4wMdk";
  private static final String clientSecret = "ClientSecret";
  private static final String oAuthAPI = "https://login.cloud.camunda.io/oauth/token";
  ZeebeClient client;

  public static void main(String[] args) {
   
    SpringApplication.run(Worker.class, args);
  }
  
  @ZeebeWorker(type = "orchestrate-something", autoComplete = true)
  public Map<String, Object> orchestrateSomething(final ActivatedJob job) {
      // Do the business logic
      System.out.println("Yeah, now you can orchestrate something :-) You could use data from the process variables: " + job.getVariables());

      // Probably add some process variables
      HashMap<String, Object> variables = new HashMap<>();
      variables.put("orderId", 42);
      
      OAuthCredentialsProvider credentialsProvider =
      new OAuthCredentialsProviderBuilder()
          .authorizationServerUrl(oAuthAPI)
          .audience(zeebeAPI)
          .clientId(clientId)
          .clientSecret(clientSecret)
          .build();

      ZeebeClient client =
      new ZeebeClientBuilderImpl()
              .gatewayAddress(zeebeAPI)
              .credentialsProvider(credentialsProvider)
              .build();
  
       client.newTopologyRequest().send().join();

       client
         .newPublishMessageCommand()
         .messageName("Money-collcted")
         .correlationKey("123")
         .send()
         .join();
     
        return variables;
  }

}

Both processes are checked as executable, but for some reason the token that should be generated in the second process is not generated =(

Can somebody help me with this?

Hello @Matheus_Pereira_de_A ,

thank you for creating a new thread.

First of all, I would like to ensure that you have no typo in your code in „money-collected“.

Then, you should find the process instance not in the same screen but under the other process definition (for the other pool).

I hope this helps

Jonathan

So, I think there is not typo because I’m correlating the message with the same name “Money-collcted”

1 Like

maybe, instead of doing this

I should create a new instance for the 2ºnd pool?

I just faced the same issue and it turns out the message start event can be called and a new process instance with a different process id started for that pool.

Seems like even though you designed two pools in the same page in the modeler, but they act as two different processes which is the same way you design different .bpmn files for each of the pool and deploy them separately.

In you case, you can check the completed instances in Operate as the [ManualTask] defined in the second pool is meaningless and will be completed directly.

1 Like

Hello @GgJinFWu ,

thank you for this answer. You are right, and the reason lies in the xml:

When you create one process and do not put a pool around it, you will have one process tag. This will be a process definition later in the engine.

As soon as you create a pool, you design a collaboration. Each participant of a collaboration will hold its own process tag. Then, the same as described above happens to each of them.

I hope this clarifies the behaviour more.

Jonathan