Package io.camunda.zeebe.client
Interface ZeebeClient
- All Superinterfaces:
AutoCloseable
,JobClient
- All Known Implementing Classes:
ZeebeClientImpl
The client to communicate with a Zeebe broker/cluster.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Command to broadcast a signal.newCancelInstanceCommand
(long processInstanceKey) Command to cancel a process instance.static ZeebeClient
static ZeebeClient
newClient
(ZeebeClientConfiguration configuration) static ZeebeClientBuilder
static ZeebeClientCloudBuilderStep1
Command to create/start a new instance of a process.newDeleteResourceCommand
(long resourceKey) Command to delete a resource.Deprecated.Command to deploy new resources, i.e.Command to evaluate a decision.newModifyProcessInstanceCommand
(long processInstanceKey) Command to modify a process instance.Command to publish a message which can be correlated to a process instance.newResolveIncidentCommand
(long incidentKey) Command to resolve an existing incident.newSetVariablesCommand
(long elementInstanceKey) Command to set and/or update the variables of a given flow element (e.g.Request the current cluster topology.newUpdateRetriesCommand
(long jobKey) Command to update the retries of a job.Command to update the retries of a job.Registers a new job worker for jobs of a given type.Methods inherited from interface io.camunda.zeebe.client.api.worker.JobClient
newActivateJobsCommand, newCompleteCommand, newCompleteCommand, newFailCommand, newFailCommand, newStreamJobsCommand, newThrowErrorCommand, newThrowErrorCommand
-
Method Details
-
newClient
- Returns:
- a new Zeebe client with default configuration values. In order to customize
configuration, use the methods
newClientBuilder()
ornewClient(ZeebeClientConfiguration)
. SeeZeebeClientBuilder
for the configuration options and default values.
-
newClient
- Returns:
- a new
ZeebeClient
using the provided configuration.
-
newClientBuilder
- Returns:
- a builder to configure and create a new
ZeebeClient
.
-
newCloudClientBuilder
- Returns:
- a builder with convenient methods to connect to the Camunda Cloud cluster.
-
newTopologyRequest
TopologyRequestStep1 newTopologyRequest()Request the current cluster topology. Can be used to inspect which brokers are available at which endpoint and which broker is the leader of which partition.List<BrokerInfo> brokers = zeebeClient .newTopologyRequest() .send() .join() .getBrokers(); InetSocketAddress address = broker.getSocketAddress(); List<PartitionInfo> partitions = broker.getPartitions();
- Returns:
- the request where you must call
send()
-
getConfiguration
ZeebeClientConfiguration getConfiguration()- Returns:
- the client's configuration
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-
newDeployCommand
DeployProcessCommandStep1 newDeployCommand()Deprecated.since 8 for removal with 8.1, replaced bynewDeployResourceCommand()
Command to deploy new processes.zeebeClient .newDeployCommand() .addResourceFile("~/wf/process1.bpmn") .addResourceFile("~/wf/process2.bpmn") .send();
- Returns:
- a builder for the command
-
newDeployResourceCommand
DeployResourceCommandStep1 newDeployResourceCommand()Command to deploy new resources, i.e. BPMN process models and DMN decision models.zeebeClient .newDeployCommand() .addResourceFile("~/wf/process1.bpmn") .addResourceFile("~/wf/process2.bpmn") .addResourceFile("~/dmn/decision.dmn") .send();
- Returns:
- a builder for the command
-
newCreateInstanceCommand
CreateProcessInstanceCommandStep1 newCreateInstanceCommand()Command to create/start a new instance of a process.zeebeClient .newCreateInstanceCommand() .bpmnProcessId("my-process") .latestVersion() .variables(json) .send();
- Returns:
- a builder for the command
-
newModifyProcessInstanceCommand
Command to modify a process instance.zeebeClient .newModifyProcessInstanceCommand(processInstanceKey) .activateElement("element1") .and() .activateElement("element2") .withVariables(globalScopedVariables) .withVariables(localScopedVariables, "element2") .and() .terminateElement("element3") .send();
- Parameters:
processInstanceKey
- the key which identifies the corresponding process instance- Returns:
- a builder for the command
-
newCancelInstanceCommand
Command to cancel a process instance.zeebeClient .newCancelInstanceCommand(processInstanceKey) .send();
- Parameters:
processInstanceKey
- the key which identifies the corresponding process instance- Returns:
- a builder for the command
-
newSetVariablesCommand
Command to set and/or update the variables of a given flow element (e.g. process instance, task, etc.)zeebeClient .newSetVariablesCommand(elementInstanceKey) .variables(json) .send();
- Parameters:
elementInstanceKey
- the key of the element instance to set/update the variables for- Returns:
- a builder for the command
-
newEvaluateDecisionCommand
EvaluateDecisionCommandStep1 newEvaluateDecisionCommand()Command to evaluate a decision.zeebeClient .newEvaluateDecisionCommand() .decisionKey("my-decision") .variables(json) .send();
- Returns:
- a builder for the command
-
newPublishMessageCommand
PublishMessageCommandStep1 newPublishMessageCommand()Command to publish a message which can be correlated to a process instance.zeebeClient .newPublishMessageCommand() .messageName("order canceled") .correlationKey(orderId) .variables(json) .send();
- Returns:
- a builder for the command
-
newBroadcastSignalCommand
BroadcastSignalCommandStep1 newBroadcastSignalCommand()Command to broadcast a signal.zeebeClient .newBroadcastSignalCommand() .signalName("signal") .variables(json) .send();
- Returns:
- a builder for the command
-
newResolveIncidentCommand
Command to resolve an existing incident.zeebeClient .newResolveIncidentCommand(incidentKey) .send();
- Parameters:
incidentKey
- the key of the corresponding incident- Returns:
- the builder for the command
-
newUpdateRetriesCommand
Command to update the retries of a job.long jobKey = ..; zeebeClient .newUpdateRetriesCommand(jobKey) .retries(3) .send();
If the given retries are greater than zero then this job will be picked up again by a job worker. This will not close a related incident, which still has to be marked as resolved with
newResolveIncidentCommand(long incidentKey)
.- Parameters:
jobKey
- the key of the job to update- Returns:
- a builder for the command
-
newUpdateRetriesCommand
Command to update the retries of a job.ActivatedJob job= ..; zeebeClient .newUpdateRetriesCommand(job) .retries(3) .send();
If the given retries are greater than zero then this job will be picked up again by a job worker. This will not close a related incident, which still has to be marked as resolved with
newResolveIncidentCommand(long incidentKey)
.- Parameters:
job
- the activated job- Returns:
- a builder for the command
-
newWorker
JobWorkerBuilderStep1 newWorker()Registers a new job worker for jobs of a given type.After registration, the broker activates available jobs and assigns them to this worker. It then publishes them to the client. The given worker is called for every received job, works on them and eventually completes them.
JobWorker worker = zeebeClient .newWorker() .jobType("payment") .handler(paymentHandler) .open(); ... worker.close();
Example JobHandler implementation:public final class PaymentHandler implements JobHandler { @Override public void handle(JobClient client, JobEvent jobEvent) { String json = jobEvent.getVariables(); // modify variables client .newCompleteCommand() .event(jobEvent) .variables(json) .send(); } };
- Returns:
- a builder for the worker registration
-
newDeleteResourceCommand
Command to delete a resource.zeebeClient .newDeleteResourceCommand(resourceKey) .send();
- Parameters:
resourceKey
- the key of the resource- Returns:
- the builder for the command
-
newDeployResourceCommand()