Purge Service

The Purge service looks for eligible records to delete from the Live system databases.

The following table provides an overview of the Purge service:

Category Description
System name PurgeServiceType
Graphical Process Modeler (GPM) categories All Services, System
Description Looks for eligible records to delete from the Live system database.
Business usage Deletes rows by controlling the number of rows to use from ARCHIVE_INFO when purging tables. The Purge Service continues to loop until the purge is complete. This gives you control over how much data can be deleted for each database transaction and also makes sure that all data for a given workflowId is deleted from a table in one transaction. The Purge service physically removes records that have been flagged as eligible for deletion from the Live system databases. Eligibility is determined by the Index Business Process service, which scans the Live systems and flags records that have reached their purge eligibility date and time.
Preconfigured? Yes
Requires third-party files? No
Platform availability All supported Sterling B2B Integrator platforms
Related services Index Business Process service, Archive service, Purge BP LInkage service
Application requirements No
Initiates business processes? No
Invocation Generally, this service is invoked by the Scheduler. The default schedule is to run every ten minutes, but the frequency can be changed.
Business process context considerations No
Restrictions This is an internal service, and should not be used in a business process.

How the Scheduled Purge Works

The purge process takes a specified number of rows from a table for purging, which enables more control over how much data is purged from a table in one transaction. The system takes the first 1000 business processes and deletes all of the data in a specific table for that business process ID. A “loop” is the complete purge of all the tables for those 1000 business processes.

If there is more data than can be deleted in one transaction, due to the row limitation, the purge process continues to loop until all eligible data has been purged. For most users, this setting will not need to be changed; however, if you have very high data loads, you may want to consult IBM® Customer Support for information about customizing this process.

There is no configuration necessary for the Purge service; the service is installed with Sterling B2B Integrator, and scheduled to run every ten minutes. Unless you need to change the schedule, there is no setup required.

Purge All Business Process

The Purge service includes the ability to run a Purge All command. Note that this functionality should only be used when requested by IBM Customer Support. It enables you to purge all eligible records, regardless of date, on demand. The service uses a new BP, PurgeAll.bp, which contains two flags, Purge (set to ALL) and Max Loops (set by default to 100). You can change the Max Loops value. The Purge All and scheduled Purge functions cannot run at the same time, so if the regularly scheduled Purge service is running, the Purge All activity will not start until the scheduled purge is done. If the Purge All activity is running, the scheduled purge will not run until the Purge All is done. (In these cases, you do not need to take any action – this is just for your information. You may want to disable the purge schedule before starting a Purge All, but it is not required.)

CAUTION:
The Purge All business process should not be used for ordinary production purposes. It is only for use, generally on the advice of IBM Support, to immediately remove data from the live system, regardless of its expiration date. This may be advisable, for example, if the Scheduled Purge business process has encountered some failure causing a backup of purge-eligible data. There is an additional flag (MAX_LOOPS) available that will help limit the number of loops made by the Purge All business process, thereby helping to control how much data the system will handle in a single execution. If a large amount of data had accumulated, this limit will help the system continue with other processing.

The following example shows the PurgeAll business process as delivered with Sterling B2B Integrator. Sterling B2B Integrator replaces the necessary entities with the correct values for your system when the business process is invoked.

<process name="PurgeAll">
     <rule name="obtainLock">
         <condition>controlLock ='true' </condition>
     </rule>
      <sequence>
     <assign to='controlLock'>false</assign>
  <operation name="SetLock">
      <participant name="SystemLockService"/>
      <output message="Xout">
        <assign to="LOCK_KEY">PURGE</assign>
       <assign to="DURATION">86400000</assign>
	<assign to="CLEAR_ON_START_UP">true</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="Xin">
       <assign to="." from="*"></assign>
     </input>
    </operation>
      <assign to='controlLock'>true</assign>
      <operation name="Purge Service">
         <participant name="PurgeService"/>
         <output message="Xout">
            <assign to="PURGE_MODE">ALL</assign>
            <assign to="MAX_LOOPS">100</assign>
            <assign to="." from="*"></assign>
         </output>
          <input message="Xin">
            <assign to="." from="*"></assign>
         </input>
       </operation>
   <operation name="unLock">
      <participant name="SystemLockService"/>
      <output message="Xout">
        <assign to="ACTION">unlock</assign>
       <assign to="LOCK_KEY">PURGE</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="Xin">
       <assign to="." from="*"></assign>
     </input>
    </operation>
  <onFault>
     <sequence name="LockFailed">
      <choice>
         <select>
          <case ref="obtainLock" activity="proceedWithLocking"/>
          <case ref="obtainLock" negative="true" activity=
                    "stopWithoutLocking"/>
        </select>
         <sequence name="proceedWithLocking">
           <operation>
            <participant name="SystemLockService"/>
            <output message="Xout">
              <assign to="ACTION">unlock</assign>
              <assign to="LOCK_KEY">PURGE</assign>
              <assign to="." from="*"></assign>
            </output>
             <input message="Xin">
               <assign to="." from="*"></assign>
             </input>
          </operation>
         </sequence>
        <sequence name="stopWithoutLocking">
          <assign to="Document/Msg" append="true">Failed to obtain a lock.!
          </assign>
         </sequence>
      </choice>
       <assign to="Document/Status" append="true">Failed!</assign>
       <assign to="Document/Msg" append="true">Purging failed!</assign>
      <assign to="Document/CurrentHost" append="true">&HOST_NAME;</assign>
      <assign to="Document/CurrentPort" append="true">&LIST_PORT;</assign>
      <assign to="Document/DetailMsg" from="/ProcessData/StatusRpt/text()" 
        append="true"></assign>
       <operation name="SMTP Send">
         <participant name="SMTP_SEND_ADAPTER"/>
         <output message="SMTP_SEND_ADAPTERInputMessage">
          <assign to="xport-smtp-mailfrom">&SI_ADMIN_MAIL_ADDR;</assign>
          <assign to="xport-smtp-mailhost">&SI_ADMIN_SMTP_HOST;</assign>
          <assign to="xport-smtp-mailport">25</assign> 
#:ifdef WOODSTOCK_DIR
            <assign to="xport-smtp-mailto">alert_test@stercomm.com</assign> 
#:else
           <assign to="xport-smtp-mailto">&SI_ADMIN_MAIL_ADDR;</assign> 
#:endif
          <assign to="xport-smtp-mailsubject">Automated Event Notification -
             Purging All Failed</assign>
          <assign to="PrimaryDocument" from="DOMToDoc(Document)/@*"></assign>
          <assign to="." from="*"></assign>
        </output>
         <input message="inmsg">
          <assign to="." from="*"></assign>
        </input>
       </operation>
    </sequence>
   </onFault>
 </sequence> 
</process>

Purge Business Process Chunk

The purge service deletes the rows in a chunk instead of a single delete statement to prevent lock timeouts, excessive rollback, and so on. The chunk parameter in purge service is defined by the number of business processes (Workflow IDs) the process tries to delete in each iteration. The process will go through each table and deletes all rows associated with that group of business processes. The default value is 2000. The purge service finds all business processes that are currently marked as eligible for purging and whose date is less than the system time. It then deletes them in groups using the chunk parameter until they have all been deleted.

The following example shows the purge service defined to delete rows in groups using the chunk parameter:

<operation name="Purge Service">
            <participant name="PurgeService"/>
            <output message="Xout">
              <!-- Added for infinite loop chunk purge -->
             <assign to="CHUNK">50</assign>
             <assign to="." from="*"></assign>
           </output>
            <input message="Xin">
              <assign to="." from="*"></assign>
            </input>
         </operation>