Auto Terminate Service

The Auto Terminate service terminates business processes that are in a specified state for more than a specified number of days.

The following table provides an overview of the Auto Terminate service:

System Name AutoTerminateService
Graphical Process Modeler (GPM) categories) All Services, System
Description This service terminates business processes that have been in a pre-defined state for more than a specified length of time. By default, the Auto Terminate service terminates business processes that have been in a halted state for more than 14 days.
Business usage This is a system service used to automatically terminate certain business processes.
Usage example Used to automate the process of cleaning up business processes.
Preconfigured? Yes
Requires third-party files? No
Platform availability All supported platforms
Related services Works within the Schedule_AutoTerminateService business process.
Application requirements None
Initiates business processes? No
Invocation Invoked by the scheduler. By default, the Auto Terminate service runs once per day at 4:00 A.M.
Business process context considerations None
Returned status values None
Restrictions Used with the bprecover.properties file.
Persistence level System Default
Testing considerations None

How the Auto Terminate Service Works

The Auto Terminate service is pre-configured and, by default, is scheduled to run each day at 4:00 A.M. The service checks for business processes that have been in a specified state for a specified length of time and then terminates them. By default, the Auto Terminate service checks for and terminates business processes that have been in a halted state for over 14 days. You can adjust these settings to suit your specific business needs. See Overriding the bprecovery.properties File Settings for more information.

Implementing the Auto Terminate Service

A pre-configured instance of the Auto Terminate service is provided with Sterling B2B Integrator and may be used in your business processes. You may also create new instances.

To implement a new instance of the Auto Terminate service, complete the following tasks:
  1. Create a new configuration of the Auto Terminate service. For basic information about creating service configurations, see Managing Services and Adapters. For information about the fields specific to this service, see Configuring the Auto Terminate Service.
  2. Specify field settings for the service configuration in the Sterling B2B Integrator Admin Console as necessary.

Configuring the Auto Terminate Service

You can specify settings for the Auto Terminate service in Sterling B2B Integrator using the Admin Console, BPML, and by overriding settings in the bprecovery.properties file.

Creating a Service Configuration in the Admin Console

Use the field definitions in the following table to create a new configuration of the Auto Terminate service.

Field Description
Name Unique and meaningful name for the service configuration. Required.
Description Meaningful description for the service configuration, for reference purposes. Required.
Select a Group Select one of the options:
  • None – Do not include the configuration in a service group at this time.
  • Create New Group – Enter a unique name for a new group, which will be created with this configuration. (You can then add other services to the group as well.)
  • Select Group – If service groups already exist for this service type, they are displayed in the list. Select a group from the list.
Note: For more information about service groups, see Managing Services and Adapters.
Run As User Type the user ID to associate with the schedule, or click the icon and select a user ID from the list. Valid values: Any valid Sterling B2B Integrator user ID.
Use 24 Hour Clock Display Check the box to use the 24-hour clock instead of the default 12-hour clock.
Schedule Specify the scheduling information for running the Auto Terminate service. Valid values:
  • Do not use schedule. If you select this field, the service does not run on a schedule.
  • Run based on timer Valid values are the hour and minutes at which to run the service. If you choose to select a time interval, the valid values are the hours and minutes for the intervals. Add or delete selections as necessary. Specify any schedule exclusions or date exclusions. Indicate whether you want the service to run at startup.
  • Run daily Valid values are the hour and minutes at which to run the service each day. If you choose to select a time interval, the valid values are the hour and minute for the interval. Add or delete selections as necessary. Specify any date exclusions. Indicate whether you want the service to run at startup.
  • Run based on days of the week Valid values are the day of the week, the hour, and the minute that specify when to run the service. If you choose to select a time interval, the valid values are the hours and minutes for the intervals. Add or delete selections as necessary. Specify any date exclusions.
  • Run based on days of the month Valid values are the day of the month, hour, and minute that specify when to run the service. If you choose to select a time interval, the valid values are the hours and minutes for the intervals. Add or delete selections as necessary. Specify any date exclusions.

Setting Up the Service in the GPM

There is no configuration needed in the GPM for the Auto Terminate service.

Overriding the bprecovery.properties File Settings

The number of days a business process must be in a specified state before being terminated by the Auto Terminate service, and the specified state or states, are defined by properties in the bprecovery.properties file. The default settings are specified by the following lines:

auto_terminate_days=14
num_states=1
auto_terminate_state1=halted
auto_terminate_batch=1000

The default settings can be overridden using the customer_overrides.properties file. You can change the number of days before termination, change the specified state, or add additional states.

To change property file settings using the customer override property file:
  1. In the install_dir/properties directory, locate (or create, if necessary) the customer_overrides.properties file.
  2. Open the customer_overrides.properties file in a text editor.
  3. Add the properties that you want to override, using the following format:

    bprecovery.PROPERTY_NAME=PROPERTY_VALUE

    Property Description
    auto_terminate_days Number of days that a business process must be in one of the specified states before being terminated by the Auto Terminate service. Valid values: any positive integer. Default is 14.
    num_states Number of different specified business process states to use as a condition for terminating a business process. Must correspond to the number of auto_terminate_statex properties. For example, if there are 3 auto_terminate_statex properties, num_states must be set to 3. Default is 1.
    auto_terminate_statex Business process state to use as a condition for terminating a business process. x = a digit corresponding to the number of the state. For example, the first state would be auto_terminate_state1.Default is auto_terminate_state1=halted.The number of auto_terminate_statex statements must correspond to the value of num_states. For example, if num_states is set to 3, there must be 3 auto_terminate_statex properties:
    • auto_terminate_state1=1st state
    • auto_terminate_state2=2nd state
    • auto_terminate_state3=3rd state

    Valid states are:

    • interrupted_man
    • interrupted_auto
    • halted
    • waiting
    auto_terminate_batch Maximum number of business processes that will be marked during each run of the Schedule_AutoTerminateService business process. Default is 1000.

    For example, assume that you want to change the value of auto_terminate_days to 10 and add two more business process states, interrupted_auto and interrupted_man, in addition to the default state of halted.

    To do so, add the following lines to the customer_overrides.properties file:

    bprecovery.auto_terminate_days=10
    bprecovery.num_states=3
    bprecovery.auto_terminate_state2=interrupted_auto
    bprecovery.auto_terminate_state3=interrupted_man
    
  4. Save and close the customer_overrides.properties file.
  5. Stop and restart Sterling B2B Integrator to use the new values.

The value of auto_terminate_days in the bprecovery.properties file can also be overridden using BPML in your business process using a statement in the following format:

<assign to="AUTO_TERM_DAYS" >new_value</assign>
The new value can be one of the following:
  • double – Doubles the value of auto_terminate_days in the bprecovery.properties file.
  • an integer value – A new integer value. Partial days can also be defined here. For example, 0.5 would specify one-half of a day.

Business Process Examples

The following BPML is the code used for the Schedule_AutoTerminateService business process included with Sterling B2B Integrator. The Schedule_AutoTerminateService business process invokes the Auto Terminate service and provides e-mail notification of Auto Terminate activities. The e-mail notification provides details of the business processes that will be terminated. These details include the ID, data, and the time that the business process will be terminated. An e-mail notification is also generated after business processes are terminated.

Schedule_AutoTerminateService
<process name="Schedule_AutoTerminateService">
  <rule name="Exist-PDOC">
    <condition>count(//PrimaryDocument) &gt; 0</condition>
  </rule>
  <rule name="Exist-PDOC-onfault">
    <condition>count(//PrimaryDocument) > 0</condition>
  </rule>
 <sequence>
    <operation name="SetLock">
     <participant name="SystemLockService"/>
     <output message="Xout">
        <assign to="LOCK_KEY">AutoTerminateHaltedBPS</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>
   <operation name="Service">
      <participant name="AutoTerminateService"/>
      <output message="Xout">
        <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">AutoTerminateHaltedBPS</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="Xin">
       <assign to="." from="*"></assign>
     </input>
    </operation>
   <sequence name="email">
      <choice name="exist pdoc">
        <select>
         <case ref="Exist-PDOC" activity="sending-email"/>
       </select>
       <sequence name="sending-email">
         <operation name="Get mailfrom">
           <participant name="UserService"/>
           <output message="UserServiceTypeInputMessage">
             <assign to="MethodName">getEmail</assign>
             <assign to="UserName">admin</assign>
             <assign to="." from="*"></assign>
           </output>
            <input message="inmsg">
             <assign to="mailfrom" from="//UserService/getEmail/text()"></assign>
           </input>
          </operation>
         <operation name="get mailto">
           <participant name="UserService"/>
           <output message="UserServiceTypeInputMessage">
             <assign to="MethodName">getEmail</assign>
             <assign to="UserName">admin</assign>
             <assign to="." from="*"></assign>
           </output>
            <input message="inmsg">
             <assign to="mailto" from="//UserService/getEmail/text()"></assign>
           </input>
          </operation>
         <operation name="SMTP Send">
           <participant name="SMTP_SEND_ADAPTER"/>
           <output message="SMTP_SEND_ADAPTERInputMessage">
             <assign to="xport-smtp-mailfrom" from="//mailfrom/text()"></assign>
             <assign to="xport-smtp-mailhost" from="'00.000.000.00'"></assign>
             <assign to="xport-smtp-mailport">25</assign>
             <assign to="xport-smtp-mailto" from="//mailto/text()"></assign>
             <assign to="xport-smtp-mailsubject">Automated Terminate Notification
                </assign>
             <assign to="." from="*"></assign>
           </output>
            <input message="inmsg">
              <assign to="." from="*"></assign>
            </input>
         </operation>
       </sequence>
      </choice>
   </sequence>
    <onFault>
     <sequence>
        <operation>
         <participant name="SystemLockService"/>
         <output message="Xout">
           <assign to="ACTION">unlock</assign>
           <assign to="LOCK_KEY">AutoTerminateHaltedBPS</assign>
           <assign to="." from="*"></assign>
         </output>
          <input message="Xin">
           <assign to="." from="*"></assign>
         </input>
        </operation>
       <sequence name="email">
         <choice name="exist pdoc">
           <select>
              <case ref="Exist-PDOC-onfault" activity="sending-email-onfault"/>
           </select>
           <sequence name="sending-email-onfault">
             <operation name="Get mailfrom">
               <participant name="UserService"/>
               <output message="UserServiceTypeInputMessage">
                 <assign to="MethodName">getEmail</assign>
                 <assign to="UserName">admin</assign>
                 <assign to="." from="*"></assign>
               </output>
               <input message="inmsg">
                 <assign to="mailfrom" from="//UserService/getEmail/text()">
                     </assign>
               </input>
              </operation>
             <operation name="get mailto">
               <participant name="UserService"/>
               <output message="UserServiceTypeInputMessage">
                 <assign to="MethodName">getEmail</assign>
                 <assign to="UserName">admin</assign>
                 <assign to="." from="*"></assign>
               </output>
               <input message="inmsg">
                 <assign to="mailto" from="//UserService/getEmail/text()">
                     </assign>
               </input>
              </operation>
             <operation name="SMTP Send">
               <participant name="SMTP_SEND_ADAPTER"/>
               <output message="SMTP_SEND_ADAPTERInputMessage">
                 <assign to="xport-smtp-mailfrom" from="//mailfrom/text()">
                      </assign>
                 <assign to="xport-smtp-mailhost" from="'00.000.000.00'">
                      </assign>
                 <assign to="xport-smtp-mailport">25</assign>
                 <assign to="xport-smtp-mailto" from="//mailto/text()">
                      </assign>
                 <assign to="xport-smtp-mailsubject">Automated Terminate 
                        Notification </assign>
                 <assign to="." from="*"></assign>
               </output>
               <input message="inmsg">
                 <assign to="." from="*"></assign>
               </input>
              </operation>
           </sequence>
          </choice>
       </sequence>
      </sequence>
   </onFault>
  </sequence>
</process>

The following BPML example doubles (by overriding) the number of Auto Terminate days defined in the bprecovery.properties file.

<operation name="Service">
      <participant name="AutoTerminateService"/>
     <output message="Xout">
        <assign to="AUTO_TERM_DAYS" >double</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="Xin">
       <assign to="." from="*"></assign>
     </input>
    </operation>

The following BPML example changes (by overriding) the number of Auto Terminate days to a half day.

    <operation name="Service">
     <participant name="AutoTerminateService"/>
     <output message="Xout">
        <assign to="AUTO_TERM_DAYS" >0.5</assign>
       <assign to="." from="*"></assign>
     </output>
      <input message="Xin">
       <assign to="." from="*"></assign>
     </input>
    </operation>