Service Invocation
This section introduces the service invocation API used when a service call is required in the business logic.
1. Format
DefaultServiceExecutor.execute(trxCd, serviceArg); // Synchronous service link
DefaultServiceExecutor.executeAsync(trxCd, serviceArg, timeout); // Asynchronous service link
DefaultServiceExecutor.executeAsyncForWait(trxCd, serviceArg, timeout); // Asynchronous service link 2
2. Description
-
execute
Links the service in a synchronous manner. The transactions of the calling transaction and the called transaction are processed as the same transaction.
-
executeAsync
Links the service in an asynchronous manner.
The called transaction is executed in a thread separate from the thread performing the calling transaction, and after calling the called transaction, no response object is returned.
The transactions of the calling transaction and the called transaction are separated, and the transaction of the called transaction is processed as a new transaction. -
executeAsyncForWait
Links the service in an asynchronous manner.
The called transaction is executed in a thread separate from the thread performing the calling transaction, and after calling the called transaction, an AsyncResponse object is returned as a response.
Afterwards, by calling the waitForResponse() method of the AsyncResponse object, the response object of the called transaction can be obtained.
The transactions of the calling transaction and the called transaction are separated, and the transaction of the called transaction is processed as a new transaction.
3. Example
@BxmCategory(logicalName = "Service Execute API Sample")
public SSMP1005A001OutDto callInternalLink(SSMP1005A001InDto input)
throws DefaultApplicationException {
logger.debug("============== START ==============");
logger.debug("input = {}", input);
SSMP1001A001InDto calleeInput = new SSMP1001A001InDto();
/**
* @BXMType LogicalArea
* @Desc internal service input data mapping
*/
{
calleeInput.setFeduEmpNo(input.getFeduEmpNo());
}
SSMP1001A001OutDto calleeOutput = null;
SSMP1005A001OutDto output = new SSMP1005A001OutDto();
/**
* @BXMType Try
*/
try {
/**
* @BXMType ServiceExecutorCall
* @Desc internal service call
*/
calleeOutput = DefaultServiceExecutor.execute("SSMP1001A001", calleeInput);
} catch (DefaultApplicationException e) {
/**
* @BXMType ApplicationException
* @Desc throw exception when internal service throw checked exception
*/
throw new DefaultApplicationException("BXME60008", null, new Object[] {}, e);
}
/**
* @BXMType LogicalArea
* @Desc output data mapping
*/
{
output.setFeduEmpNo(calleeOutput.getFeduEmpNo());
output.setFeduEmpNm(calleeOutput.getFeduEmpNm());
output.setFeduOccpNm(calleeOutput.getFeduOccpNm());
output.setFeduMngrEmpNo(calleeOutput.getFeduMngrEmpNo());
output.setFeduHireDt(calleeOutput.getFeduHireDt());
output.setFeduPayAmt(calleeOutput.getFeduPayAmt());
output.setFeduDeptNo(calleeOutput.getFeduDeptNo());
}
logger.debug("output = {}", output);
logger.debug("============== END ==============");
return output;
}