How to execute a class method of a process periodically?
Hi all,
I have a requirement to periodically poll a URL to fetch some XML data based on a list of query data, lets say every hour, and map what's returned to HL7 then send downstream, I mostly have everything contained within a business process and DTL but I'm lacking a way of invoking the process every X minutes,
The client has a prefence for as much as possible to be done via out of the box components in the standard HL7 model of "Service --> Process/Rule/DTL --> Operation" within the Web UI,
I'm looking for something to act as the Service part that will trigger the "Process/Rule/DTL --> Operation" parts,
In Rhapsody we might use a Timer component to send a blank dummy message periodically that triggers some javascript logic and the rest of the flow etc.,
What could I use to provide the same functionality in HealthShare?
Thanks for your help :)
Use a Business Service with a basic Ens.InboundAdapter:
Class test.BS Extends Ens.BusinessService { Parameter ADAPTER = "Ens.InboundAdapter"; Method OnProcessInput(pInput As %RegisteredObject, Output pOutput As %RegisteredObject) As %Status { $$$LOGINFO("In OnProcessInput") Quit $$$OK } }
Add it to production and set Call Interval to X seconds (and Pool Size to 1). That would ensure OnProcessInput being called every X seconds after it's last completion.
Perfect, that's what I was looking for, And I would make my calls to the API there, build out a message and send the XML on to the DTL that adapts to HL7?
Yes.
Alternatively you can sync call some BO to make an API call, wait for a response and send that to DTL.
It might make sense if you already have a BO/some-other-preexisting-API-caller so you don't have to reimplement the API call code in BS.
You can also use IRIS scheduled tasks.
I recommend to take a look at this project, that gives you ability to schedule a class-method execution via cron expression.
Hi thanks for the reply, this seems like the cleanest way and CRONs are a good option but our client won't accept external libraries