-
-
Notifications
You must be signed in to change notification settings - Fork 1
Topic Kafka
Bernardo Teixeira edited this page Oct 22, 2021
·
2 revisions
Kafka topics are the categories used to organize messages. Each topic has a name that is unique across the entire Kafka cluster. Messages are sent to and read from specific topics. In other words, producers write data to topics, and consumers read data from topics.
ApolloBus use the message name to use for the Topic name.
public async Task Publish(Event _event) { if (_event == null) { _logger.Warning("Event is null"); return; } var eventName = _event.GetType().Name; try { var producer = _kafkaConnection.ProducerBuilder<Event>(); _logger.Information($"Publishing the event {_event} to Kafka topic {eventName}"); var producerResult = await producer.ProduceAsync(eventName, new Message<Null, Event>() { Value = _event }); } catch (Exception e) { _logger.Error($"Error occured during publishing the event to topic {_event}"); _logger.Error($"Producer exception {e.Message}, StackTrace {e.StackTrace}"); } }