Skip to content
On this page


When you publish a message using IMessageBus or IMessageContext, Wolverine uses its concept of subscriptions to know how and where to send the message. Consider this code that publishes a PingMessage:

public class SendingExample
    public async Task SendPingsAndPongs(IMessageContext bus)
        // Publish a message
        await bus.SendAsync(new PingMessage());

snippet source | anchor

When sending, publishing, scheduling, or invoking a message type for the first time, Wolverine runs though a series of rules to determine what endpoint(s) subscribes to the message type. Those rules in order of precedence are:

  1. Explicit subscription rules
  2. Use a local subscription using the conventional local queue routing if the message type has a known message handler within the application
  3. Any registered message routing conventions like the Rabbit MQ or Amazon SQS routing conventions

Explicit Subscriptions

To route messages to specific endpoints, we can apply static message routing rules by using a routing rule as shown below:

using var host = Host.CreateDefaultBuilder()
    .UseWolverine(opts =>
        // Route a single message type
            .ToServerAndPort("server", 1111);

        // Send every possible message to a TCP listener
        // on this box at port 2222

        // Or use a more fluent interface style

        // Complicated rules, I don't think folks will use this much
        opts.Publish(rule =>
            // Apply as many message matching
            // rules as you need

            // Specific message types

            // All types in a certain assembly

            // or this

            // or by namespace

            // Express the subscribers

        // Or you just send all messages to a certain endpoint

snippet source | anchor

Do note that doing the message type filtering by namespace will also include child namespaces. In our own usage we try to rely on either namespace rules or by using shared message assemblies.

Message Routing Conventions

As an example, you can apply conventional routing with the Amazon SQS transport like so:

var host = await Host.CreateDefaultBuilder()
    .UseWolverine(opts =>


snippet source | anchor

In this case any outgoing message types that aren't handled locally or have an explicit subscription will be automatically routed to an Amazon SQS queue named after the Wolverine message type name of the message type.

Basic Options

TODO -- talk about durability, buffered, inline. Envelope rules. Serializers

Released under the MIT License.