Constructor and Description |
---|
JobClientImpl(GatewayGrpc.GatewayStub asyncStub,
ZeebeClientConfiguration config,
ZeebeObjectMapper objectMapper,
ScheduledExecutorService executorService,
List<CloseableSilently> closeables) |
Modifier and Type | Method and Description |
---|---|
ActivateJobsCommandStep1 |
newActivateJobsCommand()
Command to activate multiple jobs of a given type.
|
CompleteJobCommandStep1 |
newCompleteCommand(long jobKey)
Command to complete a job.
|
CreateJobCommandStep1 |
newCreateCommand()
Command to create a new (standalone) job.
|
FailJobCommandStep1 |
newFailCommand(long jobKey)
Command to mark a job as failed.
|
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.
|
public JobClientImpl(GatewayGrpc.GatewayStub asyncStub, ZeebeClientConfiguration config, ZeebeObjectMapper objectMapper, ScheduledExecutorService executorService, List<CloseableSilently> closeables)
public CreateJobCommandStep1 newCreateCommand()
JobClient
jobClient .newCreateCommand() .type("my-todos") .payload(json) .send();
newCreateCommand
in interface JobClient
public CompleteJobCommandStep1 newCompleteCommand(long jobKey)
JobClient
long jobKey = ..; jobClient .newCompleteCommand(jobKey) .payload(json) .send();The job is specified by the given event. The event must be the latest event of the job to ensure that the command is based on the latest state of the job. If it's not the latest one then the command is rejected.
If the job is linked to a workflow instance then this command will complete the related activity and continue the flow.
newCompleteCommand
in interface JobClient
public FailJobCommandStep1 newFailCommand(long jobKey)
JobClient
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.
newFailCommand
in interface JobClient
jobKey
- the key of the jobpublic UpdateRetriesJobCommandStep1 newUpdateRetriesCommand(long jobKey)
JobClient
long jobKey = ..; jobClient .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.
newUpdateRetriesCommand
in interface JobClient
jobKey
- the key of the job to updatepublic JobWorkerBuilderStep1 newWorker()
JobClient
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 = jobClient .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(); } };
public ActivateJobsCommandStep1 newActivateJobsCommand()
JobClient
jobClient .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.
newActivateJobsCommand
in interface JobClient
Copyright © 2017–2018 camunda services GmbH. All rights reserved.