LibraryToggle FramesPrintFeedback

Example 2.5 shows how to schedule a route to start up using the Java DSL. The initial start time, startTime, is defined to be 3 seconds after the current time. The policy is also configured to start the route a second time, 3 seconds after the initial start time, which is configured by setting routeStartRepeatCount to 1 and routeStartRepeatInterval to 3000 milliseconds.

In Java DSL, you attach the route policy to the route by calling the routePolicy() DSL command in the route.


[Note]Note

You can specify multiple policies on the route by calling routePolicy() with multiple arguments.

The initial times of the triggers used in the simple scheduled route policy are specified using the java.util.Date type.The most flexible way to define a Date instance is through the java.util.GregorianCalendar class. Use the convenient constructors and methods of the GregorianCalendar class to define a date and then obtain a Date instance by calling GregorianCalendar.getTime().

For example, to define the time and date for January 1, 2011 at noon, call a GregorianCalendar constructor as follows:

// Java
import java.util.GregorianCalendar;
import java.util.Calendar;
...
GregorianCalendar gc = new GregorianCalendar(
    2011,
    Calendar.JANUARY,
    1,
    12,  // hourOfDay
    0,   // minutes
    0    // seconds
);

java.util.Date triggerDate = gc.getTime();

The GregorianCalendar class also supports the definition of times in different time zones. By default, it uses the local time zone on your computer.

When you configure a simple scheduled route policy to stop a route, the route stopping algorithm is automatically integrated with the graceful shutdown procedure (see Controlling Start-Up and Shutdown of Routes). This means that the task waits until the current exchange has finished processing before shutting down the route. You can set a timeout, however, that forces the route to stop after the specified time, irrespective of whether or not the route has finished processing the exchange.

The following table lists the parameters for scheduling one or more route starts.

ParameterTypeDefaultDescription
routeStartDatejava.util.DateNoneSpecifies the date and time when the route is started for the first time.
routeStartRepeatCountint0When set to a non-zero value, specifies how many times the route should be started.
routeStartRepeatIntervallong0Specifies the time interval between starts, in units of milliseconds.

The following table lists the parameters for scheduling one or more route stops.

ParameterTypeDefaultDescription
routeStopDatejava.util.DateNoneSpecifies the date and time when the route is stopped for the first time.
routeStopRepeatCountint0When set to a non-zero value, specifies how many times the route should be stopped.
routeStopRepeatIntervallong0Specifies the time interval between stops, in units of milliseconds.
routeStopGracePeriodint10000Specifies how long to wait for the current exchange to finish processing (grace period) before forcibly stopping the route. Set to 0 for an infinite grace period.
routeStopTimeUnitlongTimeUnit.MILLISECONDSSpecifies the time unit of the grace period.

The following table lists the parameters for scheduling the suspension of a route one or more times.

ParameterTypeDefaultDescription
routeSuspendDatejava.util.DateNoneSpecifies the date and time when the route is suspended for the first time.
routeSuspendRepeatCountint0When set to a non-zero value, specifies how many times the route should be suspended.
routeSuspendRepeatIntervallong0Specifies the time interval between suspends, in units of milliseconds.

The following table lists the parameters for scheduling the resumption of a route one or more times.

ParameterTypeDefaultDescription
routeResumeDatejava.util.DateNoneSpecifies the date and time when the route is resumed for the first time.
routeResumeRepeatCountint0When set to a non-zero value, specifies how many times the route should be resumed.
routeResumeRepeatIntervallong0Specifies the time interval between resumes, in units of milliseconds.
Comments powered by Disqus
loading table of contents...