/
SilverbackBuilderPublishOutboundMessagesToInternalBusExtensions.cs
40 lines (35 loc) · 1.68 KB
/
SilverbackBuilderPublishOutboundMessagesToInternalBusExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2020 Sergio Aquilini
// This code is licensed under MIT license (see LICENSE file for details)
using System;
using Silverback.Messaging.Outbound.Routing;
using Silverback.Util;
namespace Silverback.Messaging.Configuration
{
/// <summary>
/// Adds the <c>PublishOutboundMessagesToInternalBus</c> method to the <see cref="ISilverbackBuilder" />.
/// </summary>
public static class SilverbackBuilderPublishOutboundMessagesToInternalBusExtensions
{
/// <summary>
/// Enables the legacy behavior where the messages to be routed through an outbound connector are also
/// being published to the internal bus, to be locally subscribed. This is now disabled by default.
/// </summary>
/// <param name="silverbackBuilder">
/// The <see cref="ISilverbackBuilder" />.
/// </param>
/// <returns>
/// The <see cref="ISilverbackBuilder" /> so that additional calls can be chained.
/// </returns>
public static ISilverbackBuilder PublishOutboundMessagesToInternalBus(this ISilverbackBuilder silverbackBuilder)
{
Check.NotNull(silverbackBuilder, nameof(silverbackBuilder));
var outboundRoutingConfiguration =
silverbackBuilder.Services.GetSingletonServiceInstance<IOutboundRoutingConfiguration>() ??
throw new InvalidOperationException(
"IOutboundRoutingConfiguration not found, " +
"WithConnectionToMessageBroker has not been called.");
outboundRoutingConfiguration.PublishOutboundMessagesToInternalBus = true;
return silverbackBuilder;
}
}
}