Metadata
- Applicable Version:
HttpRequestSrv@v1.0.0 - Publish Date:
2026-04-08 - Article Type:
Technical Deep Dive - Related Service:
HttpRequestSrv@v1.0.0@http-request-route.xml
When a service needs to expose HTTP APIs in LightESB, the route XML itself is only half of the picture.
The other half is the runtime listener switch: HTTP.Listener.
This article explains how HTTP.Listener, server.port, and Undertow endpoints work together by using HttpRequestSrv as a concrete example.
Why HTTP.Listener Matters
In LightESB, Undertow component registration is controlled by configuration:
-
HTTP.Listener=true: register Undertow and expose HTTP routes -
HTTP.Listener=false: skip Undertow registration -
server.port: runtime listening port for route endpoints
From HttpRequestSrv/v1.0.0/common.config.properties:
server.port=18083
HTTP.Listener=true
system.components=undertowhttp
This design lets teams decide whether a service is externally reachable without modifying route XML files.
Route Entry Design in HttpRequestSrv
HttpRequestSrv defines two Undertow entries:
<from uri="undertow:http://0.0.0.0:{{server.port}}/api/httprequest/test?httpMethodRestrict=POST" />
...
<from uri="undertow:http://0.0.0.0:{{server.port}}/api/test?httpMethodRestrict=POST"/>
Key points:
-
0.0.0.0listens on all NICs -
{{server.port}}injects environment-level port -
httpMethodRestrict=POSTensures method-level guard at the endpoint
This is a clean pattern for API entry routes: reject invalid methods early and keep business processors focused.
Request Flow: Listener -> Route -> Downstream Call
The first route acts as both inbound listener and outbound requester:
- Receive external request on
/api/httprequest/test - Log request start with
servicelog - Forward to local endpoint
http://0.0.0.0:18083/api/test - Log completion and return response
Core segment:
<to uri="servicelog:info?message=开始处理HTTP请求&showBody=true&maxBodyLength=500"/>
<to uri="http://0.0.0.0:18083/api/test?httpMethod=POST&contentType=application/json&bridgeEndpoint=true&connectTimeout=5000&socketTimeout=30000"/>
<to uri="servicelog:info?message=HTTP请求完成&showBody=true&maxBodyLength=5000"/>
The second route handles /api/test and returns a fixed JSON payload for quick verification.
Minimal Validation with cURL
curl -X POST "http://localhost:18083/api/httprequest/test" \
-H "Content-Type: application/json" \
-d "{\"orderId\":\"A1001\",\"amount\":199.9}"
Expected behavior:
- request enters
http-request-route - route forwards to
/api/test - response body returns
{"message": "HTTP Response Test"} - request logs are visible through
servicelog
Common Failures and How to Diagnose
1) API not reachable
Check:
-
HTTP.Listeneristrue -
server.portis valid and not occupied - startup logs include Undertow registration success
2) Port conflict
- another process already binds the same port
- release lifecycle did not clean previous context on hot reload
3) 405 or route miss
- method is not in
httpMethodRestrict - request path does not match route URI exactly
Practical Recommendations
- Keep listener behavior configurable through properties, not hard-coded
- Start with strict
httpMethodRestrictto reduce invalid traffic - Add
jsonResponseProcessorwhen multilingual JSON output is required - Keep one service-level log at route entry for observability and incident triage
Top comments (0)