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
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:
- 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.
Start date: The date at which the Timer has to start sending the messages
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
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.
The messages that are sent from the Timer Port have the following schema:
Root element of the schema
The number of milliseconds since January 1, 1970
Day of the week(Eg: 1 for Sunday)
Day of month
Week of month
Week of year
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.
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
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.