Question
· 8 hr ago

Ensemble query

Hi Team,

I've basic learning in Ensemble. I want to create a code as per following request. Please help in clearing following questions

We have a business process-AA. In this business process, we have onRequest method, here after performing some logic, I have to call a method ProcessAAlogic. 

In ProcessAAlogic method, after initial processing, we have to call a business operation BB asynchronously (which will give a flag "AACompleted" having value 1 or 0) in pResponse object.
Now based on this AACompleted flag, I have to call other methods which are part of onRequest method  i.e.,GoAheadtoCC and GoAheadtoDD.

Question-1-how to call a business operation asynhronously and get the response?
Question-2-Assuming AACompleted flag is part of pResponse, then how to write the code to get its value and store the same in newvariable AACompletedfromPresponse.
Question-3-Assuming we fetch the variable AACompletedfromPresponse, then how code flow goes back to on Request method ?

Class AA as Ens.BusinesProcess {

Method on Request (pRequest as ClassA, pResponse as Ens.Response) as %status
{
    // After performing some logic
     Set tSC=..ProcessAAlogic()
   
     If  AACompletedfromPresponse {
    Set tSC=..GoAheadtoCC(AACompletedfromPresponse)
     }
    Else {
    Set tSC=..GoAheadtoDD(AACompletedfromPresponse)
    }

     
}

Method ProcessAAlogic () as %status {

    //after Intial processing 
    Set tSC = ..SendCallAsync("BB", pRequest)

    Set AACompletedfromPresponse=AACompleted (variable from pResponse)
}

}

Product version: IRIS 2023.3
Discussion (1)2
Log in or sign up to continue

Regarding your query about ensemble-specific tasks:

Question 1: Calling a Business Operation Asynchronously and Retrieving the Response

To call a business operation asynchronously, you can utilize either the SendRequestAsync method or follow techniques that enable deferred response handling. Here’s an example:
- The Ensemble framework provides capabilities such as OnRequest and OnResponse, where asynchronous calls can return responses later. These deferred responses allow processing to be resumed when the response is retrieved [1][2].

Question 2: Extracting Variable from pResponse

Once the response is obtained, you can fetch the flag and store it using:

Set AACompletedfromPresponse = pResponse.AACompleted

Ensure that the property AACompleted exists within the structure of pResponse and is appropriately set during the execution of the business operation [1][1].

Question 3: Returning to onRequest Flow After Fetching

Returning flow naturally follows Ensemble’s architecture. After receiving the asynchronous response (via Deferred Response or other mechanisms), you can process additional logic by invoking methods such as GoAheadtoCC or GoAheadtoDD based on the flag check:

If AACompletedFromResponse {
    Set tSC = ..GoAheadtoCC(AACompletedfromPresponse)
} Else {
    Set tSC = ..GoAheadtoDD(AACompletedfromPresponse)
}

This logic should handle the response as it arrives, ensuring it adheres to the asynchronous nature of Ensemble operations [1][2][3].

For complex workflows or scenarios, you may consider implementing features like Deferred Token, or exploring Ensemble's inbuilt abilities to manage asynchronous and dependent transactions within BPL or business processes dynamically [3][1][2].

Sources: