Best Practices for Adding a Stateless Microservice in Balanced Deployment Model

Given new business requirements, I need to introduce a new microservice to our Broadleaf-based ecosystem. This service will not have its own database and will mainly be responsible for consuming events from existing services and integrating with an external system.

We are currently using the Balanced Service Deployment model.
What are the recommended practices for adding such a microservice within this deployment architecture? Are there any specific considerations we should keep in mind?

Hi hagarabdelzaher,

Thanks for posting!

  1. Choosing the right flex package for the new microservice depends on how it will be used. For example, it sounds like it could be included in the processing flex package since it will be processing messages behind the scenes. It could also make sense as it’s own flex package if you need to scale it separately from other services. Some documentation for the grouping of services by balanced flex package: Deployment Flexibility - Broadleaf Dev Central
  2. Assuming you’re on a pre-initializr version of Microservices, we recommend to basically mimic how another service in the same flexpackage is configured and get pretty close. This also includes things like adding gateway routing properties for the new service’s API as needed.
  3. A good practice is to keep the core service code and flexpackage decoupled as separate JARs. That way, the service can be moved to another flexpackage easily if needed.
  4. Since you aren’t using a database you won’t need to worry about data routing configuration. For reference, an example of a microservice without a data store is CartOperationServices. If you did have a database, the @JpaDataRoute configuration for that would look very similar to what we have in our out-of-the-box configurations such as CatalogJpaAutoConfiguration.
  5. If you are not introducing this as a net new flexpackage application, then we imagine your Helm charts don’t need to change much (if at all). If it is a net new flexpackage app, then the Helm charts would need to be updated.

If you have any additional questions, please let us know.