Sleep

Not available in Community Designer

Short Description
Ports
Metadata
Sleep Attributes
Details
Examples
Best practices
See also

Short Description

Sleep slows down data records going through it.

Component Same input metadata Sorted inputs Inputs Outputs Each to all outputs Java CTL Auto-propagated metadata
Sleep-
no
0-11-n
yes
no
no
yes

Ports

Port typeNumberRequiredDescriptionMetadata
Input0
yes
For input data recordsAny
Output0
yes
For copied data recordsInput 0
1-n
no
For copied data recordsInput 0

Metadata

All metadata must be the same.

Metadata can be propagated through this component.

Sleep Attributes

AttributeReqDescriptionPossible values
Basic
Delay [1]

Delay of processing of each input record; by default in milliseconds, but other time units may be used. Total delay of parsing is equal to the this value multiplied by the number of input records.

0-N or time units
Input mapping[1]

Delay for input records processing can be also defined dynamically. You can determine how long should a record be delayed based on an incoming record content. So delay can be dynamically changed by your CTL code. Possible outputs of the mapping are two different values - string value delay, which can be populated by a same value as the component's attribute Delay, for example '15s'. The second output value delayMillis can specify delay by number of milliseconds.

CTL code

[1] One of these must be specified.

Details

Sleep receives data records through its single input port, delays each input record by a specified number of milliseconds and copies each input record to all connected output ports. Total delay does not depend on the number of output ports. It only depends on the number of input records.

The delay can be specified statically by the Delay attribute or dynamically based on an incoming record content in the Input mapping attribute.

Examples

Constant delay
Variable delay

Constant delay

This example show way to wait for a specific unit of time before each record.

Use Sleep to wait 2 seconds before each record.

Solution

Connect input and output edge to Sleep and configure the component.

AttributeValue
Delay (ms)2s

Variable delay

This example shows way to use variable delay in Sleep. The delay is received from input edge.

Delay each record. The delay (in milliseconds) is received from the input edge in field delay (long).

Solution

Connect input and output edge to the component. The input edge contains field delay.

AttributeValue
Input mapping
//#CTL2

function integer transform() {
    $out.0.delayMillis = $in.0.delay;

    return ALL;
}

Best practices

When using Sleep, remember that records are sent out from the component only after its buffer gets full (by default). Sometimes you might need to:

  1. send a record to Sleep

  2. have it delayed by a specified number of seconds

  3. send this very record to output ports immediately

In such case, you have to change settings of the edge outgoing from Sleep to Direct fast propagate. For more information, see Types of Edges.

[Tip]Tip

An unconnected Sleep component can be used to insert a pause between different phases of a graph. Put an extra phase between the two phases with single unconnected Sleep component.

See also

Common Properties of Components
Specific Attribute Types
Others Comparison