We can integrate Sitecore with Kafka using .NET Connectors. I will be using Cloudera .NET client library for Apache Kafka called Cloudera.Kafka.
The Cloudera.Kafka assembly can be downloaded and installed through Visual Studio or a command line interface or from nuget.org. Using Cloudera.Kafka, we can Push the data to Kafka system using ProducerBuilder and Pull using ConsumerBuilder.
Download, the solution on your local system and restore the NuGet packages.
Kafka Configurations, to use the
Kafkawe have to change theKafka configurationsin the following places:
- \Sitecore-Kafka-Integration\KafkaIntegrationSite\KafkaIntegrationSite\Controllers\KafkaController.cs >
PublishToKafkaFunction :-
var items = this.kafkaRepository.Push(
new CT.SC.Foundation.Kafka.Models.ProducerModel
{
Topic = topic,
Message = message,
BootstrapServers = "<Fill details from configuration items>",
SecurityProtocol = SecurityProtocolValue.SaslSsl,
SaslMechanism = SaslMechanismValue.Plain,
SslCaLocation = @"<Fill details from configuration items>",
SaslUsername = "<Fill details from configuration items>",
SaslPassword = "<Fill details from configuration items>",
EnableSslCertificateVerification = false
}
);
- \Sitecore-Kafka-Integration\KafkaIntegrationSite\KafkaIntegrationSite\Controllers\KafkaController.cs >
PullFromKafkaFunction :-
var items = this.kafkaRepository.Pull(
new CT.SC.Foundation.Kafka.Models.ConsumerModel
{
Topic = topic,
GroupId = groupId,
AutoOffsetReset = AutoOffsetResetValue.Earliest,
EnablePartitionEof = true,
BootstrapServers = "<Fill details from configuration items>",
SecurityProtocol = SecurityProtocolValue.SaslSsl,
SaslMechanism = SaslMechanismValue.Plain,
SslCaLocation = @"<Fill details from configuration items>",
SaslUsername = "<Fill details from configuration items>",
SaslPassword = "<Fill details from configuration items>",
EnableSslCertificateVerification = false
}
);Once user click on the
Push to Kafka, user will seePlease Waitscreen:
After successful
Pushuser will seeScuccessmessage:
Once user click on the
Pull from Kafka, user will seePlease Waitscreen:
If
Messagesnot present inKafka Topicuser will seeErrormessage:
If
Messagespresent inKafka Topicuser will seeSuccessmessage with details:
Copyright (c) 2021.
Licensed under the MIT license.