Timer
The Timer component is used to trigger sending of messages to a component connected to its output ports. The date and the time at which this component needs to start sending messages can be configured. The number of messages and the format of the message can also be specified.
This component has no input ports, but has 2 output ports:
- Message Port
- Timer Port
Timer component is capable of sending messages with the format specified in the Configuration Property Sheet to its Message port. It sends messages that contain the date and time to its Timer Port. The component uses java.util.Timer class for scheduling.
Points to note
If the Timer component is configured for a start date and time which is in past, when the component starts, all messages which could have been sent had the component started at the configured date and time, is sent immediately on startup. To avoid this, the component can be configured to send the first message at the first interval which comes in the future of the time when the component launched. The configuration parameter to check is Start execution from next interval.
Configuration and Testing
Scheduler Configuration
The Scheduling information can be configured in Scheduler Configuration panel.
Figure 1: Scheduler Configuration section in Scheduler Service Configuration Panel
In this panel, the following parameters are configured:
- Message Sending Interval: Time interval after which the message needs to be sent. It can be set in:
milli seconds
seconds
minutes
hours
days
- Number of Messages: Number of times the message needs to be sent
Infinite Times: Select this check box to send the messages without a count limit
Start time: The time at which the Timer has to start sending the messages.
This can be configured for a future time or past time.
Start date: The date at which the Timer has to start sending the messages
Advanced Configuration
Figure 2: Advance Configuration section in Scheduler Service Configuration Panel
- Schedule Type
- Daily: The message is sent every day between the start and end time as defined in the sessions table. The times have to be in hh:mm:ss format.
- Weekly:The message is sent on predefined days of a week. The days in week can be chosen on clicking the ellipsis against the property Scheduled Days in Week. The messages are sent only during the intervals defined by the sessions table.
- Monthly:The message is sent on predefined dates in a month. The days in week can be chosen on clicking the ellipsis against the property Scheduled Dates in Month. The messages are sent only during the intervals defined by the sessions table.
- Start Time: The time when the Timer should start sending the messages.
- End Time: The time when the Timer should stop sending the messages.
End Date: This is to set the date when the timer should stop sending the messages
End Date option gets enabled only if Use End Date check box is selected.
Timer Service Configuration
Figure 3: Timer Service Configuration panel
Output Message Format
The output message format for the Message Port can be configured in this panel. Timer supports plain text format and XML format messages.
If you select the message format as XML, then you need to provide sample XSD in this panel.
If the timer is configured to send Plain Text message, then the content can be specified in the text area. If you select the message format as XML, then you need to provide sample XSD in this panel.The schema can also be loaded from a file using the "Load" option or from the ports using the "Connected Port Schemas" option.
Output Schema
The messages that are sent from the Timer Port have the following schema:
Schema | Description |
---|---|
<Timer> | Root element of the schema |
<time> | The number of milliseconds since January 1, 1970 |
<second> | Seconds |
<minute> | Minutes |
<hour> | Hour |
<dayOfWeek> | Day of the week(Eg: 1 for Sunday) |
<dayOfMonth> | Day of month |
<weekOfMonth> | Week of month |
<weekOfYear> | Week of year |
<month> | Month |
<year> | Year |
<date> | Date |
Message Details Configuration
Figure 4: Message Details Configuration panel
This panel is used to generate the sample message which has to be sent by the Timer service. If you configure to send the message in XML then you can create a sample using the “Generate Sample” option.
Functional Demonstration
Scenario
Sending messages on its output ports when the timer clicks.
Configure the Timer as described in, Configuration section to send sample XML message to its Message Port and Timer Port after every 10 seconds after the component launch.To display components are connected to Timer output ports to receive the sample output.
Figure 5: Scenario demonstration
Useful Tips
If the Timer component is configured for a start date and time which is in the past, when the component starts, all messages which could have been sent had the component started at the configured date and time, will be sent immediately on startup. To avoid this, the component can be configured to send the first message at the first interval which comes in the future, that is, after the component gets launched.