I need to have the rest interface for my aggregates to interaction with external net core services to write properties.
But internal microservices use the commandGateway
Have you best practices way, examples to do it?
I think it should be done without projections.
I’m not sure if I understood you correctly, maybe you can provide more information.
My opinionated approach would be to create a REST controller (adapter). You should inject
commandGateway in this controller and dispatch commands.
I have created a sample application that is demonstrating this approach: https://github.com/idugalic/digital-restaurant/tree/master/drestaurant-apps/drestaurant-monolith-rest
This application is exposing capabilities of ‘domain model’ via the REST API components (adapters) that are responsible for
- dispatching commands - CommandController
- querying the ‘query model’ (materialized views) - Spring REST repositories
I create one-to-one relation between a Command Model resource and a Query Model (materialized view) resource. Note that we are utilizing Spring Rest Data project to implement REST API (on the query side), and that will position us on the third level of Richardson Maturity Model
microservices architectural style for the same domain/problem is available here:
https://github.com/idugalic/digital-restaurant/tree/master/drestaurant-apps/drestaurant-microservices-rest (Version 2.1: Rabbit to distribute events, Spring Cloud to distribute commands, we do not distribute queries)
https://github.com/idugalic/digital-restaurant/tree/master/drestaurant-apps/drestaurant-microservices-rest-2 (Version 2.1: Axon Server to distribute events, commands and queries, Spring Cloud to distribute commands)
I hope this helps,