I am trying to understand different methods used in messaging between services.
Let us say that I have a scenario where I need first service to notify the other that a user has asked for product creation, and the second service should receive this message, create a product and then respond telling the first service that a product has been created.
I am thinking that commands along with request/respond suits this scenario because the first service will need to address another specific service and will wait for feedback.
My understanding is that:
Events vs commands:
Events:
- provide loose coupling between the services.
- perform publishing to all queues and the services interested in such message will pick it.
Commands:
- perform sending to a specific queue hence only the services that receive using that queue will consume it.
Request/Respond vs Publish/Subsribe:
Request/Respond:
In Request/Respond the first service requests from the other to perform an operation and waits until respond is returned from the later.
Publish/Subscribe:
First service just publish a message and continue processing without waiting for feedback or response.
Now I started to design the messaging system using RabbitMQ along with Masstransit saga (Masstransit.Automatonymous) which seems to follow Events with publish/subscribe methods.
My Question is:
can I use commands with publishing or events with request/respond?
Is my understanding correct? and can sagas be used with request/response?