Service Workers

Subscribe here to follow Infinitic's development. Please ⭐️ us on Github!

Infinitic provides a generic worker in charge of task or workflow execution based on its configuration. When configured to run a service, a worker will:

  • listen to Pulsar for messages intented for this service
  • deserialize parameters and process the requested task
  • serialize the return value and send it back.

When running, a worker catches any sent exception to automatically retry the task (see task failure).

Add a Log4j implementation to your project. Without, you will be blind in case of errors.

Do not start multiple workers with the same configuration on one machine, instead increase the concurrency settings. To increases throughput and resilience, just start multiple workers on multiple servers

Service workers can be scaled horizontally.

We can start a worker with:

import io.infinitic.factory.InfiniticWorkerFactory;
import io.infinitic.worker.InfiniticWorker;

public class App {
    public static void main(String[] args) {
        try(InfiniticWorker worker = InfiniticWorkerFactory.fromConfigFile("infinitic.yml")) {
import io.infinitic.factory.InfiniticWorkerFactory

fun main(args: Array<String>) {
    InfiniticWorkerFactory.fromConfigFile("infinitic.yml").use { worker ->

We can also use .fromConfigResource("/infinitic.yml") if the configuration file is located in the resource folder.

Here is an example of a valid infinitic.yml file:

# Optional
name: worker_name

  brokerServiceUrl: pulsar://localhost:6650
  webServiceUrl: http://localhost:8080
  tenant: infinitic
  namespace: dev

  - name:
    concurrency: 5
  - name:
    concurrency: 5
  - name:
    concurrency: 5

This configuration contains

  • a worker name (optional),
    When providing a worker name, this name must be unique among all our workers and clients connected to the same Pulsar namespace.
  • the Pulsar settings
  • and for each service:
namestringname of the service (its interface per default)
classstringname of the class to instantiate
concurrencyintegermaximum number of messages processed in parallel

A worker must be able to instantiate any class described in its configuration file.

Edit this page on GitHub Updated at Sat, Sep 10, 2022