-
Notifications
You must be signed in to change notification settings - Fork 6
Development process
Some folks like to start with the backend service; others prefer to start from the API; and still others like to start with a dead-simple end-to-end implementation and iterate on it until it satisfies the requirements. The following sections describe the development steps used to add a new API endpoint and associated microservice. Each step can be done independently and in parallel, with some coordination to ensure consistent interfaces between Controller classes and Camel routes, and between route endpoints and microservices. For details, check out Routing API requests.
To minimize software coupling and maximize single-responsibility, a microservice should be built independent of existing VRO code. It should be idempotent and testable without having to run any other VRO code. It can be placed in its own Docker container or into an existing container. See the service-ruby
folder for an example of Ruby microservices that can be run and tested on its own, without Camel or a REST API. The only requirement is interfacing with a message queue, specifically RabbitMQ.
New backend Camel routing and microservices can be tested without having to implement API endpoint, controller, data model, request/response, and mapper classes.
CamelRestConfiguration
uses Camel to create a REST API for quick development and testing in a local development environment -- it is not for production. CamelRestConfiguration
is only enabled when vro.camel_rest_api.enable = true
(set in conf-camel.yml
).
This is achieved by using Camel's REST endpoint to provide quick API for testing via curl
or Postman.
The sample CamelApp uses this Camel feature to provide the API, whereas VRO uses Spring's Web MVC described in the next section.
Alternatively, Camel messages can be directly injected into Camel routes, which could be useful in unit tests. For examples, inspect the CamelEntrance
class.
Implement API endpoint, controller, data model, request/response, and mapper classes.
- Get agreement on the API endpoint specification, including examples and error codes. Check http://localhost:8080/swagger in a browser.
- Implement controller methods using Request and Response classes, and a Mapper class to convert to
service.spi.*.model
classes. - Have the controller initiate a Camel route that eventually leads to a microservice, for example by calling a method in the
CamelEntrance
class.