Activiti Cloud Query Service

The Query Service enable client applications to get Process & Task data without going straight to the Runtime Bundles. The Query Service was designed to enable efficient querying mechanisms for data generated by one or more Runtime Bundles. In contrast with the Audit Service, the Query Service picks up the event and apply some transformations to store state.

This component was designed to aggregate data from a set of related Runtime Bundles, allowing consumers to filter using the runtime bundle.

Specification

Endpoints

The query component provides read only REST endpoints.

Event Listeners

The query service listen to events generated by runtime bundles and transform them to store state about the current process instances and tasks executions. This state is stored in a schema that is optimized for querying and based on the specification of this component different implementations using different technologies can be implemented.

Our reference implementation uses JPA entities to store this state and we defined a simple schema to store the state of the following entities:

Here you can find all the Events Listeners that are used to recreate state from the events emitted by the Runtime Bundle.

These event listeners have the responsability of understanding each specific event and apply a transformation to the existing entities or creating new entity instances. The following section explains the current flow for each of the listeners. You can provide your own implementation of the Query Service (in any other language), by following the described behaviour:

  • This handler will

    • Create a new ProcessDefinitionEntity and

      • Set Cloud Metadata:

        • ServiceName

        • ServiceFullName

        • ServiceVersion

        • AppName

        • AppVersion

      • Set Id

      • Set Description

      • Set FormKey

      • Set ProcessDefinitionKey

      • Set Name

      • Set Version

      • Set Service Type

    • Create a new ProcessModelEntity and

      • Set ModelContent

      • Set Link to ProcessDefinitionEntity

This handler will:

  • Create a new ProcessInstanceEntity and

    • Set Cloud Metadata:

      • ServiceName

      • ServiceFullName

      • ServiceVersion

      • AppName

      • AppVersion

    • Set Id

    • Set ProcessDefinitionId

    • Set ProcessDefinitionKey

    • Set ProcessDefinitionVersion

    • Set Status to CREATED

    • Set LastModified to the date inside the event

    • Set Name

    • Set Initiator

    • Set BusinessKey

    • Set StartDate

    • Set ParentId

This handler will:

  • Update an existing ProcessInstanceEntity

  • Check if there is a Process Instance with status CREATED and:

    • Update the Status to RUNNING

    • Set the name of the process instance

    • Update LastModified

  • This event will be discarded if no Process Instance is not found and QueryException will be thrown

This handler will:

  • Update an existing ProcessInstanceEntity and

    • Update BusinessKey

    • Update Name

    • Update LastModified

  • This event will be discarded if no Process Instance is not found and QueryException will be thrown

This handler will:

  • Update an existing ProcessInstanceEntity and

    • Update Status to SUSPENDED

    • Update LastModified

  • This event will be discarded if no Process Instance is not found and QueryException will be thrown

This handler will:

  • Update an existing ProcessInstanceEntity and

    • Update Status to RUNNING

    • Update LastModified

  • This event will be discarded if no Process Instance is not found and QueryException will be thrown

This handler will:

  • Update an existing ProcessInstanceEntity and

    • Update Status to CANCELLED

    • Update LastModified

  • This event will be discarded if no Process Instance is not found and QueryException will be thrown

This handler will:

  • Update an existing ProcessInstanceEntity and

    • Update Status to COMPLETED

    • Update LastModified

  • This event will be discarded if no Process Instance is not found and QueryException will be thrown

This handler will:

  • Will check if it is a Task Var

Security and Permissions

By default only admin users can access everything. The endpoints that under /admin/ can be accessed ACTIVITI_ADMIN roles.

Process instance, task and variable data can be restricted to particular users or groups. This can be done by adding properties such as:

activiti.cloud.security.user.testuser.rb-app-name.policy.read=defKey1 activiti.cloud.security.user.hruser.rb-app-name.policy.read=defKey2

Here rb-app-name is the name of a runtime bundle application. Or environment variables can be used such as

ACTIVITI_CLOUD_SECURITY_USER_HRUSER_RBMYAPP_POLICY_READ=SimpleProcess ACTIVITI_CLOUD_SECURITY_GROUP_HR_RBMYAPP_POLICY_WRITE=SimpleProcess ACTIVITI_CLOUD_SECURITY_GROUP_TESTGROUP_RBMYAPP_POLICY_WRITE=*

Implementations

Docker Images

Last updated