Skip to content

Class InMemoryTransportBinding

Namespace: Cephalon.Behaviors.Messaging.Bindings
Assembly: Cephalon.Behaviors.Messaging.dll

In-memory messaging transport binding (transport ID: “in-memory”). Uses a bounded with backpressure internally. No external dependencies — suitable for testing and local development.

public sealed class InMemoryTransportBinding : IMessagingBehaviorBinding, IAsyncDisposable

objectInMemoryTransportBinding

IMessagingBehaviorBinding, IAsyncDisposable

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

InMemoryTransportBinding(InMemoryTransportOptions, ILogger<InMemoryTransportBinding>)

Section titled “ InMemoryTransportBinding(InMemoryTransportOptions, ILogger<InMemoryTransportBinding>)”

Initializes a new instance of with the supplied options.

public InMemoryTransportBinding(InMemoryTransportOptions options, ILogger<InMemoryTransportBinding> logger)

options InMemoryTransportOptions

The in-memory transport options.

logger ILogger<InMemoryTransportBinding>

The logger for this binding.

Gets the canonical transport identifier (e.g. “rabbitmq”, “kafka”, “in-memory”).

public string TransportId { get; }

string

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

ValueTask

A task that represents the asynchronous dispose operation.

SendAsync(object, IBehaviorContext, CancellationToken)

Section titled “ SendAsync(object, IBehaviorContext, CancellationToken)”

Enqueues a message for dispatch. Safe to call from multiple threads. Will apply backpressure (async wait) when the channel reaches its configured capacity.

public Task SendAsync(object input, IBehaviorContext context, CancellationToken ct = default)

input object

The input message object.

context IBehaviorContext

The behavior execution context.

ct CancellationToken

A cancellation token.

Task

A task that completes when the message has been written to the channel.

StartAsync(BehaviorTopologyDescriptor, BehaviorDispatcher, CancellationToken)

Section titled “ StartAsync(BehaviorTopologyDescriptor, BehaviorDispatcher, CancellationToken)”

Starts consuming messages for the given behavior topology and dispatches them. Called once per descriptor per transport; implementations should be idempotent.

public Task StartAsync(BehaviorTopologyDescriptor descriptor, BehaviorDispatcher dispatcher, CancellationToken ct)

descriptor BehaviorTopologyDescriptor

The behavior topology descriptor.

dispatcher BehaviorDispatcher

The behavior dispatcher to invoke for each received message.

ct CancellationToken

A token that signals when the host is shutting down.

Task

A task that completes when the binding is fully started.

Stops the binding and releases transport resources.

public Task StopAsync(CancellationToken ct)

ct CancellationToken

A token that cancels the graceful-stop wait.

Task

A task that completes when the binding has fully stopped.