Return to site

🔌 Feign-style clients in Java: declare, don’t implement

· java,architecture

Think

“Spring Data, but for HTTP calls"

You write an interface, add a few annotations, and the framework generates the REST client for you. Clean, testable, and fast to wire up. 🚀

🍃 In Spring (OpenFeign)

🧬 In Quarkus (MicroProfile Rest Client)

💓 Why teams love it

  • 🧩 Less boilerplate (no manual WebClient/RestTemplate/RestClient code)
  • 🤝 Clear contracts via interfaces & DTOs
  • ✨ Easy testing (mock the interface)
  • 🛡️ Built-in goodies: timeouts, retries, fault tolerance (@Timeout/@Retry/@Fallback in Quarkus; Resilience4j with Feign)

🧑💼 Pro tips

  • ⏱️ Always set timeouts and retries thoughtfully
  • 🔄 Version your APIs; keep DTOs stable
  • 🧪 Contract tests catch breaking changes early
  • 📜 Centralize error handling & logging

🗨️ How are you structuring your HTTP clients—hand-rolled or declarative? 👇Please comment...

Some resources:

Go further with certifications

PASS Java 21 certification: https://bit.ly/3fmTmVp

PASS Spring certification: https://bit.ly/2v7222