New version 0.13.0!

v0.13.0

Services

Service Events

Since version 0.13.0, it's possible to access Infinitic internal events in a CloudEvents JSON format. These events serve various use cases, including:

  • Auditing
  • Building custom dashboards
  • Logging
  • Adding hooks to specific events
  • And more.

Event listeners

To retrieve the events related a specific service, you need to add an eventListener entry to your Service configuration file:

services:
  - name: example.booking.services.carRental.CarRentalService
    class: example.booking.services.carRental.CarRentalServiceImpl
    concurrency: 3
    eventListener:
      class: example.booking.services.Listener
      concurrency: 5

where:

  • class is the name of a class implementing the io.infinitic.cloudEvents.CloudEventListener interface.
  • concurrency (optional) specifies the number of events to be handled in parallel for this service. If not specified, the default value is the same as that for the service (3 in the example above).

To implement this interface, you need to add io.cloudevents:cloudevents-json-jackson to the dependencies of your project.

Alternatively, you can set a default event listener for all services of the worker:

serviceDefault:
    eventListener:
        class: example.booking.services.Listener

Or even, a default event listener for all services and workflows of the worker:

eventListener:
    class: example.booking.services.Listener

Implementation example

Here is an example of CloudEventListener implementation that writes the events to the standard output in json format:

Service events description

Here is a typical CloudEvent example:

{
  "specversion" : "1.0",
  "id" : "018dcb5f-aaa8-7bd3-92bd-ac1f0d52b2dd",
  "source" : "pulsar://localhost:6650/infinitic/test9/services/HelloService",
  "type" : "infinitic.task.completed",
  "datacontenttype" : "application/json",
  "subject" : "018dcb5f-aa4f-7187-8a9d-d656c4e13a1b",
  "time" : "2024-02-21T11:14:20.968Z",
  "data" : {
    "result" : "Hello 0!",
    "retrySequence" : 0,
    "retryIndex" : 0,
    "serviceName" : "HelloService",
    "taskName" : "addEnthusiasm",
    "taskMeta" : { },
    "taskTags" : [ ],
    "workerName" : "standalone-13907-104",
    "infiniticVersion" : "0.13.0"
  }
}

For all service events:

  • id serves as a unique identifier for the event.
  • subject denotes the task's ID.
  • time indicates the publishing time of the event.
  • type is prefixed with infinitic.task.*, where * corresponds to one of the following:
CloudEvent's type postfixTypeDescription
startCommandA task has been scheduled.
startedEventThe worker has begun processing the task.
completedEventSuccessful completion of the task by the worker.
retryScheduledEventThe task has failed and is scheduled for retry per the retry policy.
failedEventThe task did not succeed within the allowed retries as defined by the retry policy.
delegationCompletedEventSuccessful completion of a delegated task by the worker.

The data field contains the data below, as well as type-specific information:

Field NameTypeDescription
retrySequenceIntIndex of the number of manual retries.
retryIndexIntIndex of the number of automatic retries.
serviceNameStringName of the service (provided by the @Name class annotation or the class's name if not specified).
taskNameStringName of the task (provided by the @Name method annotation or the method's name if not specified).
taskMetaMap<String, ByteArray>Metadata of the task.
taskTagsArray<String>Tags associated with the task.
infiniticVersionStringVersion of Infinitic used by the entity that published the event (e.g., "0.13.0").

The source property describes the Pulsar cluster, tenant, and namespaces, as well as the service's name. However this property does not represent an actual Pulsar topic, as the events originate from multiple internal topics.

Previous
Service Versioning