Middleware Pipeline Overview
Volt MX Server is a pass-through system. Whenever a client sends a request, the server routes the request to an external data source (a Database, MongoDB, JSON service) and sends back the back-end response to the client.
- Volt MX Server does not generate responses; however, it receives the external source's result and sends to the client. During this stage, the Server must process each request before it is sent to the external data source and each response before it is sent to the client.
- The middleware pipeline is divided into different layers, and each layer has its functionality, which applies transformations required for request and response objects.
- Each layer is responsible for transforming requests and responses.
- Each request and response object is propagated through these layers sequentially to apply transformations, as shown in the following flow diagram.
Middleware Pipeline Flow Diagram
The following middleware flow diagram details all the layers involved in the request and response transformation process:
- A client request passes through a series of different middleware layers before the request is sent to the data source.
-
A data source response passes through a series of different middleware layers before the response is sent to the client.
Note: The sequence of layers processed for the response is in the request's opposite direction.
Layers in Middleware Pipeline
-
Filters
Request- The Filters intercept a client request and perform pre-processing before passing them to Middleware Pipeline.
For example, you can use custom filters to transform request objects before the request is sent to the data source, such as validation checks, security checks, and logging metrics.
- Filters are used to intercept the responses and perform post-processing before passing it to the client.
- The Filters intercept a client request and perform pre-processing before passing them to Middleware Pipeline.
-
Data Controller
For Requests- Data Controller layer transforms HTTP servlet requests into Data Controller request objects for processing.Sends data controller request object to service delegator.
- It encapsulates data controller request objects.
Note: Data controller request objects help you configure additional parameters required in subsequent layers in the pipeline to process requests.
- Data Controller layer transforms the data controller response objects into HTTP Serverlet responses for processing.
- Sends HTTP servlet responses to the Filters layer.
- It encapsulates data control response objects.
Note: Data controller response objects help you configure additional parameters required in subsequent layers in the pipeline to process responses.
-
Data Processor
After a request is passed through the Data Controller, the request enters the Data Processor layer containing two different entities, the Service Delegator and JSON Processor. These entities have different functionality. Service Delegator functionality- Identifies appropriate data source connector based on the service configuration parameters.
- Invokes data source connectors which eventually make a service call to the external data source.
- After a request passed through the Data Controller layer, the
Service Delegator
is invoked. And the Service Delegator passes the request object to theConnector
layer.
- After the Connector layer passes a result/response object to
Data Processor
layer, theJSON Processor
is invoked.Note: At this stage, the result/response objects are in the form of Data Controller requests and responses.
TheJSON Processor
converts the response object data structure to JSON string and sends it to the Data Controller layer. At this stage, the response is in the form of a Data Controller response. - The Data Controller layer sends back the response to the device.
Note: When you have multiple back-end sources, different responses must be captured in a standard way. The Data Models play a vital role in encapsulating these multiple responses from different back-end sources.
- Abstraction of the result of a back-end service call.
- Collection of Params, Datasets, and Records.
- Abstraction of the result of a back-end service call.
- A record is an item in the Dataset.
- A record, in turn, can have Records or Datasets.
- A record can also contain Params.
- Param represents a parameter or variable part of the Result or Record object.
- It has parameter name, parameter value along with meta-data like data type, data format, and so on.
-
Data Connector
-
Transforms a request object.The Service Delegator chooses a connector based on the service configurations. The Connector layer helps transforms multiple data sources into expected data formats. A Pre-processor utility contains custom logic to transform the request object.
For example, you have an integration service type of XML service configuration. The Service Delegator selects the XML connector. And the Connect layer transforms data controller requests into the XML format. After that, a connector layer invokes pre-processor utility if configured, and the pre-processor executes classes and transforms the request object. A Pre-preprocessors utility allows developers to choose logic for data transformation. - Sends the request object to the Data Provider layer.
- Makes a call to the external data source and gets the response, and the response is in the form of a response object.
- The Post-processor checks for custom logic and executes it to transform the response object. Transforms the response object based on the custom logic specified in the Post-processor utility, if any.
- Sends the transformed response object to the JSON Processor in the previous layer.
-
Transforms a request object.The Service Delegator chooses a connector based on the service configurations. The Connector layer helps transforms multiple data sources into expected data formats. A Pre-processor utility contains custom logic to transform the request object.
-
Data Provider
Note: The functionality of the Connector layer is to transform the request objects, make a call to the Data Source layer, and get the response. The response is in the form of a response object.
The Data Provider layer establishes a connection to the external Data Source layer. For example, connection throttling and connection timeouts.
The Data Provider interface allows you to provide a custom implementation for connection establishment and generating the response.
- Default Data Provider
- Rules Data Provider
- Stub Data Provider
Note: The functionality of the Connector layer is to transform the request objects, make a call to the Data Source layer, and get the response. The response is in the form of a response object.