<p><a href="https://i.stack.imgur.com/hwgkG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hwgkG.png" alt="enter image description here"></a></p>

<ol>
<li><p>A Web API receives a customer's credit card request data at an endpoint.</p></li>
<li><p>The endpoint sends a message with this data to the Kafka.</p></li>
<li><p>Several pods/containers will be connected to Kafka in this topic for processing each request in parallel. The application requires high asynchronous processing power.</p></li>
<li><p>After sending the request, the frontend will display a progress bar and will wait. It needs a response as soon as the process is finished.</p></li>
</ol>

<p><strong>The question</strong></p>

<blockquote>
  <p>How to return in the same call to this endpoint the result of a
  processing that will be done in another web API project?
  (asynchronous)</p>
</blockquote>

<p><strong>What I thought</strong></p>

<ul>
<li><p>Creating a topic in Kafka to be notified of the completion of processing and subscribe to it in the endpoint after sending the CreditCardRequest message to process on Kafka. </p></li>
<li><p>Using a query on the mongo on every 3~4 seconds (pooling) and check if the record has been included by the Worker / Pod / Processing Container. (URRGGH)</p></li>
<li><p>Creating another endpoint for the frontend to query the operation status, this endpoint will also do a query in the mongo to check the current status of the process.</p></li>
</ul>

<p><strong>I wonder deeply if there is no framework/standard already used for these situations.</strong></p>

Vinicius Gonçalves
<p>yes, there are frameworks that handle this. 
From a .NET perspective, I have used nServiceBus todo something similar in the past (coordinate long-running processes). </p>

<p>They have a concept called Sagas <a href="https://docs.particular.net/nservicebus/sagas/" rel="nofollow noreferrer">https://docs.particular.net/nservicebus/sagas/</a>
A saga will wait for all messages that are required to finish processing before notifying the next step of the process to continue.</p>

<p>If the framework is not useful, hopefully, the processes are and you can discover how to implement in a Kafka/Mongo environment.</p>
