How to run a process on an interval or schedule?

Published: (February 25, 2026 at 11:40 AM EST)
5 min read
Source: Dev.to

Source: Dev.to

Source: Dev.to – How to run a process on an interval or schedule

Interoperability – Running a Process on an Interval or Schedule

InterSystems profile image
InterSystems Developer

When I started my journey with InterSystems IRIS, especially in Interoperability, one of the first questions I had was:
“How can I run something on an interval or schedule?”

Below are two simple classes that solve this problem. They are intended as quick‑start snippets for beginners, not a full‑blown production solution.


(The original article continues with the class definitions and usage examples.)

The Scenario

We need to “take some data from an API and put it into an external database.”
The solution is built from three pre‑existing components:

ComponentPurpose
Ens.BusinessProcessImplements the data‑flow algorithm (prepare request, transform response, handle errors, etc.).
EnsLib.REST.OperationPerforms the HTTP request to the API (uses EnsLib.HTTP.OutboundAdapter).
Ens.BusinessOperationWrites the retrieved data to the external DB via EnsLib.SQL.OutboundAdapter (JDBC).

The hosts for these components are already in place, so they are out of scope for this task.

What’s missing?

We still need an Initiator that:

  1. Runs on a scheduled interval.
  2. Sends a dummy request to the Ens.BusinessProcess to trigger the workflow.

1. Interval Initiator – Util.Service.IntervalCall

/// Call targets by interval
Class Util.Service.IntervalCall Extends Ens.BusinessService
{

/// List of targets to call
Property TargetConfigNames As Ens.DataType.ConfigName;

/// If true, calls are made asynchronously (SendRequestAsync)
Property AsyncCall As %Boolean;

/// If true, and the target list contains more than one target,
/// the process will stop after the first error
Property BreakOnError As %Boolean [ InitialExpression = 1 ];

Property Adapter As Ens.InboundAdapter;

Parameter ADAPTER = "Ens.InboundAdapter";

Parameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId},AsyncCall,BreakOnError";

/// Main entry point – called by the service interval
Method OnProcessInput(pInput As %RegisteredObject,
                     Output pOutput As %RegisteredObject,
                     ByRef pHint As %String) As %Status
{
    Set tSC = $$$OK
    Set targets = $LISTFROMSTRING(..TargetConfigNames)

    Quit:$LISTLENGTH(targets)=0 $$$ERROR($$$GeneralError, "TargetConfigNames are not defined")

    For i=1:1:$LISTLENGTH(targets) {
        Set target = $LISTGET(targets, i)
        Set pRequest = ##class(Ens.Request).%New()

        If ..AsyncCall {
            Set tSC = ..SendRequestAsync(target, pRequest)
        } Else {
            Set tSC = ..SendRequestSync(target, pRequest, .pResponse)
        }
        Quit:($$$ISERR(tSC) && ..BreakOnError)
    }

    Quit tSC
}

/// Populate the Production UI with the selected targets
ClassMethod OnGetConnections(Output pArray As %String, pItem As Ens.Config.Item)
{
    If pItem.GetModifiedSetting("TargetConfigNames", .tValue) {
        Set targets = $LISTFROMSTRING(tValue)
        For i=1:1:$LISTLENGTH(targets) Set pArray($LISTGET(targets, i)) = ""
    }
}
}

How to use it

  1. Add the class to a Production.
  2. In the TargetConfigNames setting, select the business process (or any other target) you want to invoke.

2. Scheduled Initiator – Util.Task.ScheduleCall

When the requirement changes to “run every Monday at 08:00 AM”, the best approach is to use Task Manager.
Create a custom task that launches the initiator programmatically:

/// Launch selected business service on schedule
Class Util.Task.ScheduleCall Extends %SYS.Task.Definition
{

Parameter TaskName = "Launch On Schedule";

/// Business Service to launch
Property ServiceName As Ens.DataType.ConfigName;

Method OnTask() As %Status
{
    #dim tService As Ens.BusinessService
    Set tSC = ##class(Ens.Director).CreateBusinessService(..ServiceName, .tService)
    Quit:$$$ISERR(tSC) tSC

    Set pRequest = ##class(Ens.Request).%New()
    Quit tService.ProcessInput(pRequest, .pResponse)
}
}

Important notes

  • Pool Size of the Initiator Business Service must be set to 0. This disables the built‑in “Call Interval” mechanism (you can clear the interval or leave it – it won’t be used when the pool size is 0).
  • In Task Manager, create a new task:
    1. Choose “Launch On Schedule” as the task type (don’t forget to select the correct namespace).
    2. Set the ServiceName parameter to the name of the Initiator Business Service you created.
    3. Define the desired schedule (e.g., every Monday at 08:00).

Task Manager configuration screen


Recap

ClassWhat it does
Util.Service.IntervalCallRuns on a configurable interval, sending a request to one or many targets.
Util.Task.ScheduleCallSchedules the same initiator via Task Manager, giving you full cron‑style control.

Both classes are lightweight, easy to add to any Production, and provide a solid foundation for beginners who need to trigger Interoperability processes on a schedule.


Scheduling a Task

To create a new scheduled task, navigate to:

System Operation > Task Manager > New Task

Bonus: Running a Task On‑Demand

Sometimes you need to run something in Production only on demand. Instead of building a custom UI on CSP, use the standard Management Portal UI.

  1. Change the task’s Run Type to On Demand.
  2. The on‑demand task list is available at:
System > Task Manager > On‑demand Tasks
  1. Click the Run button to execute the task immediately.

Note: The Run button (manual run) is available for any kind of task.


Summary

You now have a clean architecture for interoperability across your business hosts, with three ways to run your data grabber:

  • By interval
  • On a timetable
  • Manually (on demand)
0 views
Back to Blog

Related posts

Read more »

Dragon Ball Color Correction Process [pdf]

I’m sorry, but the content you provided is a PDF file in binary format, not HTML or plain text. I’m unable to extract and convert the article’s text from this b...