Version: 17.07
Supported Since: 17.01
File Payload Setter processing element can be used to set the message payload from a file which will set the file content as the current payload of the message.
In order to use this processing element, you must first select the Payload Manipulation dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Payload Manipulation dependency. |
Next |
Message will be emitted from this port after setting the extract value from the XPath as the configured scope variable |
On Exception |
The message context will be sent to this outport if any exception occurred while extracting the provided XPath |
File Path * |
Basic |
Path of the file which should be configured as the current payload of the message. This file path can be set dynamically as well, using any combination of @{message.headers.<name>}, @{message.properties.<name>}, @{variable.<name>}, @{current.timestamp.<timestamp_format>} and @{message.id} |
In the following use case, the requirement is to create a web service which will send the EoD trade information for each client based on the Client_ID receives as a transport header in the HTTP request. The EoD data will be generated by another system and it will persist the generated file with a pre-defined file name format and in a pre-defined location. Responsibility of the web service is to extract the Client_ID and derive the relevant file name based on the Client_ID and the current date.
In order to implement above use case you must first select following dependencies when you are creating an empty Ultra project
HTTP NIO Connector from the connector list.
Regular Payload Setter Processors and Message Logger dependencies from the processor list.
If you have already created a project, you can add above dependencies via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list and Processors list, select above dependencies
To implement above use case, first let’s create our integration flow named “integrate-for-eod-data". Then add an NIO HTTP Ingress Connector and configure the request receiving service path and port.
Then File Payload Setter processing element should be added to set the payload from the file content. File name is the only parameter which should be configured to this processing element. Based on the above use case, we should derive the relevant file name based on the Client_ID header value and the current date. For that file name should be configured as /data/eod-data/@{message.headers.Client_ID}_@{current.timestamp.yyyy_MM_dd}.xml. @{message.headers.Client_ID} will be replace by the Client_ID transport header and @{current.timestamp.yyyy_MM_dd} will be replaced by the current timestamp in yyyy_MM_dd format. As an example, if the client id is "ADRT_Integration" and current date is 20/01/2017, then the file name value will be /data/eod-data/ADRT_Integration_2017_01_20.xml. With this configuration, File Payload Setter would be configured as below,
As the final processing element, Logger Processing Element should be added to log the information related to current processing request.
With all above elements, complete integration flow would be like this,
Now run your integration flow and send a request message to the configured request URL to test your integration flow. Once you send a request, you should get the content of the file which is in the configured path as the response for your request. You can try different Client_IDs and it should pick up the correct file based on the Client_ID and the current date.