// 03_broker_server — ROUTER/DEALER request/reply broker with capture.
//
// Frontend (ROUTER on :5559) faces REQ clients; backend (DEALER on :5560)
// faces REP workers. proxy_with_capture forwards messages in both directions
// and tees a copy of every frame onto the PUB capture socket (:9999) so
// observers can subscribe without disturbing the live flow.
//
// Run alongside 02_multipart_client (REQ → :5559) and 02_multipart_server
// (REP → :5560).
use rustzmq2::prelude::*;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let mut frontend = rustzmq2::RouterSocket::new();
frontend.bind("tcp://127.0.0.1:5559").await?;
let mut backend = rustzmq2::DealerSocket::new();
backend.bind("tcp://127.0.0.1:5560").await?;
let mut capture = rustzmq2::PubSocket::new();
capture.bind("tcp://127.0.0.1:9999").await?;
rustzmq2::proxy_with_capture(frontend, backend, capture).await?;
Ok(())
}