Table of Contents

Class BusInstance<TBus>

Namespace
MassTransit
Assembly
MassTransit.Abstractions.dll

When configuring multiple bus instances in a single container (MultiBus), this base class should be used as a the base for the additional bus instance type.

public abstract class BusInstance<TBus> : IBusControl, IBus, IPublishEndpoint, IPublishEndpointProvider, IPublishObserverConnector, ISendEndpointProvider, ISendObserverConnector, IConsumePipeConnector, IRequestPipeConnector, IConsumeMessageObserverConnector, IConsumeObserverConnector, IReceiveObserverConnector, IReceiveEndpointObserverConnector, IReceiveConnector, IEndpointConfigurationObserverConnector, IProbeSite where TBus : class, IBus

Type Parameters

TBus

The specific bus interface type for this bus instance

Inheritance
BusInstance<TBus>
Implements
Inherited Members
Extension Methods

Constructors

BusInstance(IBusControl)

protected BusInstance(IBusControl busControl)

Parameters

busControl IBusControl

Properties

Address

The InputAddress of the default bus endpoint

public Uri Address { get; }

Property Value

Uri

Topology

The bus topology

public IBusTopology Topology { get; }

Property Value

IBusTopology

Methods

CheckHealth()

Returns the health of the bus, including all receive endpoints

public BusHealthResult CheckHealth()

Returns

BusHealthResult

ConnectConsumeMessageObserver<T>(IConsumeMessageObserver<T>)

public ConnectHandle ConnectConsumeMessageObserver<T>(IConsumeMessageObserver<T> observer) where T : class

Parameters

observer IConsumeMessageObserver<T>

Returns

ConnectHandle

Type Parameters

T

ConnectConsumeObserver(IConsumeObserver)

public ConnectHandle ConnectConsumeObserver(IConsumeObserver observer)

Parameters

observer IConsumeObserver

Returns

ConnectHandle

ConnectConsumePipe<T>(IPipe<ConsumeContext<T>>)

public ConnectHandle ConnectConsumePipe<T>(IPipe<ConsumeContext<T>> pipe) where T : class

Parameters

pipe IPipe<ConsumeContext<T>>

Returns

ConnectHandle

Type Parameters

T

ConnectConsumePipe<T>(IPipe<ConsumeContext<T>>, ConnectPipeOptions)

public ConnectHandle ConnectConsumePipe<T>(IPipe<ConsumeContext<T>> pipe, ConnectPipeOptions options) where T : class

Parameters

pipe IPipe<ConsumeContext<T>>
options ConnectPipeOptions

Returns

ConnectHandle

Type Parameters

T

ConnectEndpointConfigurationObserver(IEndpointConfigurationObserver)

Connect a configuration observer to the bus configurator, which is invoked as consumers are configured.

public ConnectHandle ConnectEndpointConfigurationObserver(IEndpointConfigurationObserver observer)

Parameters

observer IEndpointConfigurationObserver

Returns

ConnectHandle

ConnectPublishObserver(IPublishObserver)

public ConnectHandle ConnectPublishObserver(IPublishObserver observer)

Parameters

observer IPublishObserver

Returns

ConnectHandle

ConnectReceiveEndpoint(IEndpointDefinition, IEndpointNameFormatter?, Action<IReceiveEndpointConfigurator>?)

Adds a receive endpoint

public HostReceiveEndpointHandle ConnectReceiveEndpoint(IEndpointDefinition definition, IEndpointNameFormatter? endpointNameFormatter, Action<IReceiveEndpointConfigurator>? configureEndpoint = null)

Parameters

definition IEndpointDefinition

An endpoint definition, which abstracts specific endpoint behaviors from the transport

endpointNameFormatter IEndpointNameFormatter
configureEndpoint Action<IReceiveEndpointConfigurator>

The configuration callback

Returns

HostReceiveEndpointHandle

ConnectReceiveEndpoint(string, Action<IReceiveEndpointConfigurator>?)

Adds a receive endpoint

public HostReceiveEndpointHandle ConnectReceiveEndpoint(string queueName, Action<IReceiveEndpointConfigurator>? configureEndpoint)

Parameters

queueName string

The queue name for the receive endpoint

configureEndpoint Action<IReceiveEndpointConfigurator>

The configuration callback

Returns

HostReceiveEndpointHandle

ConnectReceiveEndpointObserver(IReceiveEndpointObserver)

public ConnectHandle ConnectReceiveEndpointObserver(IReceiveEndpointObserver observer)

Parameters

observer IReceiveEndpointObserver

Returns

ConnectHandle

ConnectReceiveObserver(IReceiveObserver)

Connect an observer to the receiving endpoint

public ConnectHandle ConnectReceiveObserver(IReceiveObserver observer)

Parameters

observer IReceiveObserver

Returns

ConnectHandle

ConnectRequestPipe<T>(Guid, IPipe<ConsumeContext<T>>)

Connect the consume pipe to the pipeline for messages with the specified RequestId header

public ConnectHandle ConnectRequestPipe<T>(Guid requestId, IPipe<ConsumeContext<T>> pipe) where T : class

Parameters

requestId Guid
pipe IPipe<ConsumeContext<T>>

Returns

ConnectHandle

Type Parameters

T

ConnectSendObserver(ISendObserver)

public ConnectHandle ConnectSendObserver(ISendObserver observer)

Parameters

observer ISendObserver

Returns

ConnectHandle

GetPublishSendEndpoint<T>()

Return the SendEndpoint used for publishing the specified message

public Task<ISendEndpoint> GetPublishSendEndpoint<T>() where T : class

Returns

Task<ISendEndpoint>

Type Parameters

T

GetSendEndpoint(Uri)

Return the send endpoint for the specified address

public Task<ISendEndpoint> GetSendEndpoint(Uri address)

Parameters

address Uri

The endpoint address

Returns

Task<ISendEndpoint>

The send endpoint

Probe(ProbeContext)

public void Probe(ProbeContext context)

Parameters

context ProbeContext

Publish(object, IPipe<PublishContext>, CancellationToken)

Publishes an object as a message, using the message type specified. If the object cannot be cast to the specified message type, an exception will be thrown.

public Task Publish(object message, IPipe<PublishContext> publishPipe, CancellationToken cancellationToken = default)

Parameters

message object

The message object

publishPipe IPipe<PublishContext>
cancellationToken CancellationToken

Returns

Task

Publish(object, CancellationToken)

Publishes an object as a message, using the message type specified. If the object cannot be cast to the specified message type, an exception will be thrown.

public Task Publish(object message, CancellationToken cancellationToken = default)

Parameters

message object

The message object

cancellationToken CancellationToken

Returns

Task

Publish(object, Type, IPipe<PublishContext>, CancellationToken)

Publishes an object as a message, using the message type specified. If the object cannot be cast to the specified message type, an exception will be thrown.

public Task Publish(object message, Type messageType, IPipe<PublishContext> publishPipe, CancellationToken cancellationToken = default)

Parameters

message object

The message object

messageType Type

The type of the message (use message.GetType() if desired)

publishPipe IPipe<PublishContext>
cancellationToken CancellationToken

Returns

Task

Publish(object, Type, CancellationToken)

Publishes an object as a message, using the message type specified. If the object cannot be cast to the specified message type, an exception will be thrown.

public Task Publish(object message, Type messageType, CancellationToken cancellationToken = default)

Parameters

message object

The message object

messageType Type

The type of the message (use message.GetType() if desired)

cancellationToken CancellationToken

Returns

Task

Publish<T>(object, IPipe<PublishContext<T>>, CancellationToken)

Publish<T>(T, CancellationToken): this overload further takes an action; it allows you to set PublishContext meta-data. Also Publish<T>(T, CancellationToken).

public Task Publish<T>(object values, IPipe<PublishContext<T>> publishPipe, CancellationToken cancellationToken = default) where T : class

Parameters

values object

The dictionary of values to become hydrated and published under the type of the interface.

publishPipe IPipe<PublishContext<T>>
cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The type of the message to publish

Publish<T>(object, IPipe<PublishContext>, CancellationToken)

Publish<T>(T, CancellationToken): this overload further takes an action; it allows you to set PublishContext meta-data. Also Publish<T>(T, CancellationToken).

public Task Publish<T>(object values, IPipe<PublishContext> publishPipe, CancellationToken cancellationToken = default) where T : class

Parameters

values object

The dictionary of values to become hydrated and published under the type of the interface.

publishPipe IPipe<PublishContext>
cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The type of the message to publish

Publish<T>(object, CancellationToken)

Publish<T>(T, CancellationToken): this is a "dynamically" typed overload - give it an interface as its type parameter, and a loosely typed dictionary of values and the MassTransit underlying infrastructure will populate an object instance with the passed values. It actually does this with DynamicProxy in the background.

public Task Publish<T>(object values, CancellationToken cancellationToken = default) where T : class

Parameters

values object

The dictionary of values to place in the object instance to implement the interface.

cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The type of the interface or non-sealed class with all-virtual members.

Publish<T>(T, IPipe<PublishContext<T>>, CancellationToken)

Publishes a message to all subscribed consumers for the message type as specified by the generic parameter. The second parameter allows the caller to customize the outgoing publish context and set things like headers on the message.

Read up on publishing: http://readthedocs.org/docs/masstransit/en/latest/overview/publishing.html

public Task Publish<T>(T message, IPipe<PublishContext<T>> publishPipe, CancellationToken cancellationToken = default) where T : class

Parameters

message T

The messages to be published

publishPipe IPipe<PublishContext<T>>
cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The type of the message

Publish<T>(T, IPipe<PublishContext>, CancellationToken)

Publishes a message to all subscribed consumers for the message type as specified by the generic parameter. The second parameter allows the caller to customize the outgoing publish context and set things like headers on the message.

Read up on publishing: http://readthedocs.org/docs/masstransit/en/latest/overview/publishing.html

public Task Publish<T>(T message, IPipe<PublishContext> publishPipe, CancellationToken cancellationToken = default) where T : class

Parameters

message T

The messages to be published

publishPipe IPipe<PublishContext>
cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The type of the message

Publish<T>(T, CancellationToken)

Publishes a message to all subscribed consumers for the message type as specified by the generic parameter. The second parameter allows the caller to customize the outgoing publish context and set things like headers on the message.

Read up on publishing: http://readthedocs.org/docs/masstransit/en/latest/overview/publishing.html

public Task Publish<T>(T message, CancellationToken cancellationToken = default) where T : class

Parameters

message T

The messages to be published

cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The type of the message

StartAsync(CancellationToken)

Starts the bus (assuming the battery isn't dead). Once the bus has been started it cannot be started again, even after it has been stopped.

public Task<BusHandle> StartAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<BusHandle>

The BusHandle for the started bus. This is no longer needed, as calling Stop on the IBusControl will stop the bus equally well.

StopAsync(CancellationToken)

Stops the bus if it has been started. If the bus hasn't been started, the method returns without any warning.

public Task StopAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task