Postboy Help

GenericMessage

A GenericMessage is the basic unit of communication in Postboy.

It represents something that happened, something that should be handled, or something that needs to be passed through the bus in a structured way. Instead of using loosely defined events or ad-hoc callbacks, Postboy uses messages as explicit, typed communication objects.

What a Message is for

A Message helps you:

  • define communication in a clear and typed way

  • separate event definition from event handling

  • keep the application flow predictable

  • make module interaction easier to maintain

Why it matters

In larger applications, communication often becomes difficult to follow. Messages help avoid that by turning the flow into something visible and intentional.

A message is not just “some data”. It is part of the architecture.

Message in Postboy

In Postboy, a Message usually acts as the starting point for a flow:

  1. the message is created

  2. it is published or executed through the bus

  3. one or more subscriptions react to it

  4. middleware can inspect or influence the process

  5. the flow continues toward a result, a callback, or another action

Key characteristics

A well-designed message in Postboy is typically:

  • typed — so payloads and contracts are explicit

  • structured — so handlers know what to expect

  • isolated — so one message type does not depend on unrelated logic

  • predictable — so the system behaves consistently

When to use a Message

Use a Message when you want to represent:

  • a domain event

  • a notification

  • a state transition

  • an application action

  • a request that should be handled by subscribers or executors

Message vs direct method calls

A direct method call says: “do this now”.

A Message says: “this happened, and whoever is interested can react to it”.

That small difference is important. It allows you to reduce coupling and keep communication more flexible.

In short

A Message is the foundation of Postboy’s event-driven model.
It gives your application a typed, explicit, and scalable way to communicate.

24 апреля 2026