Job Service Quarkus Extensions

The interaction between the workflows and the Job Service is handled by the different Job Service Quarkus Extensions. Each extension is designed to work with a different communication alternative.

For example, you can select if your workflows must interact with the Job Service by sending cloud events over the knative eventing system or the kafka messaging system, or simply by executing direct REST calls.

Finally, for the interaction work, you must configure your Quarkus Workflow Project with the extension of your choice.

Quarkus Workflow Project And Extension

We recommend that you follow this procedure:

  1. Identify the communication alternative that best fits your scenario.

  2. Be sure that the Job Service is properly configured to support that alternative. This is very important if you want to use knative events or kafka messages to communicate with it.

  3. Configure your Quarkus Workflow Project with the corresponding extension.

If your workflows are not using timer-based actions, like timeouts, there is no need to add such an extension.

Knative eventing interaction

To interact with the Job Service by sending cloud events over the knative eventing system you must follow these steps:

  1. Be sure that you have read the Consuming and producing events on Knative Eventing guide, and that you have configured the project accordingly.

  2. Add the kogito-addons-quarkus-jobs-knative-eventing extension to your Quarkus Workflow Project using any of the following alternatives:

  • Manually

  • Apache Maven

  • Quarkus CLI

<dependency>
    <groupId>org.kie.kogito</groupId>
    <artifactId>kogito-addons-quarkus-jobs-knative-eventing</artifactId>
</dependency>
mvn quarkus:add-extension -Dextensions="kogito-addons-quarkus-jobs-knative-eventing"
quarkus extension add kogito-addons-quarkus-jobs-knative-eventing
  1. Add the following configurations to the application.properties file of your project.

mp.messaging.outgoing.kogito-job-service-job-request-events.connector=quarkus-http
mp.messaging.outgoing.kogito-job-service-job-request-events.url=${K_SINK:http://localhost:8280/v2/jobs/events}
mp.messaging.outgoing.kogito-job-service-job-request-events.method=POST

The K_SINK environment variable is automatically generated by the combination of the knative ecosystem and the SinkBinding definition that will be automatically generated in the kogito.yml file.

If this variable is not present, the default value http://localhost:8280/v2/jobs/events is used instead, this can be useful in development environments if you are executing the Job Service as a standalone service.

  1. Build your project and locate the automatically generated kogito.yml and knative.yml files in the /target/kubernetes directory of your project, see.

mvn clean install
  1. Use the generated files to deploy your workflow application in the Kubernetes cluster using the following commands:

kubectl apply -f target/kogito.yml

kubectl apply -f target/knative.yml

You can see a full example of this interaction mode configuration in the Quarkus Workflow Project with standalone services example project.

Kafka messaging interaction

To interact with the Job Service by sending cloud events over the kafka messaging system you must follow these steps:

  1. Be sure that you have read the Consuming and producing events with Kafka guide, and you have configured the project accordingly.

  2. Add the quarkus-smallrye-reactive-messaging-kafka and kogito-addons-quarkus-jobs-messaging extensions to your Quarkus Workflow Project using any of the following alternatives.

  • Manually

  • Apache Maven

  • Quarkus CLI

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
</dependency>
<dependency>
    <groupId>org.kie.kogito</groupId>
    <artifactId>kogito-addons-quarkus-jobs-messaging</artifactId>
</dependency>
mvn quarkus:add-extension -Dextensions="quarkus-smallrye-reactive-messaging-kafka,kogito-addons-quarkus-jobs-messaging"
quarkus extension add quarkus-smallrye-reactive-messaging-kafka kogito-addons-quarkus-jobs-messaging
  1. Add the following configurations to the application.properties file of your project.

mp.messaging.outgoing.kogito-job-service-job-request-events.connector=smallrye-kafka
mp.messaging.outgoing.kogito-job-service-job-request-events.topic=kogito-job-service-job-request-events-v2
mp.messaging.outgoing.kogito-job-service-job-request-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer
  1. Build and deploy your workflow application using any of the available procedures.

REST call interaction

To interact with the Job Service by executing direct REST calls you must follow these steps:

  1. Add the kogito-addons-quarkus-jobs-management extension to your Quarkus Workflow Project using any of the following alternatives.

  • Manually

  • Apache Maven

  • Quarkus CLI

<dependency>
    <groupId>org.kie.kogito</groupId>
    <artifactId>kogito-addons-quarkus-jobs-management</artifactId>
</dependency>
mvn quarkus:add-extension -Dextensions="kogito-addons-quarkus-jobs-management"
quarkus extension add kogito-addons-quarkus-jobs-management
  1. Add the following configuration to the application.properties file of your project.

kogito.jobs-service.url=http://localhost:8280

When you deploy your project in a Kubernetes cluster, you must configure the kogito.jobs-service-url with the cloud URL of the Job Service. In this case, you can also use an environment variable with the name KOGITO_JOBS_SERVICE_URL and pass it to the corresponding container, etc.

  1. Build and deploy your workflow application using any of the available procedures.

Job Service Embedded

To facilitate the development and testing stage of your workflows, this extension provides an embedded Job Service instance that executes in the same runtime as your workflows, and thus, requires no additional configurations. The only consideration is that it must not be used for production installations.

To use this extension you must:

  1. Add the kogito-addons-quarkus-jobs-service-embedded extension to your Quarkus Workflow Project using any of the following alternatives.

  • Manually

  • Apache Maven

  • Quarkus CLI

<dependency>
    <groupId>org.kie.kogito</groupId>
    <artifactId>kogito-addons-quarkus-jobs-service-embedded</artifactId>
</dependency>
mvn quarkus:add-extension -Dextensions="kogito-addons-quarkus-jobs-management"
quarkus extension add kogito-addons-quarkus-jobs-management
  1. Build and deploy your workflow application using any of the available procedures.

You can see a full example of Job Service embedded usage in the Quarkus Workflow Project with embedded services example project.

Found an issue?

If you find an issue or any misleading information, please feel free to report it here. We really appreciate it!