Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Subscribe

Subscribe to workflow messages via the client channel.

Subscribe to Messages

#![allow(unused)]
fn main() {
use acts_channel::{ActsChannel, ActsOptions};

let mut client = ActsChannel::connect("http://127.0.0.1:10080").await?;

// ActsOptions fields support glob patterns, e.g. "act*" matches every message
// starting with "act"
let options = ActsOptions {
    state: Some("{created,completed}".to_string()),
    r#type: Some("act*".to_string()),
    ..ActsOptions::default()
};

let sub = client
    .subscribe(
        "client-1",
        move |message| {
            println!("{message:?}");
        },
        // faults that do not end the feed: decode failures, failed auto-acks
        move |err| eprintln!("subscription fault: {err}"),
        &options,
    )
    .await?;

// the end of the feed: Ok(()) on a clean close, Err(status) on a failure
if let Err(err) = sub.wait().await {
    eprintln!("subscription closed: {err}");
}
}

The id is a namespace component of the caller’s subject on the server ({subject}/{client_id}): two subscribers of different subjects can both subscribe as client-1 without colliding, and under [acl] a subscription carries the messages of the processes that subject started, not every tenant’s. See access control.

Message Types

TypeDescription
workflowWorkflow-level message
stepStep-level message
actaction message