Skip to content

Commit

Permalink
[incubator-kie-drools-6199] Clean up quartz related docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Dec 17, 2024
1 parent cd6f510 commit 9bb3350
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ In this example, the rule is scheduled for every hour, after a delay of 30 secon
If the system is paused (for example, the session is serialized and then later deserialized), the rule is scheduled only one time to recover from missing activations regardless of how many activations were missed during the pause, and then the rule is subsequently scheduled again to continue in sync with the timer setting.
The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling a rule and supports the following format:
The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] style cron expression for scheduling a rule and supports the following format:
.Calendar attribute format
[source]
Expand All @@ -151,18 +151,24 @@ calendars "* * 0-7,18-23 ? * *"
calendars "weekday"
----
You can adapt a Quartz calendar based on the Quartz calendar API and then register the calendar in the KIE session, as shown in the following example:
You can define a custom calendar and then register it in the KIE session, as shown in the following example:
.Adapting a Quartz Calendar
.Defining a Calendar
[source,java]
----
Calendar weekDayCal = QuartzHelper.quartzCalendarAdapter(org.quartz.Calendar quartzCal)
private static final org.kie.api.time.Calendar WEEKDAY = timestamp -> {
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(timestamp);
final int day = c.get(Calendar.DAY_OF_WEEK);
return day != Calendar.SATURDAY && day != Calendar.SUNDAY;
};
----
.Registering the calendar in the KIE session
[source,java]
----
ksession.getCalendars().set( "weekday", weekDayCal );
ksession.getCalendars().set( "weekday", WEEKDAY );
----
You can use calendars with standard rules and with rules that use timers. The calendar attribute can contain one or more comma-separated calendar names written as `String` literals.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Example: `TIMER "*/5 * * * *"` (every 5 minutes)
|`CALENDAR`
|E
|A Quartz calendar definition for scheduling the rule.
|A calendar definition for scheduling the rule.
Example: `CALENDAR "* * 0-7,18-23 ? * *"` (exclude non-business hours)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ Example: `timer ( int: 30s 5m )` (every 5 minutes after a 30-second delay)
`timer ( cron:* 0/15 * * * ? )` (every 15 minutes)
|`calendar`
|A http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling the rule.
|A calendar definition for scheduling the rule.
Example: `calendars "* * 0-7,18-23 ? * *"` (exclude non-business hours)
Expand Down Expand Up @@ -1090,7 +1090,7 @@ In this example, the rule is scheduled for every hour, after a delay of 30 secon
If the system is paused (for example, the session is serialized and then later deserialized), the rule is scheduled only one time to recover from missing internalMatches regardless of how many internalMatches were missed during the pause, and then the rule is subsequently scheduled again to continue in sync with the timer setting.
The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling a rule and supports the following format:
The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] style cron expression for scheduling a rule and supports the following format:
.Calendar attribute format
[source,subs="+quotes"]
Expand All @@ -1108,18 +1108,24 @@ calendars "* * 0-7,18-23 ? * *"
calendars "weekday"
----
You can adapt a Quartz calendar based on the Quartz calendar API and then register the calendar in the KIE session, as shown in the following example:
You can define a custom calendar and then register it in the KIE session, as shown in the following example:
.Adapting a Quartz Calendar
.Defining a Calendar
[source,java]
----
Calendar weekDayCal = QuartzHelper.quartzCalendarAdapter(org.quartz.Calendar quartzCal)
private static final org.kie.api.time.Calendar WEEKDAY = timestamp -> {
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(timestamp);
final int day = c.get(Calendar.DAY_OF_WEEK);
return day != Calendar.SATURDAY && day != Calendar.SUNDAY;
};
----
.Registering the calendar in the KIE session
[source,java]
----
ksession.getCalendars().set( "weekday", weekDayCal );
ksession.getCalendars().set( "weekday", WEEKDAY );
----
You can use calendars with standard rules and with rules that use timers. The calendar attribute can contain one or more comma-separated calendar names written as `String` literals.
Expand Down

0 comments on commit 9bb3350

Please sign in to comment.