Operations
A receive operation reports its queue group in the nats binding, the one field that binding has.
The binding is {"queue": "<group>", "bindingVersion": "0.1.0"}.
The group is the one queue_group names on a CoreSubject or a CoreWildcard.
A subscription outside a queue group carries no binding.
A JetStream consumer carries none either: its durable name and its other settings are on the channel.
Example
The operation receive_orders_created reports the queue group workers.
- Macros
- Manual
#[subscriber(CoreSubject::new("orders.created").queue_group("workers"))]
async fn confirm(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "order confirmed");
HandlerOutcome::ack()
}
struct Confirm;
impl Handle<Order> for Confirm {
fn handle(
&self,
order: &Order,
_outs: &(),
_ctx: &mut Context<'_>,
) -> impl Future<Output = Result<(), HandlerOutcome>> {
tracing::info!(order.id, "order confirmed");
ready(Ok(()))
}
}
/// Core NATS subject `orders.created`, shared by the queue group `workers`.
fn created() -> CoreSubject {
CoreSubject::new("orders.created").queue_group("workers")
}