3. Architectural Overview
Fig.1 - HTTP Request Lifecycle in Mobius HTTP Gateway
1. The client initiates a request to the server over TCP, typically using standard HTTP/1.1.
2. Undertow, the embedded reactive HTTP server, listens on the configured port and accepts the TCP connection, providing high-performance socket handling.
3. Once accepted, Undertow parses the incoming HTTP request (method, path, headers, body) and delegates it to a servlet – WrappedServlet.
4. Mobius’ WrappedServlet implementation is responsible for:
- Parsing the URL path and headers.
- Extracting the body and converting it to JSON/XML/Form.
- Determining the matching HttpLink (via URL and host).
- Resolving the corresponding HttpServer and its serviceName.
- Looking up the appropriate HttpCallbackInterface implementation based on the (destinationID, serviceName) mapping.
5. HttpServerData Runtime Context: this internal in-memory structure holds:
- All registered links for the local port (activeLinks).
- All declared servers (serversMap).
- All registered application callbacks (registeredCallbacks).
It is used to route the request dynamically without needing restarts or hardcoded logic.
6. The resolved HttpCallbackInterface is executed, and the user-defined onMessage(...) method processes the input and prepares a response.
7. The returned object is serialized into:
- JSON (default)
- XML (if specified and xmlRootName is set)
- application/x-www-form-urlencoded (if requested)
8. HTTP Response Sent: response is written to the socket and sent back to the client.
3.1 Core Design Principles
Principle |
Description |
Modular Configuration |
Destinations, Servers, and Links are stored dynamically in MongoDB and can be modified during runtime without downtime. |
Asynchronous Handling |
AsyncCallback interface ensures non-blocking, concurrent request processing even under high loads, aligning with HTTP’s expectation of independent transactions. |
External Integration |
External lifecycle listeners (HttpExternalListener) allow dynamic enforcement of business rules, such as validating deletions of Destinations before removing associated Servers and Links. |
Stateless Routing |
WrappedServlet dispatches every HTTP request by evaluating the incoming parameters against runtime-registered Links and Callbacks, with no server-side session retention. |
3.2 Runtime Components
At runtime, the following components collaborate to realize the gateway's asynchronous, scalable, stateless architecture:
Component |
Purpose |
Undertow HTTP Server Instances |
Lightweight embedded HTTP servers bound to localPorts, running the WrappedServlet for handling HTTP requests. |
DB Storage |
Persistent database holding the dynamic configuration entities: Destinations, Servers, and Links. |
Async Callback Framework |
Allows developer-defined logic to handle requests, based on service names dynamically mapped at runtime. |
WrappedServlet |
Parses HTTP requests, locates the matching Link and Service, and dispatches the call to the correct callback implementation. |
HttpServerData |
In-memory runtime cache: maps active Links, registered Callbacks, and Server definitions for rapid request resolution. |
Start innovating with Mobius
What's next? Let's talk!