1

What I found so far, that it is possible to install RawRabbit.Enrichers.Attributespackage and configure message class with attributes:

[Queue(Name = "my_queue"]
private class AttributedMessage
{       
}

and set

var client = RawRabbitFactory.CreateSingleton(new RawRabbitOptions
{
    Plugins = plugin => plugin.UseAttributeRouting()
});

But I would rather want to specify queue name along with publish command to keep it more flexible:

await _busClient.PublishAsync(message /*some_config_here???*/);

Is it possible with RawRabbit 2.0.0-rc5?

Roma Kostelnyy
  • 183
  • 1
  • 12

1 Answers1

-1

I think this may help you:

    static async Task Publish()
    {
        var config = new RawRabbitConfiguration
        {
            Username = "YOUR_RMQ_USER",
            Password = "YOUR_RMQ_PWD",
            Port = 5672,
            VirtualHost = "/",
            Hostnames = { "YOUR_RMQ_HOST_OR_IP" }
        };
        var bus = BusClientFactory.CreateDefault(config);


        await bus.PublishAsync(
            message: yourAwesomeMessagePayload,
            configuration: ctx => ctx.WithExchange(BuildExchangeConfig)
                                     .WithRoutingKey("custom.message.routing.key")
            );

        Console.WriteLine("message published!");
    }

    static void BuildExchangeConfig(IExchangeConfigurationBuilder e)
    {
        e.WithName("YOUR_EXCHANGE_NAME")
            .WithAutoDelete(false)
            .WithDurability(true)
            .WithType(ExchangeType.Topic);
    }
Thiago Silva
  • 14,183
  • 3
  • 36
  • 46