Skip to content

3.1 Loopback Configuration

Jesse Sweetland edited this page Jun 14, 2017 · 4 revisions

Platibus provides a loopback configuration in which all sent messages, publications, and replies are handled are routed back to the sender. This configuration can be initialized via the static Start method of the Platibus.LoopbackHost class.

The LoopbackHost.Start method has two overloads. The first accepts an optional string parameter specifying the name of the Platibus.Config.LoopbackConfigurationSection to load from the app.config (the default section name is "platibus"). If this overload is used, the loopback host will be configured according to the declarative configuration specified in the named configuration section, filtered through any concrete public IConfigurationHook implementations found in any of the assemblies in the the app domain base directory.

Declarative configuration example:

<configuration>
  <configSections>
    <section name="platibus" type="Platibus.Config.LoopbackConfigurationSection, Platibus" />
  </configSections>
  <platibus replyTimeout="00:00:30" defaultContentType="application/xml">
    <queueing provider="SQLite" path="platibus\queues" />
    <topics>
      <add name="CustomerEvents" />
      <add name="OrderEvents" />
    </topics>
  </platibus>
</configuration>

Because of the nature of the loopback host there is no need to specify a base URI, endpoints, send rules, or subscriptions.

The second overload accepts the Platibus.Config.ILoopbackConfiguration containing all of the necessary configuration data for the loopback host. This overload bypasses all declarative configuration and uses the supplied configuration object (configuration hooks are not called). This version can be used to programmatically specify 100% of the configuration for the loopback host.

In addition to the common bus configuration elements, the HTTP server configuration features some options specific to the looback host.

Message Queueing Service

The message queueing service provides the loopback host with a means of persisting important messages until they are successfully processed (outbound messages are queued until they are successfully sent; inbound messages are queued until they are acknowledged). The message queueing service can be specified declaratively or programmatically.

See 3.4 Message Queueing for more details.

Declarative example:

<platibus>
  <queueing provider="Filesystem" path="C:\platibus\queues"/>
</platibus>

Programmatic example:

public class ConfigurationHook : IConfigurationHook
{
    public void Configure(PlatibusConfiguration configuration)
    {
        var loopbackConfiguration = configuration as LoopbackConfiguration;
        if (loopbackConfiguration != null)
        {
            var path = @"C:\platibus\queues";
            var messageQueueingService = new FilesystemMessageQueueingService(path);
            loopbackConfiguration .MessageQueueingService = messageQueueingService;
        }
    }
}

A variety of message queueing service implementations are provided. See the message queueing section for configuration details.