Show / Hide Table of Contents

    Class Broker<TProducerEndpoint, TConsumerEndpoint>

    The base class for all IBroker implementations.

    Inheritance
    object
    Broker<TProducerEndpoint, TConsumerEndpoint>
    KafkaBroker
    MqttBroker
    RabbitBroker
    TransactionalOutboxBroker
    Implements
    IBroker
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Messaging.Broker
    Assembly: Silverback.Integration.dll
    Syntax
    public abstract class Broker<TProducerEndpoint, TConsumerEndpoint> : IBroker, IDisposable where TProducerEndpoint : IProducerEndpoint where TConsumerEndpoint : IConsumerEndpoint
    Type Parameters
    Name Description
    TProducerEndpoint

    The type of the IProducerEndpoint that is being handled by this broker implementation.

    TConsumerEndpoint

    The type of the IConsumerEndpoint that is being handled by this broker implementation.

    Constructors

    | Improve this doc View source

    Broker(IServiceProvider)

    Initializes a new instance of the Broker<TProducerEndpoint, TConsumerEndpoint> class.

    Declaration
    protected Broker(IServiceProvider serviceProvider)
    Parameters
    Type Name Description
    IServiceProvider serviceProvider

    The IServiceProvider to be used to resolve the required services.

    Properties

    | Improve this doc View source

    ConsumerEndpointType

    Gets the type of the IConsumerEndpoint that is being handled by this broker implementation.

    Declaration
    public Type ConsumerEndpointType { get; }
    Property Value
    Type Description
    Type
    | Improve this doc View source

    Consumers

    Gets the collection of IConsumer that have been created so far.

    Declaration
    public IReadOnlyList<IConsumer> Consumers { get; }
    Property Value
    Type Description
    IReadOnlyList<IConsumer>
    | Improve this doc View source

    IsConnected

    Gets a value indicating whether this broker is currently connected.

    Declaration
    public bool IsConnected { get; }
    Property Value
    Type Description
    bool
    | Improve this doc View source

    ProducerEndpointType

    Gets the type of the IProducerEndpoint that is being handled by this broker implementation.

    Declaration
    public Type ProducerEndpointType { get; }
    Property Value
    Type Description
    Type
    | Improve this doc View source

    Producers

    Gets the collection of IProducer that have been created so far.

    Declaration
    public IReadOnlyList<IProducer> Producers { get; }
    Property Value
    Type Description
    IReadOnlyList<IProducer>

    Methods

    | Improve this doc View source

    AddConsumer(IConsumerEndpoint)

    Adds an IConsumer that will consume from the specified endpoint as soon as the broker is connected. The received messages will be forwarded to the specified callback delegate.

    Declaration
    public virtual IConsumer AddConsumer(IConsumerEndpoint endpoint)
    Parameters
    Type Name Description
    IConsumerEndpoint endpoint

    The source endpoint.

    Returns
    Type Description
    IConsumer

    The IConsumer for the specified endpoint.

    | Improve this doc View source

    ConnectAsync()

    Connect to the message broker to start consuming.

    Declaration
    public Task ConnectAsync()
    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    | Improve this doc View source

    ConnectAsync(IReadOnlyCollection<IProducer>, IReadOnlyCollection<IConsumer>)

    Connects all the consumers and starts consuming.

    Declaration
    protected virtual Task ConnectAsync(IReadOnlyCollection<IProducer> producers, IReadOnlyCollection<IConsumer> consumers)
    Parameters
    Type Name Description
    IReadOnlyCollection<IProducer> producers

    The producers to be connected.

    IReadOnlyCollection<IConsumer> consumers

    The consumers to be connected and started.

    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    | Improve this doc View source

    DisconnectAsync()

    Disconnect from the message broker to stop consuming.

    Declaration
    public Task DisconnectAsync()
    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    | Improve this doc View source

    DisconnectAsync(IReadOnlyCollection<IProducer>, IReadOnlyCollection<IConsumer>)

    Disconnects all the consumers and stops consuming.

    Declaration
    protected virtual Task DisconnectAsync(IReadOnlyCollection<IProducer> producers, IReadOnlyCollection<IConsumer> consumers)
    Parameters
    Type Name Description
    IReadOnlyCollection<IProducer> producers

    The producers to be disconnected.

    IReadOnlyCollection<IConsumer> consumers

    The consumers to be stopped and disconnected.

    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    | Improve this doc View source

    Dispose()

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

    Declaration
    public void Dispose()
    | Improve this doc View source

    Dispose(bool)

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

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    A value indicating whether the method has been called by the Dispose method and not from the finalizer.

    | Improve this doc View source

    GetProducer(IProducerEndpoint)

    Returns an IProducer to be used to produce to the specified endpoint.

    Declaration
    public virtual IProducer GetProducer(IProducerEndpoint endpoint)
    Parameters
    Type Name Description
    IProducerEndpoint endpoint

    The target endpoint.

    Returns
    Type Description
    IProducer

    The IProducer for the specified endpoint.

    | Improve this doc View source

    GetProducer(string)

    Returns an IProducer to be used to produce to the specified endpoint.

    Declaration
    public virtual IProducer GetProducer(string endpointName)
    Parameters
    Type Name Description
    string endpointName

    The target endpoint name (or friendly name).

    Returns
    Type Description
    IProducer

    The IProducer for the specified endpoint.

    | Improve this doc View source

    InstantiateConsumer(TConsumerEndpoint, IBrokerBehaviorsProvider<IConsumerBehavior>, IServiceProvider)

    Returns a new instance of IConsumer to subscribe to the specified endpoint.

    Declaration
    protected abstract IConsumer InstantiateConsumer(TConsumerEndpoint endpoint, IBrokerBehaviorsProvider<IConsumerBehavior> behaviorsProvider, IServiceProvider serviceProvider)
    Parameters
    Type Name Description
    TConsumerEndpoint endpoint

    The endpoint.

    IBrokerBehaviorsProvider<IConsumerBehavior> behaviorsProvider

    The IBrokerBehaviorsProvider<TBehavior>.

    IServiceProvider serviceProvider

    The IServiceProvider instance to be used to resolve the needed types or to be forwarded to the consumer.

    Returns
    Type Description
    IConsumer

    The instantiated IConsumer.

    | Improve this doc View source

    InstantiateProducer(TProducerEndpoint, IBrokerBehaviorsProvider<IProducerBehavior>, IServiceProvider)

    Returns a new instance of IProducer to publish to the specified endpoint. The returned instance will be cached and reused for the same endpoint.

    Declaration
    protected abstract IProducer InstantiateProducer(TProducerEndpoint endpoint, IBrokerBehaviorsProvider<IProducerBehavior> behaviorsProvider, IServiceProvider serviceProvider)
    Parameters
    Type Name Description
    TProducerEndpoint endpoint

    The endpoint.

    IBrokerBehaviorsProvider<IProducerBehavior> behaviorsProvider

    The IBrokerBehaviorsProvider<TBehavior>.

    IServiceProvider serviceProvider

    The IServiceProvider instance to be used to resolve the needed types or to be forwarded to the consumer.

    Returns
    Type Description
    IProducer

    The instantiated IProducer.

    Implements

    IBroker
    IDisposable
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini