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
Kafka
we have to change theKafka configurations
in the following places:
- \Sitecore-Kafka-Integration\KafkaIntegrationSite\KafkaIntegrationSite\Controllers\KafkaController.cs >
PublishToKafka
Function :-
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 >
PullFromKafka
Function :-
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 Wait
screen:
After successful
Push
user will seeScuccess
message:
Once user click on the
Pull from Kafka
, user will seePlease Wait
screen:
If
Messages
not present inKafka Topic
user will seeError
message:
If
Messages
present inKafka Topic
user will seeSuccess
message with details:
Copyright (c) 2021.
Licensed under the MIT license.