Hello, I’m new to Camunda 8 and I’m trying to configure a Receive Task with a simple BPMN model showed below:
I was able to use the Send Task by following the steps described here:
Currently, I have this Java project working, then, I tried to add the code to use the ReceiveTask and I ended up with my code like this:
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;
}
}
But when I execute a process instance, I can execute the SendTask, but the token keeps waiting on the ReceiveTask =( When I look at the terminal, I get no error, only the expected print “Yeah, now you can orchestrate…”:
I also tried to use the zbctl to publish the message. I tried using the following command:
zbctl publish message “Money-collcted” --correlationKey “order-123” --address “fbe78958-209f-4daa-8278-3d81bf161e06.bru-2.zeebe.camunda.io:443” --clientId “z5jW~eX.ShwRx7G1S5pBmUEZW-a4wMdk” --clientSecret “clientSecretValue”
And I got the response with a key, for example:
{
“key”: “1234322432”
}
Which I think means the message was published succefully, But the instance still keeps stopped at the the ReceiveTask.
Can somebody tell me what I am doing wrong?