MassTransit Kafka producers configure to send several events to the same Kafka topic

25 Views Asked by At

I am using Masstransit library for sending data to Kafka. There is one specific case where I have to send 3 different events to the same Kafka topic. But it looks like Masstransit doesn't support it as it uses topicName as a key for Dictionary to store Kafka producers:

void IKafkaFactoryConfigurator.TopicProducer<TKey, TValue>(string topicName, ProducerConfig producerConfig,
    Action<IKafkaProducerConfigurator<TKey, TValue>> configure)
    where TValue : class
{
    if (string.IsNullOrWhiteSpace(topicName))
        throw new ArgumentException(nameof(topicName));
    if (producerConfig == null)
        throw new ArgumentNullException(nameof(producerConfig));

    var added = _producers.TryAdd(topicName, topic => CreateSpecification(topic, producerConfig, configure));

    if (!added)
        throw new ConfigurationException($"A topic producer with the same key was already added: {topicName}");
}

Does anyone face with the issue? Maybe there are any workarounds?

0

There are 0 best solutions below