Class TaktClient

java.lang.Object
io.taktx.client.TaktClient

public class TaktClient extends Object
TaktClient is the main entry point for interacting with the TaktX BPMN engine. It provides methods to deploy process definitions, start process instances, send message events, and register consumers for process definition updates, instance updates, external task triggers, and user task triggers.
  • Method Details

    • newClientBuilder

      public static TaktClient.TaktClientBuilder newClientBuilder()
      Creates a new TaktClientBuilder instance to create a new TaktClient.
      Returns:
      A new TaktClientBuilder instance.
    • start

      public void start()
      Starts the TaktClient, which subscribes to process definition records and process definition updates.
    • stop

      public void stop()
      Stops the TaktClient, which unsubscribes from process definition records and process
    • requestExternalTaskTopic

      public String requestExternalTaskTopic(String externalTaskId, int partitions, io.taktx.CleanupPolicy cleanupPolicy, short replicationFactor)
      Requests the creation of a Kafka topic for an external task.
      Parameters:
      externalTaskId - The ID of the external task.
      partitions - The number of partitions for the topic.
      cleanupPolicy - The cleanup policy for the topic.
      replicationFactor - The replication factor for the topic.
      Returns:
      The name of the created topic.
    • deployProcessDefinition

      public io.taktx.dto.ParsedDefinitionsDTO deployProcessDefinition(InputStream inputStream) throws IOException
      Deploys a process definition from an InputStream.
      Parameters:
      inputStream - The InputStream containing the process definition XML.
      Returns:
      The parsed definitions DTO.
      Throws:
      IOException - If an error occurs while reading the InputStream.
    • getProcessDefinitionByHash

      public Optional<io.taktx.dto.ProcessDefinitionDTO> getProcessDefinitionByHash(String processDefinitionId, String hash)
      Retrieves a deployed process definition by its ID and hash.
      Parameters:
      processDefinitionId - The ID of the process definition.
      hash - The hash of the process definition.
      Returns:
      An Optional containing the ProcessDefinitionDTO if found, or empty if not found.
    • startProcess

      public UUID startProcess(String process, io.taktx.dto.VariablesDTO variables)
      Starts a new process instance.
      Parameters:
      process - The ID of the process definition to start.
      variables - The initial variables for the process instance.
      Returns:
      The UUID of the started process instance.
    • sendMessage

      public void sendMessage(io.taktx.dto.MessageEventDTO messageEventDTO)
      Sends a message event to the engine.
      Parameters:
      messageEventDTO - The message event DTO containing the message details.
    • registerInstanceUpdateConsumer

      public void registerInstanceUpdateConsumer(Consumer<InstanceUpdateRecord> consumer)
      Registers a consumer that will be notified of instance update records.
      Parameters:
      consumer - The consumer to register.
    • registerProcessDefinitionUpdateConsumer

      public void registerProcessDefinitionUpdateConsumer(BiConsumer<io.taktx.dto.ProcessDefinitionKey,io.taktx.dto.ProcessDefinitionDTO> consumer)
      Registers a consumer that will be notified of process definition updates.
      Parameters:
      consumer - The consumer to register.
    • deployTaktDeploymentAnnotatedClasses

      public void deployTaktDeploymentAnnotatedClasses()
      Deploys all classes annotated with @TaktDeployment found in the classpath.
    • respondToExternalTask

      public ExternalTaskInstanceResponder respondToExternalTask(io.taktx.dto.ExternalTaskTriggerDTO externalTaskTriggerDTO)
      Responds to an external task trigger.
      Parameters:
      externalTaskTriggerDTO - The external task trigger DTO.
      Returns:
      The ExternalTaskInstanceResponder to respond to the external task.
    • completeUserTask

      public UserTaskInstanceResponder completeUserTask(io.taktx.dto.UserTaskTriggerDTO userTaskTriggerDTO)
      Completes a user task.
      Parameters:
      userTaskTriggerDTO - The user task trigger DTO.
      Returns:
      The UserTaskInstanceResponder to respond to the user task.
    • abortElementInstance

      public void abortElementInstance(UUID processInstanceId)
      Terminates a process instance.
      Parameters:
      processInstanceId - The UUID of the process instance to terminate.
    • abortElementInstance

      public void abortElementInstance(UUID activeProcessInstanceId, List<Long> elementInstanceIdPath)
      Aborts a specific element instance within a process instance.
      Parameters:
      activeProcessInstanceId - The UUID of the active process instance.
      elementInstanceIdPath - The path of element instance IDs leading to the element to abort.
    • registerExternalTaskConsumer

      public void registerExternalTaskConsumer(ExternalTaskTriggerConsumer externalTaskTriggerConsumer, String gruopId)
      Registers an external task consumer that will be notified of external task triggers.
      Parameters:
      externalTaskTriggerConsumer - The external task trigger consumer to register.
      gruopId - The group ID for the consumer.
    • registerUserTaskConsumer

      public void registerUserTaskConsumer(UserTaskTriggerConsumer userTaskTriggerConsumer)
      Registers a user task consumer that will be notified of user task triggers.
      Parameters:
      userTaskTriggerConsumer - The user task trigger consumer to register.
    • getProcessDefinitionXml

      public String getProcessDefinitionXml(io.taktx.dto.ProcessDefinitionKey processDefinitionKey) throws IOException
      Retrieves the XML of a process definition by its key.
      Parameters:
      processDefinitionKey - The key of the process definition.
      Returns:
      The XML of the process definition.
      Throws:
      IOException - If an error occurs while retrieving the XML.
    • sendSignal

      public void sendSignal(String signalName)
      Sends a signal event to the engine.
      Parameters:
      signalName - The name of the signal to send.