Event Sources

Integrate various event producers using Apache Camel Kamelets

Event Sources provide a flexible way to integrate various event producers into your system using Apache Camel Kamelets. Event Sources capture events from external systems and publish them as CloudEvents to NATS JetStream.

Configuration Format

Event sources are configured using YAML files:

apiVersion: weik.io/v1alpha1
kind: EventSource
metadata:
  name: file-watch-test
  description: Watch for file changes in a dir
spec:
  type: file-watch
  parameters:
    filePath: "/tmp/eventdatatest"
    events: "CREATE,MODIFY"
  eventType: weikio.file.${header.CamelFileEventType}

Applying Configuration

Use the Weikio CLI to apply event source configurations:

weikio config apply filename.yaml

API Endpoints

  1. GET /eventsources/configurations

    • Returns all event sources
    • Requires “EventSource.Read” policy
  2. GET /eventsources/configurations/{name}

    • Returns a specific event source by name
    • Requires “EventSource.Read” policy

Event Source Types

Event sources are based on Apache Camel Kamelets. You can use any source Kamelet from the Apache Camel Kamelet catalog.

File Watch Source

apiVersion: weik.io/v1alpha1
kind: EventSource
metadata:
  name: file-watch-test
  description: Watch for file changes in a dir
spec:
  type: file-watch
  parameters:
    filePath: "/tmp/eventdatatest"
    events: "CREATE,MODIFY"
  eventType: weikio.file.${header.CamelFileEventType}

NATS Source

apiVersion: weik.io/v1alpha1
kind: EventSource
metadata:
  name: nats-events
  description: Listen for NATS messages
spec:
  type: nats-source
  parameters:
    servers: "nats://localhost:4222"
    topic: "events.>"
    queueGroup: "event-source-group"

AWS S3 Source

apiVersion: weik.io/v1alpha1
kind: EventSource
metadata:
  name: s3-events
  description: Monitor AWS S3 bucket for changes
spec:
  type: aws-s3-source
  parameters:
    bucketNameOrArn: "my-bucket"
    region: "eu-west-1"
    accessKey: "{{accessKey}}"
    secretKey: "{{secretKey}}"
  variables:
    - accessKey: "{{sys:AWS_ACCESS_KEY}}"
    - secretKey: "{{sys:AWS_SECRET_KEY}}"

Event Processing

When an event source is configured:

  1. A NATS JetStream stream is automatically created

    • Stream name: eventsource-{name}-stream
    • Subject: eventsource.{name}
    • Republish configuration to eventsourceprocessing.{name}
  2. An Integration Flow is created using the specified Kamelet

    • Flow connects the event source to the NATS stream
    • Events are converted to CloudEvents
    • CloudEvents are published to the NATS stream

Integration with Other Features

Variables Support

Event sources can use variables in their configurations:

apiVersion: weik.io/v1alpha1
kind: EventSource
metadata:
  name: s3-events
spec:
  type: aws-s3-source
  parameters:
    bucketNameOrArn: "my-bucket"
    accessKey: "{{accessKey}}"
    secretKey: "{{secretKey}}"
  variables:
    - accessKey: "{{sys:AWS_ACCESS_KEY}}"
    - secretKey: "{{sys:AWS_SECRET_KEY}}"

User Interface

Event Sources can be managed through the web interface:

  1. Navigate to Eventing > Event Sources in the sidebar
  2. The interface displays all configured event sources with:
    • Name and description
    • Source type
    • Creation date
    • Detailed view with tabbed interface showing:
      • Parameters configuration
      • Variables
      • CloudEvents generated by the source