Hi
Yesterday, I was at tech talks about microservices
It was very interesting, but i've still some questions.
I've heard that we can use "bus" with publish/subscribe event for communicate between microservices.
For example a micro service which create an user (it will send "user created event on bus") and a micro service which send email (he will subscribe about user created event and send confirmation email).
How to manage errors ? If this two services are independant, how can i return information message in my web application for saying "user has been successfully created and email is send" ?
I need to send email if user successfully created and if email has been send, but how can i associate this two services for be sure that our process was a success ?
Thank's for your help !
Usually, websites do not give a response from the API, that a mail has been sent (the site will just display static text and each service is self-contained and should use a buffer-system, which enables you to restart the service and work on everything which has failed before). However, if you need such feedback, you could use the bus to send back an "success" message. That would require a token on the message, so that other services can recognize to what the success message belongs.
That method, however, harbors dangers, as it is tempting to wait for success, then do something and send another message out. In the worst case, you create a very hard to debug loop of messages which answer to messages which answer to messages (and so on).
This is how I would go about this.
You have four components - UI, API, User Creation Microservice (UCM), Email Microservice (EM).
I put together a workflow diagram, see if it makes sense to you.

j
stuff ;)
you have an answer bus :) a bus per definition is just "a unidirectional pipeline" so you create a service that handles errors.
micro-services come with an architectural overhead.
every bus is just a queue the idea is to distribute load with it. there is no guaranty of order of execution.
so to answer simply -> you create an "to the service channel" and than a "from the service channel"
there are different ideas of how to manage and utilize such queues
so in your case I would create an "error service" that decides what to do with the error but don't forget to log them directly in the service as well ... systems tend to break so you want a good log :)