Configuring Messaging

There's a couple moving parts to using Jasper as a messaging bus. You'll need to configure connectivity to external infrastructure like Rabbit MQ brokers, set up listening endpoints, and create routing rules to teach Jasper where and how to send your messages.

Transport Connectivity

The TCP transport is built in, and the "local" in memory queues can be used like a transport, but you'll need to configure connectivity for every other type of messaging transport adapter to external infrastructure. In all cases so far, the connectivity to external transports is done through an extension method on JasperOptions using the Use[ToolName]() idiom that is now common across .NET tools.

For an example, here's connecting to a Rabbit MQ broker:

using Jasper;
using Jasper.RabbitMQ;

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseJasper(opts =>
{
    // Using the Rabbit MQ URI specification: https://www.rabbitmq.com/uri-spec.html
    opts.UseRabbitMq(new Uri(builder.Configuration["rabbitmq"]));

    // Or connect locally as you might for development purposes
    opts.UseRabbitMq();

    // Or do it more programmatically:
    opts.UseRabbitMq(rabbit =>
    {
        rabbit.HostName = builder.Configuration["rabbitmq_host"];
        rabbit.VirtualHost = builder.Configuration["rabbitmq_virtual_host"];
        rabbit.UserName = builder.Configuration["rabbitmq_username"];

        // and you get the point, you get full control over the Rabbit MQ
        // connection here for the times you need that
    });
});

snippet source | anchor

Listening Endpoint Configuration

Sending Endpoint Configuration