Some people don't recommend to use kafka to implement request/response pattern in micro-service world.
but I am not yet clear why it is not recommended ? At the same time, I see spring kafka is supported this pattern out of the box while .net doesn't have this feature available out of the box via any libraries (neither via confluent kafka nor MassTransit). If it is not recommended via kafka do we have any other standard methodology to achieve this scenario via .net core. Can someone provide a reasonable technical answer for me to convince my-self?
UPDATE
I am editing my question to explain the business use case Let's assume I need to display my account balances. I make a request [http request] from front end to api controller, Then there will be three events will be triggered to get savings account balance/ Fixed account balance / current account balances.
These events will be posted to the three kafka topics it will then be listened by three consumers. These consumers process the requests separately and publish to another three topics. Initial http call will be waited till these topics are get consumed. Once it's consumed http call respond to the front end.
[HttpPost]
[Route("ResponseWhenAny")]
public async Task<string> AggregateResponseWhenAny([FromBody] string value, string correlationId)
{
string resultOne = "No-Message";
string resultTwo = "No-Message";
correlationId=(string.IsNullOrEmpty(correlationId)) ? Guid.NewGuid().ToString() : correlationId;
var resultOneTask = RequetOne(value, correlationId);
var resultTwoTask = RequetSecond(value, correlationId);
var requestResponseTasks = new List<Task> { resultOneTask, resultTwoTask };
while (requestResponseTasks.Count > 0)
{
Task finishedTask = await Task.WhenAny(requestResponseTasks);
if (finishedTask == resultOneTask && resultOne == "No-Message")
{
Console.WriteLine("First response Received....");
resultOne = await resultOneTask;
}
else if (finishedTask == resultTwoTask && resultTwo == "No-Message")
{
Console.WriteLine("Second response Received....");
resultTwo = await resultTwoTask;
}
requestResponseTasks.Remove(finishedTask);
}
string newResponse = resultOne + resultTwo;
return newResponse;
}
resultOneTask and resultTwoTask should be waited till response topics are consumed. If resultOneTask and resultTwoTask are http calls there is no issue of implementing it. Even RMQ is also supported for this use case.But I am not able to find any standard implementation using confluent kafka or MassTransit for kafka .
Thanks In advance