Class TaktClient
java.lang.Object
io.taktx.client.TaktClient
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for creating TaktClient instances. -
Method Summary
Modifier and TypeMethodDescriptionvoidabortElementInstance(UUID processInstanceId) Terminates a process instance.voidabortElementInstance(UUID activeProcessInstanceId, List<Long> elementInstanceIdPath) Aborts a specific element instance within a process instance.completeUserTask(io.taktx.dto.UserTaskTriggerDTO userTaskTriggerDTO) Completes a user task.io.taktx.dto.ParsedDefinitionsDTOdeployProcessDefinition(InputStream inputStream) Deploys a process definition from an InputStream.voidDeploys all classes annotated with @TaktDeployment found in the classpath.Optional<io.taktx.dto.ProcessDefinitionDTO> getProcessDefinitionByHash(String processDefinitionId, String hash) Retrieves a deployed process definition by its ID and hash.getProcessDefinitionXml(io.taktx.dto.ProcessDefinitionKey processDefinitionKey) Retrieves the XML of a process definition by its key.static TaktClient.TaktClientBuilderCreates a new TaktClientBuilder instance to create a new TaktClient.voidregisterExternalTaskConsumer(ExternalTaskTriggerConsumer externalTaskTriggerConsumer, String gruopId) Registers an external task consumer that will be notified of external task triggers.voidRegisters a consumer that will be notified of instance update records.voidregisterProcessDefinitionUpdateConsumer(BiConsumer<io.taktx.dto.ProcessDefinitionKey, io.taktx.dto.ProcessDefinitionDTO> consumer) Registers a consumer that will be notified of process definition updates.voidregisterUserTaskConsumer(UserTaskTriggerConsumer userTaskTriggerConsumer) Registers a user task consumer that will be notified of user task triggers.requestExternalTaskTopic(String externalTaskId, int partitions, io.taktx.CleanupPolicy cleanupPolicy, short replicationFactor) Requests the creation of a Kafka topic for an external task.respondToExternalTask(io.taktx.dto.ExternalTaskTriggerDTO externalTaskTriggerDTO) Responds to an external task trigger.voidsendMessage(io.taktx.dto.MessageEventDTO messageEventDTO) Sends a message event to the engine.voidsendSignal(String signalName) Sends a signal event to the engine.voidstart()Starts the TaktClient, which subscribes to process definition records and process definition updates.startProcess(String process, io.taktx.dto.VariablesDTO variables) Starts a new process instance.voidstop()Stops the TaktClient, which unsubscribes from process definition records and process
-
Method Details
-
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
-
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
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
Terminates a process instance.- Parameters:
processInstanceId- The UUID of the process instance to terminate.
-
abortElementInstance
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
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
Sends a signal event to the engine.- Parameters:
signalName- The name of the signal to send.
-