Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In our use case we want to show some charts, metrices and grid based on Kafka topics data.( All Topics are already loaded with Json data from different systems )
We are planning to use Kafka connect and will sync topics data to Cassandra database.
Based on some trigger like any new data in Kafka topic will re-load UI  and read same data from Cassandra (Via Dot Net core APIs) and display it on UI.
So is it good idea to use Kafka connect and sync data to Cassandra and query on Cassandra to load UI data Realtime.

Note : Reading data directly from Kafka topics and display on UI using Dot net Kafka consumer is very slow as in our use case we need to query different topics.

Kindly provide suggestions on same.


What I have tried:

Instaclustr hosted Kafka and Cassandra
Posted
Comments
[no name] 1-Dec-20 23:29pm    
Slow how? Maybe you need to do asynchronous reads.
[no name] 2-Dec-20 12:01pm    
As querying over 3-4 topics to get required data.

consumer code used -


var processedResult = new List<dictionary<string, object="">>();

using (var consumer = new ConsumerBuilder<genericrecord, genericrecord="">(consumerConfig)
.SetKeyDeserializer(new CustomAvroDeserializer<genericrecord>(schemaRegistryClient).CustomAsSyncOverAsync())
.SetValueDeserializer(new CustomAvroDeserializer<genericrecord>(schemaRegistryClient).CustomAsSyncOverAsync())
.SetErrorHandler((_, e) => Console.WriteLine($"Error: {e.Reason}"))
.Build())
{

Dictionary<string, object=""> results = new Dictionary<string, object="">();

consumer.Subscribe(topicName);

try
{
while (true)
{
try
{
// consumer.Subscribe(topicName);

ConsumeResult<genericrecord, genericrecord=""> consumeResult = consumer.Consume(cts.Token);

if (consumeResult.IsPartitionEOF)
{
return processedResult;
}

Dictionary<string, object=""> obj = new Dictionary<string, object="">();
var result = ProcessRetrievedResult(consumeResult);
processedResult.Add(result);

}
catch (ConsumeException e)
{
Console.WriteLine($"Error occurred: {e}");

}
}
}
catch (OperationCanceledException)
{
// Ensure the consumer leaves the group cleanly and final offsets are committed.
consumer.Close();
}
}

return processedResult;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900