sleep
The sleep function (screenshot below) delays the transmission of data for N seconds. Passing a sequence through the function will delay each item of the sequence for a specified time. The sleep function is compatible with the following transformation languages: Java, C#, C++, and Built-In. Code generation is supported in Java, C#, and C++. For more information about code generation, see Code Generator.
Parameters
Name | Type | Description |
---|---|---|
data | any node or atomic type | The data input parameter accepts any value (e.g., string). |
delay-seconds | xs:double | The delay-seconds input parameter delays the transmission of data for N seconds. Fractional seconds are also acceptable. |
data | any node or atomic type | The data output parameter receives data from the input and passes this data on to a target node. |
Example
For a possible use-case scenario, in which the sleep function is used, see the following mapping: MapForceExamples\SentimentAnalysis.mfd. An extract of this mapping is illustrated below. To be able to test the mapping, you will need your organization's login credentials.
Since OpenAI imposes rate limits on the API requests you can make, you may run into a Too Many Requests error. The sleep function enables you to bypass the rate limits by configuring a delay.
In the response structure of the web service call below, the content node receives data as a result of the request sent to the OpenAI API. Before each web service call, there is a delay for 3 seconds, and then the value of the content node is mapped to the sentiment column of the CustomerFeedback database.
For more information about this example and AI functionality in MapForce, see the following articles:
•AI-Based Support Request Sentiment Analysis Using MapForce and GPT-4
•AI-Based Database Image Classification with Altova MapForce