Add openfeign-demo: OpenFeign vs @HttpExchange on Spring Boot 4.2.0 + Spring Cloud 2026.0.0

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b3W3uHbHAmM3orhn7b
This commit is contained in:
Ankur
2026-11-26 00:46:05 +05:30
co-authored by Claude Sonnet 5.5
parent def73fa1c4
commit 7211b0fb80
43 changed files with 927 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
findAll() -> [Student[id=1, name=Asha, branch=CS], Student[id=2, name=Ravi, branch=IT], Student[id=3, name=Meera, branch=EXTC]]
findById(2) -> Student[id=2, name=Student-2, branch=CS]
create(Kiran, ME) -> Student[id=100, name=Kiran, branch=ME]
Feign's own log (logger-level: basic):
[StudentClient#findAll] ---> GET http://student-service/api/students HTTP/1.1
[StudentClient#findAll] <--- HTTP/1.1 200 (138ms)
[StudentClient#findById] ---> GET http://student-service/api/students/2 HTTP/1.1
[StudentClient#findById] <--- HTTP/1.1 200 (7ms)
[StudentClient#create] ---> POST http://student-service/api/students HTTP/1.1
[StudentClient#create] <--- HTTP/1.1 201 (6ms)
@@ -0,0 +1,12 @@
StudentClient.findById(99) [default decoder]
exception : feign.FeignException$NotFound
status : 404
message : [404] during [GET] to [http://student-service/api/students/99] [StudentClient#findById(int)]: [{"detail":"No student with id 99","status":404,"title":"Not Found"}]
DecodedStudentClient.findById(99) [custom ErrorDecoder]
exception : com.ankurm.feign.client.StudentNotFoundException
message : 404 from DecodedStudentClient#findById(int) (http://localhost:18367/api/students/99)
DecodedStudentClient.findById(503) [custom decoder delegates non-404 to the default]
exception : feign.FeignException$ServiceUnavailable
status : 503
@@ -0,0 +1,4 @@
profile : newprefix
server sleeps: 3000 ms, read-timeout configured: 1000 ms
outcome : threw feign.RetryableException -> Read timed out executing GET http://student-service/api/students/slow?ms=3000
took : about 1000 ms (gave up at the timeout)
@@ -0,0 +1,4 @@
profile : oldprefix
server sleeps: 3000 ms, read-timeout configured: 1000 ms
outcome : returned: answered after 3000 ms
took : about 3000 ms (waited for the full answer)
+6
View File
@@ -0,0 +1,6 @@
Server answers 503 + 'Retry-After: 0' for the first 2 calls, then 200.
no Retryer bean (the default) : RetryableException, server saw 1 call(s)
Retryer.Default(50,200,3) GET : success Student[id=3, name=flaky-b, branch=CS], server saw 3 call(s)
same Retryer, server keeps 503 : RetryableException, server saw 3 call(s)
same Retryer on a POST : success Student[id=3, name=flaky-d, branch=CS], server saw 3 call(s) for ONE client call
+7
View File
@@ -0,0 +1,7 @@
findById(503), server answers 503 -> Student[id=503, name=unknown, branch=unknown]
placeOrder(w), server answers 503 -> IllegalStateException: student-service down; order w not placed
StudentClient.slow(3000) with circuitbreaker.enabled=true and NO read-timeout configured:
threw org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException after about 1000 ms
message: No fallback available.
cause : java.util.concurrent.TimeoutException
@@ -0,0 +1,8 @@
findAll() -> [Student[id=1, name=Asha, branch=CS], Student[id=2, name=Ravi, branch=IT], Student[id=3, name=Meera, branch=EXTC]]
findById(2) -> Student[id=2, name=Student-2, branch=CS]
create(Kiran, ME) -> Student[id=100, name=Kiran, branch=ME]
findById(99), circuit breaker starter on the classpath (default):
exception : org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException
message : No fallback available.
cause : org.springframework.web.client.HttpClientErrorException$NotFound
@@ -0,0 +1,3 @@
findById(99) with spring.cloud.circuitbreaker.http-services.enabled=false:
exception : org.springframework.web.client.HttpClientErrorException$NotFound
message : 404 Not Found: "{"detail":"No student with id 99","status":404,"title":"Not Found"}"
@@ -0,0 +1,6 @@
mvn -Pnoparams -Dtest=UnnamedPathVariableTest test (maven-compiler-plugin <parameters>false</parameters>)
Caused by: java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.ankurm.feign.client.UnnamedPathVariableClient': FactoryBean threw exception on object creation
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.498 s <<< FAILURE! -- in com.ankurm.feign.UnnamedPathVariableTest