1. Tasks
  2. Heimdall Register - Event-Driven Task Triggering

Tasks

Heimdall Register - Event-Driven Task Triggering

Register tasks with Heimdall to execute actions based on event triggers

Heimdall Paths and Mechanisms form the basis of the registration task and are explained further in the Heimdall documentation.

Basic usage

In the following example, we are registering a task using Heimdall to update the subject of a stub every time a customer's balance is updated. This task will be triggered whenever the specified event occurs.

loading...

Detailed Description

Task Type

  • tasktype: Specifies the type of task to be registered. In this case, it is a Heimdall task registration.

Parameters (params)

  • uuid: A unique identifier for the task, generated deterministically using the stub reference. This ensures that the same task has the same UUID every time it is registered.

{{#deterministicuuid stub.stubref}}{{/deterministicuuid}}: Template syntax used to generate the UUID based on the stub reference.

  • registration_name: A human-readable name for the task registration. In this case, it's named heimdall_customer_account_balance_update to reflect the nature of the task.

  • on_trigger_method: Specifies how the task should behave when triggered. The value keep indicates that the task should remain registered and active even after being triggered.

Events (events) This section defines the events that will trigger the task. In this example, it listens for updates to customer account balances.

  • wait_for_customer_account_balance:
    • path: The event path that the task will listen to. It monitors updates to the balance of customer accounts. The [CUSTOMER_ACCOUNT_ID] placeholder will be dynamically replaced with the actual customer account ID.
    • mechanism: Specifies the event mechanism. Here, evt indicates that the event is an asynchronous event.
    • timeout_seconds: Defines the timeout period for the event in seconds. In this case, the timeout is set to 3600 seconds (1 hour).

Trigger Stub Action (trigger_stubaction) This section defines the action to be performed when the event is triggered.

  • action_name: The name of the action to be executed. _set_subject_on_stub is a predefined action that sets the subject on a stub.
  • stubref: A reference to the stub that will be updated. ~~stub.stubref uses a template to dynamically reference the stub.
  • data: Contains the data to be used in the action.
    • subject: The new subject to be set on the stub. It uses template syntax to include the customer account ID and the updated balance.

{{stubpost.data.customer_account_id}}: Template placeholder for the customer account ID.

{{stubpost.data.balance}}: Template placeholder for the updated account balance.

Parameters

uuid
required
string

The unique identifier of linked to this particular Heimdall registration.


registration_name
required
string

The human readable name of the registration. This is used to identify the registration.


on_trigger_method
optional
string

The method to use when the trigger is fired. Allows the user to specify whether to keep or remove the registration when the trigger is fired.

Options: keep | remove


events.[event_name].path
required
string

This is the path that will be monitored for triggers. * can be used as a wildcard in the path.

See also: Heimdall


events.[event_name].mechanism
required
string

The mechanism to use to fire the trigger.

Options: evt | cbh| rra| rnd| evb

Mechanism Description
evt Event
cbh Callback Handler
rra Round Robin Approach
rnd Random
evb Event Back

See also: Heimdall


events.[event_name].timeout_seconds
required
integer

The number of seconds that the registration will be active for. After this time the registration will be removed.


trigger_stubaction.action_name
required
string

The name of the stub action to trigger when the registration is fired.


trigger_stubaction.stubref
required
string

The stubref of the stub to trigger the action on.


trigger_stubaction.data
required
object

The data to pass to the stub action when it is triggered.


trigger_stubaction.message
required
string

The stub post message to pass to the stub action when it is triggered.

Result

loading...

Examples

Here are some more complex examples:

Send an minutely update to a stub

Task
loading...

See also: Heimdall: Standard Emitters