Product, order and inventory services behind Spring Cloud Gateway (WebMVC), configuration from a Config Server, discovery with Eureka, a Resilience4j circuit breaker on order -> inventory and Brave tracing. Run as six plain jars; output/ holds real transcripts (config, registry, requests, trace propagation, circuit breaker, startup race and the load-balanced RestClient.Builder trap). Dockerfile and docker-compose.yml are included but were not run. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HhW8LD8r3EigoBaCGrQZx5
30 lines
1.7 KiB
Bash
Executable File
30 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Reproduces the one trap that costs the most time: a load-balanced RestClient.Builder that Eureka's own client picks up.
|
|
# Needs the system running (scripts/start.sh). Starts a second order-service on :8092 WITHOUT the @Primary plain builder,
|
|
# captures what it logs and whether it registered, then stops it. Writes output/06-eureka-lb-trap.txt.
|
|
set -uo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
unset JAVA_TOOL_OPTIONS
|
|
F=output/06-eureka-lb-trap.txt
|
|
LOG=run/logs/order-service-broken.log
|
|
nohup java -Xmx200m -XX:+UseSerialGC -jar order-service/target/order-service-1.0.0.jar \
|
|
--server.port=8092 --shop.demo.primary-builder=false > $LOG 2>&1 &
|
|
echo $! > run/order-service-broken.pid
|
|
sleep 30
|
|
{
|
|
echo "# order-service started with --shop.demo.primary-builder=false (the only RestClient.Builder is the @LoadBalanced one)"
|
|
echo
|
|
echo "--- the log lines that give it away ---"
|
|
grep -m1 "BeanCurrentlyInCreationException" $LOG | sed -E 's/^[^ ]+ +[A-Z]+ [0-9]+ --- \[[^]]*\] \[[^]]*\] \[[^]]*\] //' | cut -c1-220
|
|
grep -m1 "No instances available for localhost" $LOG | sed -E 's/^[^ ]+ +[A-Z]+ [0-9]+ --- \[[^]]*\] \[[^]]*\] \[[^]]*\] //' | cut -c1-220
|
|
grep -m1 "registration failed" $LOG | sed -E 's/^[^ ]+ +[A-Z]+ [0-9]+ --- \[[^]]*\] \[[^]]*\] \[[^]]*\] //' | cut -c1-220
|
|
echo
|
|
echo "--- is instance order-service:8092 in Eureka? ---"
|
|
curl -s -H 'Accept: application/json' localhost:8761/eureka/apps | python3 -c '
|
|
import sys, json
|
|
ids = [i["instanceId"] for a in json.load(sys.stdin)["applications"]["application"] for i in a["instance"]]
|
|
print("order-service:8092 registered:", "order-service:8092" in ids)'
|
|
} > $F
|
|
kill "$(cat run/order-service-broken.pid)" 2>/dev/null; rm -f run/order-service-broken.pid
|
|
cat $F
|