A Pub/Sub based HTTP communication method in complex network environments
In a complex distributed system that consists of internal and external networks, i.e., internet and intranet, it is very challenging to ensure communication among various components across different networks. Typically, components in distributed system communicate via REST calls. However, in the complex network environment, direct REST communication doesn’t work sometimes, since the inbound connections are not allowed in particular situations without network tunnel.
a Pub/Sub method to enable HTTP communication among various components in a complex network environment, without changing the original service provider and service consumer in the HTTP based RESTful communication model.
In this method, each existing HTTP request/response is wrapped in message stream, transmitted in the Pub/Sub message bus, and then is recovered for request/response consumer. This approach solves the communicate problems in specific network environment with
limited efforts while still keeping the REST mode with sync HTTP calls.
HTTP transmission contains core components of our idea. By using it, clients can communicate with services using HTTP calls even in network environments where clients cannot fetch responses from services directly with HTTP calls.
Besides the message bus, there’re two important components in the HTTP transmission component: Message router and Message handler.
Workflow of the Message router:
Intercept HTTP requests from the client.
Transform the HTTP request to a Pub message, and transmit the message to the message bus. The Pub message contains the target service’s endpoint, the resource that is requested, and a UUID generated for this request.
Subscribe the request’s UUID by transmitting a Sub message to the message bus.
Listen to and get corresponding response from the message bus.
Return the response to the client.