You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AsyncAPI v3: support receiving multiple messages per operation (follow-up to #140) #333
Follow-up to #140. The send side of multiple-messages-per-operation shipped in #332 (PR), which generates one SendAs<Op>For<Message> function per message. This issue tracks the remaining receive side.
Goal
When an operation (or its channel) declares more than one message, generate a way to receive each message type. Per the agreed design:
API shape: per-message methods — e.g. SubscribeToXForUserCreated(ctx, fn func(ctx, UserCreatedMessage) error) and SubscribeToXForUserDeleted(...), one subscriber callback per message. Single-message operations stay unchanged.
Discrimination: try-each-until-valid — on receive, attempt to unmarshal + validate the raw broker message against each candidate message schema and dispatch to the first that fits. This is heuristic and can be ambiguous when schemas overlap (acknowledged trade-off).
Two per-message SubscribeToXForA / SubscribeToXForB calls on the same channel address would therefore collide. Supporting per-message receive requires reworking subscription management, for example one of:
Key subscriptions by addr + message (allowing several broker subscriptions per channel, each filtering to its message type); or
A single per-address subscription that multiplexes/dispatches to the registered per-message handlers.
Scope / acceptance
Per-message subscribe functions for multi-message operations (single-message unchanged, byte-identical output).
Try-each-until-valid discrimination on receive (unmarshal + validate).
Subscription-management rework so multiple per-message subscriptions on one channel don't collide.
Decide ack/nak semantics when a received message matches none of the expected types.
Regression test (ideally broker-backed in CI) covering dispatch of two distinct message types on one channel.
Notes
Channel.GetMessage was made deterministic in #332 and Operation.GetMessages() already returns all messages sorted by name, so the data layer is ready. The reply/request path with multiple messages is a further edge case to consider separately.
Activity
feat(v3): support receiving multiple messages per operation (#333) (#336