Managing Data Retention for Inbound Requests

Request data is persisted in the platform for monitoring as InboundRequest, InboundRequestError, and IntegrationApiMedia types. You can change the data retention policy for how long the data persists in the system, and for when and how often data clean-up cron jobs run.

This tutorial guides you through changing the request data retention duration, the timing and intervals at which request data clean-up jobs run, and then running the data clean-up cron job manually in Backoffice.

Changing the Data Retention Policy and Clean-up Schedule

You can change the duration of request data retention and the schedule for cleaning up request data using an ImpEx script or in Backoffice.

Change the Data Retention Policy and Clean-up Schedule using ImpEx

By default, the extension creates two cron jobs, one for cleaning up InboundRequest and InboundRequestError types. You can see the default settings in the following ImpEx.
  • INSERT_UPDATE AfterRetentionCleanupRule creates the cleanup rules for the InboundRequest and IntegrationApiMedia cron jobs. The default retention period is 604800 seconds (7 days).
  • INSERT_UPDATE RetentionJob defines how many items per batch get deleted at once. You can change the number of items for better performance.
  • INSERT_UPDATE CronJob creates the cron job and specifies when, and which days of the week to run each of the two cron jobs
  • INSERT_UPDATE Trigger defines when to run each job. The expression 0 0 0 * * ? runs the jobs every day at midnight. The server must be running at the time you specify in order for it to delete the persisted request data.
INSERT_UPDATE AfterRetentionCleanupRule ; code[unique=true]                   ; retirementItemType(code)     ; itemFilterExpression    ; actionReference           ; retentionTimeSeconds  ; retirementDateAttribute(enclosingType(code),qualifier)
                                        ; inboundRequestCleanupRule      ; InboundRequest           ;                         ; basicRemoveCleanupAction  ; 604800                ; InboundRequest:creationtime
                                        ; inboundRequestMediaCleanupRule ; IntegrationApiMedia      ;                   ; basicRemoveCleanupAction  ; 604800                ; IntegrationApiMedia:creationtime
 
 
INSERT_UPDATE RetentionJob  ; code[unique=true]                    ; retentionRule(code)                    ; batchSize
                            ; inboundRequestCleanupJob        ; inboundRequestCleanupRule          ; 100
                            ; inboundRequestMediaCleanupJob   ; inboundRequestMediaCleanupRule     ; 100
 
 
INSERT_UPDATE CronJob   ; code[unique=true]                       ; job(code)                            ; sessionLanguage(isoCode)[default=en]
                        ; inboundRequestCleanupCronJob       ; inboundRequestCleanupJob         ;
                        ; inboundRequestMediaCleanupCronJob  ; inboundRequestMediaCleanupJob    ;
 
 
# CronJob Triggers set to run every day at midnight
INSERT_UPDATE Trigger ; cronJob(code)[unique=true]                     ; cronExpression
                      ; inboundRequestCleanupCronJob          ; 0 0 0 * * ?
                      ; inboundRequestMediaCleanupCronJob     ; 0 0 0 * * ?
For this tutorial, change the retention for the InboundRequest to 30 seconds.
  1. In a web browser, navigate to the SAP Commerce Cloud Administration Console at https://localhost:9002/ and log in.
  2. Click Console > ImpEx Import.
  3. To override the default retention settings, paste the following ImpEx into the Import Content field and click Import content.
    INSERT_UPDATE AfterRetentionCleanupRule; code[unique = true]; retirementItemType(code); itemFilterExpression; actionReference; retentionTimeSeconds; retirementDateAttribute(enclosingType(code), qualifier)
    ; inboundRequestCleanupRule      ; InboundRequest      ; ; basicRemoveCleanupAction ; 30 ; InboundRequest:creationtime
  4. Verify that the change was made. In a web browser, navigate to https://localhost:9002/backoffice/ and log in.
  5. In the Administration perspective, click System > Retention Rule.
  6. Locate and click inboundRequestCleanupRule.
  7. At the bottom of the screen, scroll to the Properties section and verify that the value in the Retention Time in Seconds field is 30.

Running the Data Clean-up cron jobs

Now you can run the cron job. To see the results of the cron job without waiting until the next scheduled job, change the job schedule. You can either change the schedule using ImpEx, or by triggering the job manually in Backoffice.

Changing the job schedule using ImpEx

  1. To change the inboundRequestCleanupCronJob to run every 30 seconds, run the following ImpEx:
    INSERT_UPDATE Trigger ; cronJob(code)[unique=true]      ; cronExpression
                          ; inboundRequestCleanupCronJob    ; */30 * * * * ?
  2. Wait 30 seconds and then view the log in terminal. If the job ran successfully, the log shows:
    INFO  [hybrisHTTP30] [PerformCronJobAction] Performing CronJob CronJobModel (8796093514229@34) from Backoffice!
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Starting AfterRetentionCleanupJob
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Selecting items for clean up using inboundRequestCleanupRule
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 1 items for clean up, using basicRemoveCleanupAction
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 0 items for clean up, using basicRemoveCleanupAction
    

Changing the job schedule and running the cron job in Backoffice

To clean up a persisted InboundRequest using the Integration UI Tool view in Backoffice, perform the following steps.

  1. In a web browser, navigate to https://localhost:9002/backoffice/ and log in.
  2. In Backoffice, from the drop-down menu at the top, click Administration > Integration UI Tool.
  3. In the navigation menu on the left, click System > Background Processes > Cronjobs.
  4. In the list of jobs, click inboundRequestCleanupCronJob. The job details appear in the bottom of the screen.
  5. Click the Run Cronjob button and click Yes in the confirmation window. The cron job runs.
  6. View the log in terminal to verify that the job ran successfully. The log should show:
    INFO  [hybrisHTTP30] [PerformCronJobAction] Performing CronJob CronJobModel (8796093514229@34) from Backoffice!
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Starting AfterRetentionCleanupJob
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Selecting items for clean up using inboundRequestCleanupRule
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 1 items for clean up, using basicRemoveCleanupAction
    INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 0 items for clean up, using basicRemoveCleanupAction
    
  7. In Backoffice, click Administration > Integration UI Tool.
  8. In the navaigation on the left, Monitoring > Inbound.
  9. Click Search. If the cron job successfully deleted the InboundRequest, it does not appear in the list.