Question
· Jun 6, 2022

No OnProcessInput() method in custom business service

Hello all,

I was looking at some code of a business service of which the author is unknown. It's very simple in what it does; it extends from Ens.BusinessService and has a method that performs SendRequestSync() to a business process. However, I noticed that the business service lacks an OnProcessInput() method. Rather, it uses a method called General() which has the same sort of signature/structure that OnProcess input does--pInput as [Custom Message Class], Output pOutput as [Custom Response Class]. 

The method works as observed in a message trace but I am not sure why. Is it possible to have a method that functions like OnProcessInput() but is just renamed to something else? Would this be an example of overriding the OnProcessInput() method?

Discussion (7)2
Log in or sign up to continue

I use simple classes which extend Ens.BusinessService all the time to run things.

All you need to do is to set the parameter

Parameter ADAPTER = "Ens.InboundAdapter";

Then perhaps add custom Properties and assign them to SETTINGS and then override

Method OnProcessInput(pInput As %RegisteredObject, Output pOutput As %RegisteredObject) As %Status
{

// do your stuff

quit $$$OK

}

Sounds very odd. The adapters OnTask would call the bussiness hosts ProcessInput and this would call OnProcessInput(). If the service is standard then how General() gets called is an oddity.

My only thought (other than observer error) is that the service has a non standard adapter implementation.

If you look at the adapter, does its OnTask call ProcessInput(), or is it hard wired to call General() ?

I think you might have missed my point about the adapter being non standard.

E.g. what if the adapter has code like this...

Method OnTask() As %Status
{
    //Set tSC = ..BusinessHost.ProcessInput($$$NULLOREF)
    Set tSC = ..BusinessHost.General($$$NULLOREF)
    Set ..BusinessHost.%WaitForNextCallInterval=1
    Quit tSC
}

The normal sequence of

OnTask() → ProcessInput() → OnProcessInput()

becomes

OnTask() → General()

Of course this then raises the question, how does the interval then work as it would most likely only run once.

Main point is to check if the adapter has hard wired it in directly. It's the only logical explanation outside of this being an observer error.

Apologies I have not been able to answer until now.

The business service has no adapter as verified by looking at its code as well as its settings in the configuration.

However, it IS tied to a REST Service of which I was previously unaware. An HTTP request is sent with either POST with a payload or GET with the data listed in the URL. When the associated class method fires, it instantiates a request with information from the HTTP request and a response class and uses them as arguments in the General() method.

This solves what Sean raised about the method firing off more than once. My question now would be is it permissible to have a business service with no OnProcessInput() method so long as it is tied to something like a RESTful API? I am a newer developer when it comes to Ensemble/ObjectScript so I am under the impression that OnProcessInput() is the end-all-be-all when it comes to the business service.

Please let me know and thanks for your responses thus far.

I believe so, just wanted to confirm a couple of things>

1. So long as we are using an application to directly invoke the business service, this means the business service doesn't strictly need an OnProcessInput() method?

2. Is the General method thus being called how you described above, i.e. OnTask() --> General() ?

3. Just to confirm I'm grasping the concept, would this be an example of the business service being in the data "pushing" mode as detailed in this link: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...

Thanks very much for your help and input, it is very appreciated by a new dev like myself!