New in 0.16.2

v0.16.3

Event Listener

Events Listener

Infinitic internal events provide valuable insights into the execution of your workflows and services. Here are some common use cases for leveraging these events:

  • Auditing: Track every step of your workflow executions, including task completions, failures, and retries. This comprehensive audit trail can be crucial for compliance and debugging purposes.
  • Custom Dashboards: Build real-time dashboards to visualize the performance and status of your workflows and services. Monitor metrics such as execution times, success rates, and throughput.
  • Event-Driven Actions: Trigger custom actions or notifications based on specific events. For example, send alerts when a critical task fails or when a workflow completes successfully.
  • Performance Monitoring: Analyze event data to identify bottlenecks, optimize resource allocation, and improve overall system performance.
  • Business Intelligence: Gather insights about your business processes by analyzing workflow execution patterns and outcomes.
  • Integration with External Systems: Use events to synchronize Infinitic's state with external systems or databases, ensuring consistency across your entire infrastructure.
  • SLA Monitoring: Track events to ensure that your workflows and tasks are meeting defined Service Level Agreements (SLAs).
  • Workflow Versioning and Migration: Use events to manage and track different versions of workflows, facilitating smooth transitions between versions.

Event Listener Creation

Event listeners provide access to Infinitic's internal events in the standardized CloudEvents JSON format. This allows for easy integration with various systems and tools that support the CloudEvents specification.

The Cloud Events format is not the internal Infinitic format. It's intented to be used as an external format. This allows for internal updates without breaking changes.

You can create an Infinitic worker with an event listener using either:

  1. Java/Kotlin builders
  2. YAML configuration

To implement an event listener, you need to provide an implementation of the io.infinitic.cloudEvents.CloudEventListener interface. This interface requires an onEvents method with the following signature:

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

Targeting Services

By default, the event listener will provide events for all Services. It will automatically refresh the list of services on a regular basis (one minute by default).

You can restrict the events to specific services:

eventListener:
  class: example.MyEventListener
  concurrency: 50
  services:
    allow:
      - example.MyService
      - example.MyOtherService

or

Here only the MyService and MyOtherService services will be targeted.

At the opposite, you can target all services except some:

eventListener:
  class: example.MyEventListener
  concurrency: 50
  services:
    disallow:
      - example.MyService
      - example.MyOtherService

or

Targeting Workflows

The same logic applies to workflows. By default, the event listener will provide events for all workflows. It will automatically refresh the list of workflows on a regular basis (one minute by default).

You can restrict the events to specific workflows:

eventListener:
  class: example.MyEventListener
  concurrency: 50
  workflows:
    allow:
      - example.MyWorkflow
      - example.MyOtherWorkflow

or

Here only the MyWorkflow and MyOtherWorkflow workflows will be targeted.

At the opposite, you can target all workflows except some:

eventListener:
  class: example.MyEventListener
  concurrency: 50
  workflows:
    disallow:
      - example.MyWorkflow
      - example.MyOtherWorkflow

or

Here all workflows except the MyWorkflow and MyOtherWorkflow workflows will be targeted.

Implementation Example

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

Previous
Logging