Java / Micronaut Interview questions
What is the difference between a Micronaut declarative HTTP client and the low-level HttpClient?
| Declarative @Client | Low-level HttpClient |
| Defined as an interface with HTTP annotations; Micronaut generates the implementation. | Used programmatically by calling methods like retrieve() or exchange() directly. |
| Reads like a typed method call - request building is implicit. | Requires manually building an HttpRequest object for each call. |
| Best for calling a known, stable API with a fixed contract. | Best for dynamic requests where the URL, method, or headers vary at runtime. |
| Automatically integrates with service discovery by referencing a service ID. | Also supports service discovery, but requires more manual wiring per call. |
Most application code uses the declarative form since it reads like a normal typed method and keeps HTTP details out of business logic; the low-level client remains available for cases like building requests dynamically or calling endpoints not known until runtime.
More Related questions...