User bio
404 bio not found
Member since Mar 4, 2016
Replies:

Hi Prashanth,

I had a similar requirement once. The following is how I managed it:

First, I setup a method in a CSP dispatch class, which respond to a REST endpoint, to invoke a Business Service in the current namespace working production:

ClassMethod SomeRestEndpointCallback(body As %DynamicArray) As %DynamicObject
{
    $$$TOE(st, ##class(Ens.Director).CreateBusinessService("BusinessServiceName", .service))
    $$$ThrowOnError(service.ProcessInput(body, .output))
    Return output
}

Then, I created a adapterless Business Service (https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...) in order to don't pooling for data but just wait for an external trigger instead:

Class some.package.AdapterlessBS Extends Ens.BusinessService
{

/// Configuration item(s) to which to send file stream messages
Property TargetConfigNames As Ens.DataType.ConfigName(MAXLEN = 1000);

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

Method OnProcessInput(request As %RegisteredObject, Output response As %RegisteredObject) As %Status
{
    Set tSC = $$$OK
    Try {
        // Could be any message... adapter to your needs
        Set tMsg = ##class(Ens.StringResponse).%New()
        Set tMsg.StringValue = "some value"
        
        // Send the message to the targets
        Set targets = $LFS(..TargetConfigNames)
        For i=1:1:$LL(targets) {
            Set target = $LG(targets, i)
            // can be sync or async... it's up to you decide
            //Set tSC = ..SendRequestSync(target, tMsg)
            Set tSC = ..SendRequestAsync(target, tMsg)
            Quit:$$$ISERR(tSC)
        }
    }
    Catch (ex) {
        Set tSC = ex.AsStatus()
    }
    Quit tSC
}

Now, you can add this Business Service to a interoperability production and set the desired Business Process as its target. So, when your REST endpoint is accessed, it will call the BS and then the BP.

HTH,
José

Open Exchange applications:
Certifications & Credly badges:
Global Masters badges:
Followers:
Following:
José has not followed anybody yet.