Postboy Help

CallbackMessage

A CallbackMessage is a message that expects a reaction with a result.

Unlike a regular Message, which is often used for broadcasting information or triggering a flow, a CallbackMessage is used when the sender needs something back: a response, a decision, or an outcome.

What it is for

CallbackMessage is useful when communication is not one-way.

It helps you model scenarios where:

  • a message is sent

  • someone reacts to it

  • a result is produced

  • the sender continues based on that result

This makes it a good fit for controlled interactions where the flow should remain explicit and typed.

Why it matters

In many applications, not every event is just a notification. Sometimes the system needs to answer.

Without a dedicated model for that kind of flow, callback logic can become scattered, inconsistent, or hard to follow. CallbackMessage keeps it structured.

How it works in Postboy

A typical callback flow looks like this:

  1. a CallbackMessage is created

  2. it is sent through the bus

  3. a subscriber handles it

  4. the handler returns a result

  5. the sender receives that result and continues

This allows Postboy to support event-driven communication without losing the ability to work with responses.

Key characteristics

CallbackMessage is typically:

  • typed — the request and response shape stay explicit

  • controlled — the flow is not left to ad-hoc callback chaining

  • predictable — the response path is part of the architecture

  • composable — it can still work with middleware and other Postboy mechanisms

When to use a CallbackMessage

Use a CallbackMessage when:

  • the sender needs a result

  • the reaction should return a value

  • the flow depends on the outcome of handling

  • you want a structured alternative to manual callback passing

CallbackMessage vs regular Message

A regular Message usually says: “something happened”.

A CallbackMessage says: “something happened, and I need a response”.

That difference makes it especially useful for request-like flows inside an event-driven architecture.

In short

CallbackMessage is Postboy’s way of handling event-driven flows that need a response.
It keeps the interaction typed, explicit, and easier to reason about.

24 апреля 2026