Goal
Invoke a registered function on a running iii engine directly from the terminal, without writing application code or connecting an SDK.When to Use This
- Redriving dead-letter queue messages after fixing a bug
- Testing a function during development without wiring up a trigger
- Running one-off operational tasks against a live engine
- Scripting engine operations in CI/CD pipelines or shell scripts
Command Reference
| Flag | Required | Default | Description |
|---|---|---|---|
--function-id | Yes | — | The ID of the function to invoke (e.g. iii::queue::redrive, orders::process) |
--payload | Yes | — | A JSON string passed as the function’s input |
--address | No | localhost | The hostname or IP of the engine |
--port | No | 49134 | The engine’s WebSocket port |
Steps
Ensure the engine is running
The
iii trigger command connects to a running engine instance. If you don’t have one running yet, follow the Quickstart to get started.Identify the function ID
Every function registered with the engine has a unique ID. Builtin functions use the
iii:: prefix. User-defined functions use the ID you specified during registration.Examples of function IDs:iii::queue::redrive— builtin DLQ redriveorders::process-payment— a user-defined functionenqueue— the builtin topic-based enqueue function
Build the payload
The The CLI validates that the payload is valid JSON before connecting to the engine. Invalid JSON produces an immediate error.
--payload flag accepts a JSON string. This JSON becomes the function’s input — the same data it would receive if invoked via an SDK trigger() call.Targeting a Remote Engine
By default,iii trigger connects to localhost:49134. Use --address and --port to target a different engine instance:
How It Works
Theiii trigger command operates as a lightweight WebSocket client:
The CLI connects to the engine’s WebSocket endpoint (the same protocol SDKs use), waits for the WorkerRegistered handshake, sends an InvokeFunction message with the function ID and payload, and prints the InvocationResult when it arrives.
The WebSocket protocol is documented in the Protocol reference. The
iii trigger command uses the same InvokeFunction / InvocationResult message pair that all SDKs use.Examples
Redrive a dead-letter queue
Move all failed messages from thepayment queue’s DLQ back to the main queue:
For the full workflow of inspecting and redriving failed messages, see Use Dead Letter Queues.
Invoke a user-defined function
Trigger any function registered by your workers:Publish to a topic-based queue
Use the builtinenqueue function to publish a message to a topic:
Use in a shell script
Error Handling
| Scenario | Behavior |
|---|---|
Invalid JSON in --payload | Error printed immediately, no connection attempted |
| Engine not running (connection refused) | Error with the target address and port |
| Function not found | Engine returns a function_not_found error, printed to stderr |
| Function returns an error | Error body printed to stderr, exit code 1 |
| Connection drops before result | Error indicating the connection closed unexpectedly |
Next Steps
Trigger Actions
Compare synchronous, Void, and Enqueue invocation modes from SDKs
Dead Letter Queues
Inspect and redrive failed queue messages
Queue Module Reference
Full reference for builtin queue functions including
iii::queue::redriveProtocol Reference
WebSocket message catalog and envelope format