Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devel:documentation:application_configuration:dev:scheduled_tasks:task-scheduler [2019/11/20 16:39]
tomiskar [DeleteSynchronizationLogTaskExecutorIntegrationTest]
devel:documentation:application_configuration:dev:scheduled_tasks:task-scheduler [2021/02/22 20:38] (current)
apeterova generate initiliazation vector
Line 1: Line 1:
 ====== Tasks scheduler ====== ====== Tasks scheduler ======
  
-{{tag> scheduler}}+{{tag> scheduler final lrt long running task description triggers cron scheduled }}
  
 The task can be scheduled in three different ways - types of ''triggers'': The task can be scheduled in three different ways - types of ''triggers'':
Line 31: Line 31:
 === Configuration QUARTZ (datasource, etc.) === === Configuration QUARTZ (datasource, etc.) ===
  
-Configuration of QUARTZ (scheduler) it is using application properties by individual profiles. In every profile application properties is necessary set path for queart's settings (his own application properties) - ''scheduler.properties.location''. Change property ''scheduler.task.queue.process'' **needed server restart!** This property can not be overloaded by FE configuration agenda.+Configuration of QUARTZ (scheduler) it is using application properties by individual profiles. In every profile application properties is necessary set path for quartz's settings (his own application properties) - ''scheduler.properties.location''. Change property ''scheduler.task.queue.process'' **needed server restart!** This property can not be overloaded by FE configuration agenda.
  
  
 ==== Example ==== ==== Example ====
  
-Example of an implementing task - you will find everything that has been mentioned [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-impl/src/test/java/eu/bcvsolutions/idm/core/scheduler/TestSchedulableTask.java|here]].+Example of an implementing task - you will find everything that has been mentioned [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-impl/src/test/java/eu/bcvsolutions/idm/core/scheduler/service/impl/TestSchedulableTask.java|here]].
  
 ===== Stateful task executors ===== ===== Stateful task executors =====
Line 59: Line 59:
   * ''requireNewTransaction'' ''false'' by default. Each item will be processed in new transaction - ensures successfully processed item will be commited after other item or LRT task fails. Use this property everywhere, when LRT can be executed synchronously (e.g. for synchronization dependent task, which are executed synchronously and wrapped which one parent transaction).   * ''requireNewTransaction'' ''false'' by default. Each item will be processed in new transaction - ensures successfully processed item will be commited after other item or LRT task fails. Use this property everywhere, when LRT can be executed synchronously (e.g. for synchronization dependent task, which are executed synchronously and wrapped which one parent transaction).
   * ''supportsQueue'' - ''true'' by default. If is ''false'', then each item (candidate) will be processed without checking already processed items (queue is ignored). Usable, when processed items should be logged, but queue has to be ignored.   * ''supportsQueue'' - ''true'' by default. If is ''false'', then each item (candidate) will be processed without checking already processed items (queue is ignored). Usable, when processed items should be logged, but queue has to be ignored.
 +  * ''isRecoverable'' - ''false'' by default. See recoverable task introduction below.
 +
 +<note warning>Look out: when scheduled task is removed, then all item will be processed again! Processed items are linked to scheduled task instance. Prevent to remove tasks, which sends notifications etc. (e.g. password expire warning) - notifications will be sent again.</note>
 +
 +===== Recoverable tasks =====
 +
 +@since 10.2.0
 +
 +Task can be executed repetitively without reschedule is needed. When task is canceled (e.g. by server is restarted), then task can be executed again (~recovered) directly from long running task agenda. New task will be created and executed with the same configuration as original task. **When task** is stateful and **supports queue**, then **already processed items will not be processed again**.
 +
 +
 +<note>To enable this feature, task method ''isRecoverable'' has to be overriden and return ''true''.</note>
 +
 +<note important>Only tasks created and **running** in the version **10.2.0** and higher can be run again!</note>
 +
 +{{ :devel:documentation:application_configuration:dev:scheduled_tasks:lrt-sync-recreation.png |}}
 +
  
-<note warning>Look out: when scheduled task is removed, then all item will be processed again! Processed items are linked to scheduled task instance. Prevent to remove tasks, which sends notifications etc. (e.g. passwor exrire warning) - notifications will be send again.</note> 
  
 ===== Implemented task types ===== ===== Implemented task types =====
  
-Implemented long running task are listed bellow. Non schedulable long running tasks are included.+Implemented long running task are listed below. Non schedulable long running tasks are included.
  
 ==== PasswordExpirationWarningTaskExecutor ==== ==== PasswordExpirationWarningTaskExecutor ====
  
 Sends warning notification before password expires. Notification is **not send to disabled identities**. Days before has to be given as task's parameter (number greater than zero). More task could be configured e.g. for sending warning notification 14,7,3 days before password expires. Default notification topic is configured to email sender. Sends warning notification before password expires. Notification is **not send to disabled identities**. Days before has to be given as task's parameter (number greater than zero). More task could be configured e.g. for sending warning notification 14,7,3 days before password expires. Default notification topic is configured to email sender.
 +
 +<note tip>It's good to schedule ''PasswordExpiredTaskExecutor'' and ''PasswordExpirationWarningTaskExecutor'' on the start of day - e.g. ** 0 5 0 ? * * ** => passwords which expired yesterday will be processed and proper notifications will be send.</note>
  
 ==== PasswordExpiredTaskExecutor ==== ==== PasswordExpiredTaskExecutor ====
 Sends warning notification after password expires. Notification is **not send to disabled identities**. Default notification topic is configured to email sender. Sends warning notification after password expires. Notification is **not send to disabled identities**. Default notification topic is configured to email sender.
 +
 +<note tip>Task is scheduled by default on the start of day: ** 0 5 0 ? * * ** - passwords which expired yesterday will be processed and proper notification will be send.</note>
  
 ==== AccountProtectionExpirationTaskExecutor ==== ==== AccountProtectionExpirationTaskExecutor ====
-Removes accounts with expired protection interval. Account has to have ''inProtection'' flag setted to ''true''.+Removes accounts with expired protection interval. Account has to have ''inProtection'' flag set to ''true''.
  
 ==== RetryProvisioningTaskExecutor ==== ==== RetryProvisioningTaskExecutor ====
Line 99: Line 119:
   * ``Synchronization uuid`` - synchronization configuration to schedule.   * ``Synchronization uuid`` - synchronization configuration to schedule.
  
-==== AddNewAutomaticRoleTaskExecutor ====+==== <del>AddNewAutomaticRoleTaskExecutor</del> ==== 
 + 
 +@deprecated since 10.4.0 - ''ProcessAutomaticRoleByTreeTaskExecutor'' is used from version 10.4.0.
  
 Long running task for add newly added automatic role to users. Can be executed repetitively to assign role to unprocessed identities, after process was stopped or interrupted (e.g. by server restart). Long running task for add newly added automatic role to users. Can be executed repetitively to assign role to unprocessed identities, after process was stopped or interrupted (e.g. by server restart).
Line 112: Line 134:
 === Parameters === === Parameters ===
   * ``roleTreeNode`` - automatic role identifier.   * ``roleTreeNode`` - automatic role identifier.
 +
 +==== ProcessAutomaticRoleByTreeTaskExecutor ====
 +
 +@since 10.4.0
 +
 +Recalculate automatic role by tree structure for contracts and positions. Recalculate roles for identities with contract or other position match selected automatic role by tree structure. Can be executed repetitively to assign role to unprocessed identities, after process was stopped or interrupted (e.g. by server restart).
 +
 +=== Parameters ===
 +  * ``roletreenode`` - automatic roles by tree structure to recount.
 +
 +==== ProcessAllAutomaticRoleByTreeTaskExecutor ====
 +
 +@since 10.4.0
 +
 +Recalculate all automatic roles by tree structure for contracts and positions. Recalculate all roles for identities with contract or other position assigned by automatic role by tree structure. Can be executed repetitively to assign role to unprocessed identities, after process was stopped or interrupted (e.g. by server restart).
 +
 +==== ProcessSkippedAutomaticRoleByTreeTaskExecutor ====
 +
 +@since 10.4.0
 +
 +Recalculate skipped automatic role by tree structure. Recalculate automatic roles by tree structure, which were not processed (skipped) after tree structure was changed (e.g. from synchronization).
 +
 +==== ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor ====
 +
 +@since 10.4.0
 +
 +Recalculate skipped automatic role by tree structure for contracts and other positions. Recalculate automatic roles by tree structure for contracts and other positions, which were not processed (skipped) after work position was changed (e.g. from synchronization).
  
 ==== AddNewRoleCompositionTaskExecutor ==== ==== AddNewRoleCompositionTaskExecutor ====
Line 173: Line 222:
 @since 8.2.0 @since 8.2.0
  
-Change key for crypt confidential storage. Taks can be started after you change key in application properties/file to newer. As parameter will be given old key.+Change key for crypt confidential storage. The task can be started after you change key in application properties/file to newer. As parameter will be given old key. See the [[devel:documentation:adm:confidential_storage#change_the_confidential_storage_key|admin guide]]. 
 + 
 + 
 +==== GenerateConfidentialStorageInitializationVectorsTaskExecutor ====  
 + 
 +@since 10.8.0 
 + 
 +The task processes every value in the confidential storage, generates a new initialization vector and encrypts the value using this new initialization vector. 
 +See the [[devel:documentation:adm:confidential_storage#generate_initialization_vectors|admin guide]]. 
  
 ==== RemoveOldLogsTaskExecutor ==== ==== RemoveOldLogsTaskExecutor ====
Line 193: Line 251:
   * ``System`` - Delete operations with given system only.   * ``System`` - Delete operations with given system only.
   * ``Empty provisioning`` - Delete provisioning operations only without attributes. Operation with DELETE type is not considered as empty (even haven't attributes).   * ``Empty provisioning`` - Delete provisioning operations only without attributes. Operation with DELETE type is not considered as empty (even haven't attributes).
 +
 +<code sql>
 +-- PostgreSql
 +-- Delete archives
 +DELETE FROM sys_provisioning_archive WHERE created < now() - INTERVAL '90 day';
 +-- Delete attributes
 +DELETE FROM sys_provisioning_attribute attr WHERE NOT EXISTS (SELECT FROM sys_provisioning_archive arch where attr.provisioning_id = arch.id) AND NOT EXISTS (SELECT FROM sys_provisioning_operation oper where attr.provisioning_id = oper.id);
 +</code>
  
 ==== DeleteExecutedEventTaskExecutor ==== ==== DeleteExecutedEventTaskExecutor ====
Line 198: Line 264:
 @since 9.7.0 @since 9.7.0
  
-Delete sucessfully executed entity events (in the state 'EXECUTED') older than given number of days.+Delete successfully executed entity events (in the state 'EXECUTED') older than given number of days.
  
 === Parameters === === Parameters ===
   * ``Number of days`` - Delete events older than given number of days.   * ``Number of days`` - Delete events older than given number of days.
 +
 +<code sql>
 +-- PostgreSql
 +-- Delete events older then 3 days
 +delete from idm_entity_event where result_state='EXECUTED' AND created <= NOW() - INTERVAL '72 HOURS';
 +vacuum full idm_entity_event;
 +</code>
  
 ==== DeleteLongRunningTaskExecutor==== ==== DeleteLongRunningTaskExecutor====
Line 279: Line 352:
   * ``Workflow definition`` - Delete historic workflow processes with this definition only.   * ``Workflow definition`` - Delete historic workflow processes with this definition only.
  
 +==== VsSystemGeneratorTaskExecutor ====
 +
 +@since 10.4.0
 +
 +Task generates given number of virtual systems, roles and identities. All generated entities are evenly distributed among themselves. I.e. Roles assigned to users and connected to generated systems. Task serves for generating required scenario and following performance test.
 +
 +=== Parameters ===
 +  * ``Item prefix`` - A name prefix of all generated entities. Serves for easier searching of entities in IdM.
 +  * ``System count`` - Number of generated virtual systems.
 +  * ``Role count`` - Number of generated roles.
 +  * ``User count`` - Number of generated identities.
  
 ===== Testing tips ===== ===== Testing tips =====
Line 294: Line 378:
  
   * Support for the check of the competition of the running tasks. Now it is on the task implementation to check if it should be run or not. This could be extracted to the general.   * Support for the check of the competition of the running tasks. Now it is on the task implementation to check if it should be run or not. This could be extracted to the general.
-  * Immediate task running is carried out through the scheduler - a simple trigger - it could be carried out directly through the service [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-api/src/main/java/eu/bcvsolutions/idm/core/scheduler/api/service/LongRunningTaskManager.java|LongRunningTaskManager]] +  * Display of the scheduled triggers in the detail of the scheduled job
-  * Display of the scheduled triggers in the detail of the scheduled job+  * Recover canceled task by server is restarted automatically.
  • by tomiskar