Enqueueing from Kafka topics
Nexus has built-in support to use the very popular Apache Kafka platform for both instance events as well as taking messages from a Kafka topic and enqueueing into a Nexus queue.
In order to use this you need to install the NuGet package for RabbitMQ called CommerceMind.Nexus.Kafka
.
You set it up like this:
builder.Services
.AddNexus()
.AddQueues()
.AddKafka(options =>
{
options.ConsumerConfig.BootstrapServers = "...";
options.ConsumerConfig.GroupId = "...";
})
.AddNexusKafkaQueues()
.EnqueueFrom<KafkaQueueMessage>("kafka-topic");
With this examples all messages posted to the kafka-topic
will get placed in the Nexus queue for KafkaQueueMessage
.
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()
.AddKafka(options =>
{
options.ConsumerConfig.BootstrapServers = "...";
options.ConsumerConfig.GroupId = "...";
options.ProducerConfig.BootstrapServers = "...";
})
.AddKafkaInstanceEvents(options =>
{
// Change this to something unique if you're using the same Kafka instance for multiple
// different Nexus applications
options.TopicName = "nexus_instance_events";
});