Class ZeebeClientImpl
- All Implemented Interfaces:
JobClient
,ZeebeClient
,AutoCloseable
-
Constructor Summary
ConstructorDescriptionZeebeClientImpl
(ZeebeClientConfiguration configuration) ZeebeClientImpl
(ZeebeClientConfiguration configuration, io.grpc.ManagedChannel channel) ZeebeClientImpl
(ZeebeClientConfiguration configuration, io.grpc.ManagedChannel channel, GatewayGrpc.GatewayStub gatewayStub) ZeebeClientImpl
(ZeebeClientConfiguration config, io.grpc.ManagedChannel channel, GatewayGrpc.GatewayStub gatewayStub, ScheduledExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionstatic io.grpc.ManagedChannel
buildChannel
(ZeebeClientConfiguration config) static GatewayGrpc.GatewayStub
buildGatewayStub
(io.grpc.ManagedChannel channel, ZeebeClientConfiguration config) void
close()
Command to activate multiple jobs of a given type.newCancelInstanceCommand
(long processInstanceKey) Command to cancel a process instance.newCompleteCommand
(long jobKey) Command to complete a job.Command to complete a job.Command to create/start a new instance of a process.Command to deploy new processes.Command to deploy new resources, i.e.newFailCommand
(long jobKey) Command to mark a job as failed.Command to mark a job as failed.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.newThrowErrorCommand
(long jobKey) Command to report a business error (i.e.Command to report a business error (i.e.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.
-
Constructor Details
-
ZeebeClientImpl
-
ZeebeClientImpl
-
ZeebeClientImpl
public ZeebeClientImpl(ZeebeClientConfiguration configuration, io.grpc.ManagedChannel channel, GatewayGrpc.GatewayStub gatewayStub) -
ZeebeClientImpl
public ZeebeClientImpl(ZeebeClientConfiguration config, io.grpc.ManagedChannel channel, GatewayGrpc.GatewayStub gatewayStub, ScheduledExecutorService executorService)
-
-
Method Details
-
buildChannel
-
buildGatewayStub
public static GatewayGrpc.GatewayStub buildGatewayStub(io.grpc.ManagedChannel channel, ZeebeClientConfiguration config) -
newTopologyRequest
Description copied from interface:ZeebeClient
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();
- Specified by:
newTopologyRequest
in interfaceZeebeClient
- Returns:
- the request where you must call
send()
-
getConfiguration
- Specified by:
getConfiguration
in interfaceZeebeClient
- Returns:
- the client's configuration
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceZeebeClient
-
newDeployCommand
Description copied from interface:ZeebeClient
Command to deploy new processes.zeebeClient .newDeployCommand() .addResourceFile("~/wf/process1.bpmn") .addResourceFile("~/wf/process2.bpmn") .send();
- Specified by:
newDeployCommand
in interfaceZeebeClient
- Returns:
- a builder for the command
-
newDeployResourceCommand
Description copied from interface:ZeebeClient
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();
- Specified by:
newDeployResourceCommand
in interfaceZeebeClient
- Returns:
- a builder for the command
-
newCreateInstanceCommand
Description copied from interface:ZeebeClient
Command to create/start a new instance of a process.zeebeClient .newCreateInstanceCommand() .bpmnProcessId("my-process") .latestVersion() .variables(json) .send();
- Specified by:
newCreateInstanceCommand
in interfaceZeebeClient
- Returns:
- a builder for the command
-
newModifyProcessInstanceCommand
Description copied from interface:ZeebeClient
Command to modify a process instance.zeebeClient .newModifyProcessInstanceCommand(processInstanceKey) .activateElement("element1") .and() .activateElement("element2") .withVariables(globalScopedVariables) .withVariables(localScopedVariables, "element2") .and() .terminateElement("element3") .send();
- Specified by:
newModifyProcessInstanceCommand
in interfaceZeebeClient
- Parameters:
processInstanceKey
- the key which identifies the corresponding process instance- Returns:
- a builder for the command
-
newCancelInstanceCommand
Description copied from interface:ZeebeClient
Command to cancel a process instance.zeebeClient .newCancelInstanceCommand(processInstanceKey) .send();
- Specified by:
newCancelInstanceCommand
in interfaceZeebeClient
- Parameters:
processInstanceKey
- the key which identifies the corresponding process instance- Returns:
- a builder for the command
-
newSetVariablesCommand
Description copied from interface:ZeebeClient
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();
- Specified by:
newSetVariablesCommand
in interfaceZeebeClient
- Parameters:
elementInstanceKey
- the key of the element instance to set/update the variables for- Returns:
- a builder for the command
-
newPublishMessageCommand
Description copied from interface:ZeebeClient
Command to publish a message which can be correlated to a process instance.zeebeClient .newPublishMessageCommand() .messageName("order canceled") .correlationKey(orderId) .variables(json) .send();
- Specified by:
newPublishMessageCommand
in interfaceZeebeClient
- Returns:
- a builder for the command
-
newResolveIncidentCommand
Description copied from interface:ZeebeClient
Command to resolve an existing incident.zeebeClient .newResolveIncidentCommand(incidentKey) .send();
- Specified by:
newResolveIncidentCommand
in interfaceZeebeClient
- Parameters:
incidentKey
- the key of the corresponding incident- Returns:
- the builder for the command
-
newUpdateRetriesCommand
Description copied from interface:ZeebeClient
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)
.- Specified by:
newUpdateRetriesCommand
in interfaceZeebeClient
- Parameters:
jobKey
- the key of the job to update- Returns:
- a builder for the command
-
newUpdateRetriesCommand
Description copied from interface:ZeebeClient
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)
.- Specified by:
newUpdateRetriesCommand
in interfaceZeebeClient
- Parameters:
job
- the activated job- Returns:
- a builder for the command
-
newWorker
Description copied from interface:ZeebeClient
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(); } };
- Specified by:
newWorker
in interfaceZeebeClient
- Returns:
- a builder for the worker registration
-
newActivateJobsCommand
Description copied from interface:ZeebeClient
Command to activate multiple jobs of a given type.zeebeClient .newActivateJobsCommand() .jobType("payment") .maxJobsToActivate(10) .workerName("paymentWorker") .timeout(Duration.ofMinutes(10)) .send();
The command will try to use
maxJobsToActivate
for givenjobType
. If less then the requestedmaxJobsToActivate
jobs of thejobType
are available for activation the returned list will have fewer elements.- Specified by:
newActivateJobsCommand
in interfaceZeebeClient
- Returns:
- a builder for the command
-
newCompleteCommand
Description copied from interface:JobClient
Command to complete a job.long jobKey = ..; jobClient .newCompleteCommand(jobKey) .variables(json) .send();
If the job is linked to a process instance then this command will complete the related activity and continue the flow.
- Specified by:
newCompleteCommand
in interfaceJobClient
- Parameters:
jobKey
- the key which identifies the job- Returns:
- a builder for the command
-
newCompleteCommand
Description copied from interface:JobClient
Command to complete a job.ActivatedJob job = ..; jobClient .newCompleteCommand(job) .variables(json) .send();
If the job is linked to a process instance then this command will complete the related activity and continue the flow.
- Specified by:
newCompleteCommand
in interfaceJobClient
- Parameters:
job
- the activated job- Returns:
- a builder for the command
-
newFailCommand
Description copied from interface:JobClient
Command to mark a job as failed.long jobKey = ..; jobClient .newFailCommand(jobKey) .retries(3) .send();
If the given retries are greater than zero then this job will be picked up again by a job subscription. Otherwise, an incident is created for this job.
- Specified by:
newFailCommand
in interfaceJobClient
- Parameters:
jobKey
- the key which identifies the job- Returns:
- a builder for the command
-
newFailCommand
Description copied from interface:JobClient
Command to mark a job as failed.ActivatedJob job = ..; jobClient .newFailCommand(job) .retries(3) .send();
If the given retries are greater than zero then this job will be picked up again by a job subscription. Otherwise, an incident is created for this job.
- Specified by:
newFailCommand
in interfaceJobClient
- Parameters:
job
- the activated job- Returns:
- a builder for the command
-
newThrowErrorCommand
Description copied from interface:JobClient
Command to report a business error (i.e. non-technical) that occurs while processing a job.long jobKey = ...; String code = ...; jobClient .newThrowErrorCommand(jobKey) .errorCode(code) .send();
The error is handled in the process by an error catch event. If there is no error catch event with the specified errorCode then an incident will be raised instead.
- Specified by:
newThrowErrorCommand
in interfaceJobClient
- Parameters:
jobKey
- the key which identifies the job- Returns:
- a builder for the command
-
newThrowErrorCommand
Description copied from interface:JobClient
Command to report a business error (i.e. non-technical) that occurs while processing a job.ActivatedJob job = ...; String code = ...; jobClient .newThrowErrorCommand(job) .errorCode(code) .send();
The error is handled in the process by an error catch event. If there is no error catch event with the specified errorCode then an incident will be raised instead.
- Specified by:
newThrowErrorCommand
in interfaceJobClient
- Parameters:
job
- the activated job- Returns:
- a builder for the command
-