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

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 meant as quick‑start snippets for beginners, not a full‑blown solution.


The Scenario

Assume we need to “Take some data from an API and put it into an external database.”
The solution consists of three components:

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

The implementation of those hosts is out of scope – we’ll assume they already exist.
What we still need is an Initiator that runs on an interval and sends a dummy request to the process.


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

  • Util.Service.IntervalCall – runs on a configurable interval, sending a request to one or many targets.
  • Util.Task.ScheduleCall – lets you schedule 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


### And a Bonus

I often encounter situations where we need to run something in Production **only on demand**.  
While we could build a custom UI on CSP for this, reinventing the wheel isn’t our style.  
Instead, it’s better to use the standard Management Portal UI.

The same task we created earlier can be run manually:

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


3. Click the **Run** button to execute the task immediately.  

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

---

It’s all set now. We have a clean architecture for interoperability across our business hosts, with **three ways** to run our data grabber:

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

Related posts

Read more »

[Boost]

Profile !Vincent A. Cicirellohttps://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaw...