JasperFx 0.8.2


Messaging Transports



Configuring the Service Bus Edit on GitHub

All system configuration for a Jasper application starts with the JasperRegistry class. Underneath JasperRegistry are these sections that are specific to the messaging support:

  • JasperRegistry.Handlers - Configure policies about how message handlers are discovered, middleware is applied, and error handling policies. See Handling Received Messages for more information.
  • JasperRegistry.Publish - Optionally declare what messages or events are published by the Jasper system and any static publishing rules. See Routing Messages for more information.
  • JasperRegistry.Subscribe - Register as a subscriber for messages from other systems. See Dynamic Subscriptions for more information.
  • JasperRegistry.Transports - Configure or disable the built in transports in Jasper. See Messaging Transports for more information.

Sample usages of each of these sections are shown below:

public class MyMessagingApp : JasperRegistry
    public MyMessagingApp()
        // Configure handler policies
        Handlers.DefaultMaximumAttempts = 3;

        // Declare published messages

        // Register to receive messages
        Subscribe.To(type => type.IsInNamespace("MyMessagingApp.Incoming"));

        // Configure the built in transports

Listen for Messages

You can direct Jasper to listen for incoming messages with the built in transports by just declaring the incoming port for the transport or by providing a Uri that expresses both the transport type and port number like this:

public class MyListeningApp : JasperRegistry
    public MyListeningApp()
        // Use the simpler, but transport specific syntax
        // to just declare what port the transport should use
        // to listen for incoming messages

        // or use a Uri to declare both the transport type and port

Other transport types like the forthcoming RabbitMq and Azure Service Bus transports will probably be configured strictly by using the Uri mechanism.

Using Strong Typed Configuration

Messaging can also take advantage of Jasper's support for strong typed configuration like this:

public class MySettings
    public int LightweightPort { get; set; } = 2222;
    public Uri DefaultListener { get; set; } = "durable://localhost:2223".ToUri();

    public int MaximumSendAttempts { get; set; } = 5;

public class MyAppWithSettings : JasperRegistry
    public MyAppWithSettings()

        Settings.With<MySettings>(_ =>



Uri Lookups and Aliasing

Another way to configure the service bus is to use Uri aliasing that allows you to just make the configuration with "stand in" Uri's that are resolved later to the real value. So far, the only mechanism built into the core Jasper framework will pull the real values from the underlying IConfigurationRoot for the application.

See this example below:

public class MyAppUsingUriLookups : JasperRegistry
    public MyAppUsingUriLookups()
            .AddInMemoryCollection(new Dictionary<string, string>{{"incoming", "tcp://server3:2000"}});

        // This usage assumes that there is a value in the configuration
        // with the key "incoming" that corresponds to a Uri

Behind the scenes, the value for config://incoming is interpreted by Jasper as the Uri string stored in configuration with the key "incoming," or in code terms, IConfigurationRoot.GetValue<string>("incoming")

There is also an addon Uri lookup that uses Consul. See Jasper.Consul for more information.

The Uri aliases are respected anywhere where Uri's are accepted as arguments in JasperRegistry or when explicitly specifying the destination of a message being sent through the messaging.