airflow.providers.ibm.mq.triggers.mq

Classes

AwaitMessageTrigger

Trigger that polls an IBM MQ queue and fires a TriggerEvent when a message arrives.

Module Contents

class airflow.providers.ibm.mq.triggers.mq.AwaitMessageTrigger(mq_conn_id, queue_name, poll_interval=5, open_options=None)[source]

Bases: airflow.triggers.base.BaseEventTrigger

Trigger that polls an IBM MQ queue and fires a TriggerEvent when a message arrives.

Delegates to IBMMQHook.aconsume() which retries with exponential back-off on transient failures so that an AssetWatcher is never silently killed by a broken connection or swallowed exception.

The trigger consumes messages with MQGMO_NO_SYNCPOINT, so it provides at-most-once delivery semantics. If the trigger is canceled after IBM MQ returns a message but before Airflow yields the corresponding TriggerEvent, that message may be lost.

Parameters:
  • mq_conn_id (str) – Airflow connection id for the IBM MQ broker.

  • queue_name (str) – Name of the IBM MQ queue to consume from.

  • poll_interval (float) – Seconds between MQ get attempts inside the hook.

  • open_options (int | None) – Optional integer bitmask of MQOO_* flags for queue open.

mq_conn_id[source]
queue_name[source]
poll_interval = 5[source]
open_options = None[source]
serialize()[source]

Return the information needed to reconstruct this Trigger.

Returns:

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type:

tuple[str, dict[str, Any]]

async run()[source]

Run the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

Was this entry helpful?