Interface ZeebeClient

    • Method Detail

      • 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();
        
          SocketAddress address = broker.getSocketAddress();
        
          List<PartitionInfo> partitions = broker.getPartitions();
         
        Returns:
        the request where you must call send()
      • newDeployCommand

        DeployWorkflowCommandStep1 newDeployCommand()
        Command to deploy new workflows.
         zeebeClient
          .newDeployCommand()
          .addResourceFile("~/wf/workflow1.bpmn")
          .addResourceFile("~/wf/workflow2.bpmn")
          .send();
         
        Returns:
        a builder for the command
      • newCreateInstanceCommand

        CreateWorkflowInstanceCommandStep1 newCreateInstanceCommand()
        Command to create/start a new instance of a workflow.
         zeebeClient
          .newCreateInstanceCommand()
          .bpmnProcessId("my-process")
          .latestVersion()
          .variables(json)
          .send();
         
        Returns:
        a builder for the command
      • newCancelInstanceCommand

        CancelWorkflowInstanceCommandStep1 newCancelInstanceCommand​(long workflowInstanceKey)
        Command to cancel a workflow instance.
         zeebeClient
          .newCancelInstanceCommand(workflowInstanceKey)
          .send();
         
        Parameters:
        workflowInstanceKey - the key which identifies the corresponding workflow instance
        Returns:
        a builder for the command
      • newSetVariablesCommand

        SetVariablesCommandStep1 newSetVariablesCommand​(long elementInstanceKey)
        Command to set and/or update the variables of a given flow element (e.g. workflow 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
      • newPublishMessageCommand

        PublishMessageCommandStep1 newPublishMessageCommand()
        Command to publish a message which can be correlated to a workflow instance.
         zeebeClient
          .newPublishMessageCommand()
          .messageName("order canceled")
          .correlationKey(orderId)
          .variables(json)
          .send();
         
        Returns:
        a builder for the command
      • newResolveIncidentCommand

        ResolveIncidentCommandStep1 newResolveIncidentCommand​(long incidentKey)
        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

        UpdateRetriesJobCommandStep1 newUpdateRetriesCommand​(long jobKey)
        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
      • 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
      • newActivateJobsCommand

        ActivateJobsCommandStep1 newActivateJobsCommand()
        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 given jobType. If less then the requested maxJobsToActivate jobs of the jobType are available for activation the returned list will have fewer elements.

        Returns:
        a builder for the command