use serde_json::json;
use zeebe::{Client, Job};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_env_filter("zeebe=trace")
.init();
let client = Client::default();
client
.deploy_process()
.with_resource_file("examples/workflows/order-process.bpmn")
.send()
.await?;
client
.create_process_instance()
.with_bpmn_process_id("order-process")
.with_latest_version()
.with_variables(json!({"orderId": 31243}))
.send()
.await?;
client
.job_worker()
.with_job_type("payment-service")
.with_handler(handle_job)
.run()
.await?;
Ok(())
}
async fn handle_job(client: Client, job: Job) {
tracing::info!("working on job!");
let _ = client.complete_job().with_job_key(job.key()).send().await;
}