public interface ZeebeClient extends AutoCloseable, JobClient
Modifier and Type | Method and Description |
---|---|
void |
close() |
ZeebeClientConfiguration |
getConfiguration() |
ActivateJobsCommandStep1 |
newActivateJobsCommand()
Command to activate multiple jobs of a given type.
|
CancelWorkflowInstanceCommandStep1 |
newCancelInstanceCommand(long workflowInstanceKey)
Command to cancel a workflow instance.
|
static ZeebeClient |
newClient() |
static ZeebeClient |
newClient(ZeebeClientConfiguration configuration) |
static ZeebeClientBuilder |
newClientBuilder() |
CreateWorkflowInstanceCommandStep1 |
newCreateInstanceCommand()
Command to create/start a new instance of a workflow.
|
DeployWorkflowCommandStep1 |
newDeployCommand()
Command to deploy new workflows.
|
PublishMessageCommandStep1 |
newPublishMessageCommand()
Command to publish a message which can be correlated to a workflow instance.
|
ResolveIncidentCommandStep1 |
newResolveIncidentCommand(long incidentKey)
Command to resolve an existing incident.
|
WorkflowResourceRequestStep1 |
newResourceRequest()
Request to get the resource of a workflow (i.e.
|
TopologyRequestStep1 |
newTopologyRequest()
Request the current cluster topology.
|
UpdatePayloadWorkflowInstanceCommandStep1 |
newUpdatePayloadCommand(long elementInstanceKey)
Command to update the payload of a workflow instance.
|
UpdateRetriesJobCommandStep1 |
newUpdateRetriesCommand(long jobKey)
Command to update the retries of a job.
|
JobWorkerBuilderStep1 |
newWorker()
Registers a new job worker for jobs of a given type.
|
WorkflowRequestStep1 |
newWorkflowRequest()
Request to get all deployed workflows.
|
newCompleteCommand, newFailCommand
TopologyRequestStep1 newTopologyRequest()
List<BrokerInfo> brokers = zeebeClient .newTopologyRequest() .send() .join() .getBrokers(); SocketAddress address = broker.getSocketAddress(); List<PartitionInfo> partitions = broker.getPartitions();
send()
ZeebeClientConfiguration getConfiguration()
static ZeebeClient newClient()
newClientBuilder()
or newClient(ZeebeClientConfiguration)
. See ZeebeClientBuilder
for the configuration
options and default values.static ZeebeClient newClient(ZeebeClientConfiguration configuration)
ZeebeClient
using the provided configuration.static ZeebeClientBuilder newClientBuilder()
ZeebeClient
.void close()
close
in interface AutoCloseable
DeployWorkflowCommandStep1 newDeployCommand()
zeebeClient .newDeployCommand() .addResourceFile("~/wf/workflow1.bpmn") .addResourceFile("~/wf/workflow2.bpmn") .send();
CreateWorkflowInstanceCommandStep1 newCreateInstanceCommand()
zeebeClient .newCreateInstanceCommand() .bpmnProcessId("my-process") .latestVersion() .payload(json) .send();
CancelWorkflowInstanceCommandStep1 newCancelInstanceCommand(long workflowInstanceKey)
zeebeClient .newCancelInstanceCommand(workflowInstanceKey) .send();
workflowInstanceKey
- the key which identifies the corresponding workflow instanceUpdatePayloadWorkflowInstanceCommandStep1 newUpdatePayloadCommand(long elementInstanceKey)
zeebeClient .newUpdatePayloadCommand(elementInstanceKey) .payload(json) .send();
elementInstanceKey
- the key of the element instance to update the payload forPublishMessageCommandStep1 newPublishMessageCommand()
zeebeClient .newPublishMessageCommand() .messageName("order canceled") .correlationKey(orderId) .payload(json) .send();
WorkflowResourceRequestStep1 newResourceRequest()
WorkflowResource resource = zeebeClient .newResourceRequest() .bpmnProcessId("my-process") .lastestVersion() .send() .join(); String bpmnXml = resoure.getBpmnXml();
WorkflowRequestStep1 newWorkflowRequest()
List<Workflow> workflows = zeebeClient .newWorkflowRequest() .send() .join() .getWorkflows(); String bpmnProcessId = workflow.getBpmnProcessId();The response does not contain the resources of the workflows. Use
newResourceRequest()
to get the resource of a workflow.newResourceRequest()
ResolveIncidentCommandStep1 newResolveIncidentCommand(long incidentKey)
zeebeClient .newResolveIncidentCommand(incidentKey) .send();
incidentKey
- the key of the corresponding incidentUpdateRetriesJobCommandStep1 newUpdateRetriesCommand(long jobKey)
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 subscription and a related incident will be marked as resolved.
jobKey
- the key of the job to updateJobWorkerBuilderStep1 newWorker()
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 class PaymentHandler implements JobHandler { @Override public void handle(JobClient client, JobEvent jobEvent) { String json = jobEvent.getPayload(); // modify payload client .newCompleteCommand() .event(jobEvent) .payload(json) .send(); } };
ActivateJobsCommandStep1 newActivateJobsCommand()
zeebeClient .newActivateJobsCommand() .jobType("payment") .amount(10) .workerName("paymentWorker") .timeout(Duration.ofMinutes(10)) .send();
The command will try to activate maximal amount
jobs of given jobType
. If
less then amount
jobs of the jobType
are available for activation the returned
list will have fewer elements.
Copyright © 2017–2019 camunda services GmbH. All rights reserved.