Class ProcessDefinitionConsumer
java.lang.Object
io.taktx.client.ProcessDefinitionConsumer
A consumer that subscribes to process definition activation records from a Kafka topic, maintains
a map of deployed process definitions, and notifies registered consumers of updates.
-
Method Summary
Modifier and TypeMethodDescriptionOptional<io.taktx.dto.ProcessDefinitionDTO> getDeployedProcessDefinitionbyHash(String processDefinitionId, String hash) Retrieves a deployed process definition by its process definition ID and hash.Map<io.taktx.dto.ProcessDefinitionKey, io.taktx.dto.ProcessDefinitionDTO> Retrieves the map of deployed process definitions.Map<io.taktx.dto.ProcessDefinitionKey, io.taktx.dto.ProcessDefinitionDTO> getDeployedProcessDefinitions(String processDefinitionId) Retrieves the deployed process definitions for a specific process definition ID.voidregisterProcessDefinitionUpdateConsumer(BiConsumer<io.taktx.dto.ProcessDefinitionKey, io.taktx.dto.ProcessDefinitionDTO> consumer) Registers a consumer to be notified of process definition updates.voidstop()Stops the consumer from processing further records.voidSubscribes to the process definition activation topic and starts processing records.
-
Method Details
-
subscribeToDefinitionRecords
public void subscribeToDefinitionRecords()Subscribes to the process definition activation topic and starts processing records. This method creates a Kafka consumer, subscribes to the appropriate topic, and processes incoming records asynchronously. It updates the internal map of deployed process definitions and notifies registered consumers of any updates. -
stop
public void stop()Stops the consumer from processing further records. This method sets the running flag to false, which will cause the processing loop to exit and the consumer to unsubscribe and close. -
getDeployedProcessDefinitions
public Map<io.taktx.dto.ProcessDefinitionKey,io.taktx.dto.ProcessDefinitionDTO> getDeployedProcessDefinitions()Retrieves the map of deployed process definitions.- Returns:
- a map of ProcessDefinitionKey to ProcessDefinitionDTO representing the deployed process definitions
-
getDeployedProcessDefinitions
public Map<io.taktx.dto.ProcessDefinitionKey,io.taktx.dto.ProcessDefinitionDTO> getDeployedProcessDefinitions(String processDefinitionId) Retrieves the deployed process definitions for a specific process definition ID.- Parameters:
processDefinitionId- the process definition ID to filter by- Returns:
- a map of ProcessDefinitionKey to ProcessDefinitionDTO for the specified process definition ID
-
getDeployedProcessDefinitionbyHash
public Optional<io.taktx.dto.ProcessDefinitionDTO> getDeployedProcessDefinitionbyHash(String processDefinitionId, String hash) Retrieves a deployed process definition by its process definition ID and hash.- Parameters:
processDefinitionId- the process definition ID to filter byhash- the hash to filter by- Returns:
- an Optional containing the ProcessDefinitionDTO if found, or empty if not found
-
registerProcessDefinitionUpdateConsumer
public void registerProcessDefinitionUpdateConsumer(BiConsumer<io.taktx.dto.ProcessDefinitionKey, io.taktx.dto.ProcessDefinitionDTO> consumer) Registers a consumer to be notified of process definition updates.- Parameters:
consumer- a BiConsumer that accepts a ProcessDefinitionKey and ProcessDefinitionDTO to be notified of updates
-