Setu-TS
    Preparing search index...

    A message broker backed by Cloudflare Queues.

    Consuming requires the application to export the handler createMessagingHandler builds, and the queue to be declared as a consumer in wrangler.toml:

    const app = createApplication({
    plugins: [
    RuntimePlugin({ env }),
    CloudflarePlugin({ env, messaging: { binding: 'MESSAGES' } }),
    ],
    });
    await app.start();

    const broker = app.services.get<IMessageBroker>(CAPABILITIES.MESSAGING);
    await broker.subscribe<{ id: string }>('user.created', async (user) => {
    await mailer.send(user.id);
    });

    export default { fetch: app.fetch, queue: createMessagingHandler(app) };

    0.2.0

    Implements

    Index
    • Dispatches one delivered batch into the registered subscribers and responders.

      Every message is acked or retried exactly once:

      • a body that is not a readable envelope → retry(), because a foreign producer or a version skew is a configuration problem and acking would discard the message permanently and silently;
      • a publish whose topic has no subscriber → ack(), because publishing to a topic nobody listens on is ordinary pub/sub, and retrying would burn the queue's retry budget and dead-letter every fire-and-forget message;
      • a publish whose handler throws → retry(), leaving the queue's own max_retries and dead-letter configuration to decide what happens next;
      • a request whose topic has no responder, or whose responder throws → ack() after sending the caller a failed reply, because the caller is waiting and a redelivery would re-run a handler that already ran.

      Parameters

      Returns Promise<void>

      Resolves once every message has been acked or retried