Loopback Binding

Configuration reference for the Loopback message bus binding.

Overview

The Loopback binding enables message exchange between applications running in the same process. This binding is primarily used for unit testing where several applications may be launched in the same process for easy debugging.

When you configure a bus binding to use a loopback bus, a LoopbackBus instance is statically created on demand using the address provided by the binding. Two applications that connect to a loopback bus with the same name can exchange messages with one another.

For conceptual information about the Loopback binding, see Loopback Binding.

Bus Descriptor Format

Loopback buses can be configured using a descriptor string or decomposed DDL format.

Descriptor String

loopback://<busname>&prop1=val1&propN=valN

Example:

loopback://my-bus&topic_starts_with_channel=false&set_bus_and_channel_on_receipt=true

Decomposed DDL Format

<buses>
  <bus name="my-bus">
    <provider>loopback</provider>
    <address>my-bus</address>
    <properties>
      <topic_starts_with_channel>false</topic_starts_with_channel>
      <set_bus_and_channel_on_receipt>true</set_bus_and_channel_on_receipt>
    </properties>
    <channels>
      <!-- channel configuration -->
    </channels>
  </bus>
</buses>

As Descriptor (Substitution Support)

The descriptor form is useful when the descriptor name may be supplied as an external configuration property that is substituted at runtime, but defaults to loopback for testing:

This example defaults to loopback but can be overridden at runtime with a different bus descriptor (e.g., Solace) via the myBusDescriptor property.

Binding Specific Properties

The Loopback binding does not have any binding-specific properties beyond the general bus properties (such as topic_starts_with_channel, set_bus_and_channel_on_receipt, etc.) that apply to all message bus bindings.

Loopback Bus Naming

When working with loopback buses, it is sometimes useful to be able to look up a loopback bus by name. Loopback buses are named using their address (and optionally their port).

If you have configured a loopback bus via loopback://my-bus, you can look up the bus as follows:

Port Numbers and the Loopback Bus

A loopback bus does not require a port to be specified in its configuration. If you do configure a loopback bus with a port, the name of the loopback bus will include the port.

For example, if you specify loopback://my-bus:80, the name of the bus will be my-bus:80. One consequence of this is that loopback://my-bus:80 and loopback://my-bus:90 represent 2 separate buses which cannot communicate with one another.

Other than contributing to the name of the bus, the port has no functional significance.

See Also

Last updated