Enqueueing from RabbitMQ queues
RabbitMQ is a great way to communicate between different applications. But sometimes you want to have more visibility into queue messages, when they're processed and if they fail. And to be able to retry in a controlled fashion when they fail.
Nexus lets you get the best of both worlds by automatically enqueueing from a RabbitMQ queue to a Nexus queue like the example below. In order to use this you need to install the NuGet package for RabbitMQ called CommerceMind.Nexus.RabbitMQ
.
builder.Services
.AddNexus()
.AddQueues()
.AddRabbitMq(options =>
{
options.UserName = "...";
options.Password = "...";
options.HostNames = ["localhost"];
// Or:
options.ConnectionString = new Uri("amqp://...");
})
.AddNexusRabbitMqQueues()
.EnqueueFrom<RabbitQueueMessage>(new NexusRabbitMqQueue
{
Name = "rabbit_queue",
Bindings = [new NexusRabbitMqQueueBinding
{
ExchangeName = "my_exchange",
RoutingKey = ""
}]
});
Instance events
You can also use Kafka as the way to send signals between Nexus instances in a scaled out environment.
builder.Services
.AddNexus()
.AddQueues()
.AddRabbitMq(options =>
{
options.UserName = "...";
options.Password = "...";
options.HostNames = ["localhost"];
// Or:
options.ConnectionString = new Uri("amqp://...");
})
.AddRabbitMqInstanceEvents(options =>
{
// Change this to something unique if you're using the same RabbitMQ instance for multiple
// different Nexus applications
options.ExchangeName = "nexus_instance_events";
});