In my application there are 9 micro-services, lets say two of them uses an enum for a operation. Is it a good practice to place the enum in common place and add commons jar as a dependency to both the microservices ?
Micro-service theory says, you shouldn't do that. But I think, from practical point of view, it is often necessary. At least, if you want to ensure some level of governance across the organization. Because, yes, most of the enums are primarily owned by some microservices or bounded contexts. But it doesn't mean, you don't need to use them in others...Take for example mobile banking...You want to open a banking account via mobile application (with its own backend). This mobile app is communicating (via its own backend) (directly or through some messaging layer) with core banking system. Your mobile app needs to know the product code(among lot of other things)of an account you want to open, and of course, core banking system needs to know it as well (it is in the domain which masters this information). Also, I don't think that sharing enums via library is the only way. You can read the enums dynamically via the REST API , or messages. It is always a trade-off of what you need and what is the cost of doing that. But I don't agree, that not-sharing is always the best option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With