Skip to content

Read and handle a delivery ​

A subscription method receives a ChoMessageContext. Use the topic to identify the event contract and the body to read its data. Returning from the method signals that your handling work finished, so await any write that must succeed before acknowledgment.

MemberValue for one delivery
topicComplete subscribed topic, including the prefix
valueRaw Uint8Array. Missing and null values produce zero bytes
keyOptional string
headersRead-only string dictionary. Missing headers produce an empty object
text()UTF-8 text, decoded lazily and cached
json<T>()Parsed JSON. An empty body yields undefined and invalid JSON throws
stateA fresh map shared between middleware and handler
nativeAdapter-provided delivery details, absent in manual delivery

Pick a body representation ​

For an image or encoded payload, use ctx.value directly. For plain text, use ctx.text(). For structured data, start with ctx.json<unknown>() and validate the shape before persisting it. Supplying a generic type only tells TypeScript what you expect. See the inventory consumer for a complete input check.

Finish, fail or publish ​

A normal return, including returning false from a subscription method, finishes the delivery successfully. Throw or reject to report failure. A return value has special meaning only in a message error handler.

To publish a follow-up event, inject a producer that your application owns, or use the broker adapter's publishing API. app.handle invokes a local handler directly. Kafka publishing

Released under the MIT License.