We have just developed a basic service with two APIs that respond to requests. Let's add a few capabilities that will enable to it to be a good cloud citizen. We will discuss the following:
- Externalizing configuration
- Instrumentation—health and metrics
- Service registration and discovery
Configuration can be any property that is likely to differ between environments or production deployments. Typical examples are queue and topic names, ports, URLs, connection and pool properties, and so on.
A deployable should not have configuration in it. A configuration should be injected from outside. This makes the deployable unit immutable as it goes through the various stages of the life cycle, such as Dev, QA, and UAT.
Let's assume we have to run our product
service in different environments, where the URL differentiates the environment. Therefore, the small change we make in the request mapping is as follows:
@RequestMapping("/${env}product/{id}...