NATS RealtimeTrigger

NATS RealtimeTrigger

Certified

Trigger on real-time NATS messages

Creates one execution per message fetched from a JetStream subject using explicit acks. Requires a stream for the rendered subject; defaults: deliverPolicy=All, batchSize=10. Use the batch io.kestra.plugin.nats.Trigger when you need windowed polling.

yaml
type: io.kestra.plugin.nats.core.RealtimeTrigger

Subscribe to a NATS subject, getting every message from the beginning of the subject on first trigger execution.

yaml
id: nats
namespace: company.team

tasks:
  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "{{ trigger.data }}"

triggers:
  - id: watch
    type: io.kestra.plugin.nats.core.RealtimeTrigger
    url: nats://localhost:4222
    username: nats_user
    password: "{{ secret('NATS_PASSWORD') }}"
    subject: kestra.trigger
    durableId: natsTrigger
    deliverPolicy: All
Properties
Min length1

Subject to subscribe to

Min length1

URL to connect to NATS server

The format is (nats://)server_url: port. You can also provide a connection token like so: nats://token@server_url: port

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

Default10
Minimum>= 1

Messages are fetched by batch of given size

Credentials files authentification

DefaultAll
Possible Values
AllLastNewByStartSequenceByStartTimeLastPerSubject

The point in the stream to receive messages from

Possible settings are:

  • All: The default policy. The consumer will start receiving from the earliest available message.
  • Last: When first consuming messages, the consumer will start receiving messages with the last message added to the stream, or the last message in the stream that matches the consumer's filter subject if defined.
  • New: When first consuming messages, the consumer will only start receiving messages that were created after the consumer was created.
  • ByStartSequence: When first consuming messages, start at the first message having the sequence number or the next one available.
  • ByStartTime: When first consuming messages, start with messages on or after this time. The consumer is required to specify since which defines this start time.
  • LastPerSubject: When first consuming messages, start with the latest one for each filtered subject currently in the stream.

ID used to attach the subscription to a durable one, allowing the subscription to start back from a previous position

Plaintext authentication password

Minimum message timestamp to start consumption from

By default, we consume all messages from the subjects starting from beginning of logs or depending on the current durable id position. You can also provide an arbitrary start time to get all messages since this date for a new durable id. Note that if you don't provide a durable id, you will retrieve all messages starting from this date even after subsequent usage of this task.Must be a valid iso 8601 date.

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

Token authentification

Plaintext authentication username

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

Data

Message payload as UTF-8 string.

SubTypearray

Headers

Message headers grouped by key.

Subject

Subject of the consumed message.

Formatdate-time

Timestamp

JetStream message timestamp.