1

I am developing a microservice architecture where the API publishes a message through RabbitMQ. One or more consumers will read the message, preform its functions then if successful acknowledge the message. These functions can take many seconds and is not preformed by the API Gateway and is instead "ran in the background". What are the possibilities for updating the user interface that the functions are completed?

One idea I have is the consumer workers publish a "finished" message that a web socket server consumes and pushes to the user interface the function is complete. One problem I see with this is if the functions finishes before the user interface subscribes to the web socket the user interface will not update. Second issue I see is there needs to be a way to listen to specific event id and only consume those ids where the end user is needing. I don't believe rabbitMQ other than one time topics can achieve this.

Am I missing something when it comes to event sourcing and interacting with the user interface? What way is most efficient to update the user interface when the functions/events are completed?

Thank you for the help.

2

Unless you need actual real-time feedback, polling the server using a normal REST endpoint is the simplest method. When the client starts an activity on the server, it should receive a link to a status URL where it can query the completion status of the activity. The polling schedule can depend on the characteristics of the activity.

If you actually need immediate response within seconds of completion or faster (which is very unlikely, probably only needed in real-time online games) websockets are a valid mechanism. To avoid the situation you're fearing, the client can subscribe to the event channel before starting an activity so it can't miss status reports.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.