Table of Contents

Class CloudEventEncodingSenderExtensions

Namespace
Excalibur.Dispatch.Transport
Assembly
Excalibur.Dispatch.Transport.Abstractions.dll

Applies outbound CloudEvents encoding to a transport sender.

public static class CloudEventEncodingSenderExtensions
Inheritance
CloudEventEncodingSenderExtensions
Inherited Members

Methods

WithCloudEventEncoding(ITransportSender)

Wraps a sender so that a message carrying a CloudEvent is published in the CloudEvents structured JSON mode.

public static ITransportSender WithCloudEventEncoding(this ITransportSender sender)

Parameters

sender ITransportSender

The sender to wrap.

Returns

ITransportSender

A sender that encodes attached CloudEvents before handing the message to the transport.

Remarks

Applied unconditionally, and that is safe because the encoding is opt-in per message. A message reaches the wire byte-identical unless it explicitly carries a CloudEvent, so wrapping a sender never alters ordinary business traffic. This differs from the inbound decorator, which is safe because decoding is total; here the safety comes from the caller having to ask.

Encoding uses structured mode, which carries the whole event as JSON in the body and identifies it by the content type alone. That makes the content type load-bearing, and it is why this wrapper is applied per transport rather than everywhere. A transport whose send path cannot carry a media type end to end — one whose native header for it is a fixed-width wire-format tag, for instance — will emit a body a conformant receiver cannot recognise as a CloudEvent, so it is not wrapped. Transports shipping a binary-mode encoder for their own protocol binding continue to use it; this wrapper is what gives a transport with neither a conformant send path at all.