Skip to content
๐Ÿš€ Play in Aletyx Sandbox to start building your Business Processes and Decisions today! ×

Getting Started with the Aletyx Enterprise Build of Kogito and Drools Quarkus Maven Archetype to try the Adaptive Process Architecture with Quarkusโ„ข

This guide demonstrates how to use the Aletyx Enterprise Build of Kogito and Drools Quarkus Maven Archetype to create a fully-configured business automation project quickly to see how process can be built with mvn quarkus:dev and the Adaptive Process Architecture.

Introduction

The Aletyx Enterprise Build of Kogito and Drools Quarkus Maven Archetype Quarkus Maven Archetype provides a standardized template for creating new Kogito/jBPM projects with a focus on business automation. The archetype creates two distinct architectures you can try as a developer:

  • Using mvn quarkus:dev to see how the Quarkus Developer UI Tools work, located at http://localhost:8080/q/dev-ui
  • Using a combination of mvn clean install and docker compose up --build to build a local version of the Adaptive Process Architecture with the components to mimic how your process could look.

Within these configurations, the associated datasources are created attached to the environments. For mvn quarkus:dev this is a local, non-persisted instance that will go away when your service stops. With the Adaptive Process Architecture version, a PostgreSQL container is built with the appropriate SQL required for it to work within the docker-compose.yaml. This process helps mimic what would be used when deployed to your container platform of choice.

Prerequisites

Before starting, ensure you have the following installed:

  • Javaโ„ข 17 or higher
  • Apache Mavenโ„ข 3.9.6+
  • Dockerยฎ and Docker Composeโ„ข (for containerized deployment)
  • PostgreSQLยฎ (optional, for local development without containers)

Creating a New Project

Step 1: Generate the Project

Run the following command to create a new project using the Aletyx Enterprise Build of Kogito and Drools Quarkus Maven Archetype:

mvn archetype:generate \
  -DarchetypeGroupId=ai.aletyx.archetypes \
  -DarchetypeArtifactId=quarkus-kogito-jbpm-archetype \
  -DarchetypeVersion=1.0.0 \
  -DgroupId=com.example \
  -DartifactId=my-kogito-app \
  -Dversion=1.0.0-SNAPSHOT \
  -Dpackage=com.example.test \
  -DkogitoVersion=10.0.0 \
  -DquarkusVersion=3.15.3

This command will: 1. Connect to the repository containing the archetype 2. Download the archetype 3. Generate a new project based on the archetype template 4. Customize the project with the parameters you provided at the artifactId folder in the directory this is ran from.

Step 2: Explore the Generated Project

Navigate to the newly created project directory:

cd my-kogito-app

The generated project will have the following structure:

my-kogito-app/
โ”œโ”€โ”€ Dockerfile                   # Docker file for containerization
โ”œโ”€โ”€ README.md                    # Project README with usage instructions
โ”œโ”€โ”€ docker-compose.yaml          # Docker Compose configuration
โ”œโ”€โ”€ docker-compose/              # Docker Compose supporting files
โ”‚   โ”œโ”€โ”€ pgadmin/                 # pgAdmin configuration
โ”‚   โ”‚   โ”œโ”€โ”€ pgpass
โ”‚   โ”‚   โ””โ”€โ”€ servers.json
โ”‚   โ””โ”€โ”€ postgres/                # PostgreSQL configuration
โ”‚       โ”œโ”€โ”€ Dockerfile
โ”‚       โ””โ”€โ”€ sql/                 # SQL initialization scripts
โ”‚           โ”œโ”€โ”€ 01_init.sql
โ”‚           โ”œโ”€โ”€ data-audit.sql
โ”‚           โ”œโ”€โ”€ data-index.sql
โ”‚           โ”œโ”€โ”€ jobs-service.sql
โ”‚           โ”œโ”€โ”€ runtime-persistence.sql
โ”‚           โ””โ”€โ”€ user-tasks.sql
โ”œโ”€โ”€ pom.xml                      # Project POM file
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ main/
    โ”‚   โ”œโ”€โ”€ java/                # Java source files
    โ”‚   โ”‚   โ”œโ”€โ”€ listeners/       # Process event listeners
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ MinimalClaimListener.java
    โ”‚   โ”‚   โ””โ”€โ”€ model/           # Domain model classes
    โ”‚   โ”‚       โ””โ”€โ”€ Policy.java
    โ”‚   โ””โ”€โ”€ resources/           # Resource files
    โ”‚       โ”œโ”€โ”€ application.properties  # Application configuration
    โ”‚       โ””โ”€โ”€ claim_initiation.bpmn   # Sample BPMN process
    โ””โ”€โ”€ test/                    # Test files
        โ”œโ”€โ”€ java/
        โ””โ”€โ”€ resources/

Running the Application in Development Mode

Step 1: Start the Development Server

Run the following command to start the application in development mode:

./mvnw compile quarkus:dev

This will start a development server with hot reloading enabled.

Step 2: Access the Application

Once the application is running, you can access:

Step 3: Test the Sample Process

  1. Navigate to the Swagger UIโ„ข at http://localhost:8080/q/swagger-ui
  2. Find the "claim_initiation" process endpoint
  3. Create a new process instance by sending a request with "Home" as the claimType
  4. The process will create a user task assigned to user "jdoe"
  5. You can claim and complete the task by impersonating as "jdoe"

Running with Docker Compose

For a full deployment including PostgreSQL persistence and the Kogito Management Console:

Step 1: Build the Application

First, build the application:

./mvnw clean install

Step 2: Start the Docker Compose Environment

Launch all services using Docker Compose:

docker compose up --build

This will start: - PostgreSQL database (port 5432) - Your application (port 8080) - Kogito Management Console (port 8280) - pgAdmin (port 8055)

Step 3: Access the Services

Step 4: Test the Application

  1. Navigate to http://localhost:8080/q/swagger-ui
  2. Test the claim_initiation process (use "Home" for the claimType)
  3. Navigate to http://localhost:8280 to open the Management Console
  4. Connect to a new service at http://localhost:8080
  5. Monitor the process instance in the Management Console
  6. Complete the task by impersonating as user "jdoe"
  7. Verify the process is completed in the Management Console

Customizing the Project

Adding New Processes

  1. Create new BPMNโ„ข files in src/main/resources
  2. They will be automatically compiled and deployed when the application starts

Creating Process Event Listeners

  1. Create a new class that extends DefaultKogitoProcessEventListener
  2. Annotate it with @ApplicationScoped
  3. Override the desired event methods, such as:
  4. beforeProcessStarted
  5. afterProcessStarted
  6. beforeTaskCompleted
  7. afterTaskCompleted

Example:

@ApplicationScoped
public class MyProcessListener extends DefaultKogitoProcessEventListener {

    private static final Logger LOGGER = LoggerFactory.getLogger(MyProcessListener.class);

    @Override
    public void afterProcessStarted(ProcessStartedEvent event) {
        LOGGER.info("Process started: {}", event.getProcessInstance().getProcessId());
    }

    @Override
    public void afterTaskCompleted(TaskCompletedEvent event) {
        LOGGER.info("Task completed: {}", event.getTask().getName());
    }
}

Deployment Options

The generated project supports several deployment options:

Local Development

Use the default profile for local development with in-memory persistence:

./mvnw quarkus:dev

Docker Compose

Use the compose profile for containerized deployment with PostgreSQL:

./mvnw clean package -Pcompose
docker compose up

Red Hat OpenShiftยฎ Deployment

Use the Red Hat OpenShiftยฎ profile for deploying to OpenShift:

./mvnw clean package -Popenshift

Conclusion

The Aletyx Enterprise Build of Kogito and Drools Quarkus Maven Archetype provides a comprehensive starting point for building business automation applications with Kogito, jBPM, and Quarkus. By using this archetype, you can quickly set up a project with all the necessary components for workflow automation, decision management, and business rules processing.