Exchange Pre-configured Maestro services. | Platform Developer | All versions This feature is related to v5.1 and higher.
Currently, Journey Manager provides the following API to log third party service calls:
new TxnUpdater(txn).addServiceCallLog(serviceName, moreInfo, serviceEndpoint).update();
The problem with the existing data is that:
In order to solve this and be able to know which Exchange package a service log record belongs to, with minimum backend and API changes, we use the moreInfo parameter to provide the Exchange package information in the following format:
EXCHANGE|exchange-project-code|moreInfo
For example, the Mitek TIDEN project has the following code to record service log at the moment:
// record service usage
new TxnUpdater(txn).addServiceCallLog('MitekTidenId Prefill',"EvidenceId: $evidenceId", endPoint).update()
It should be changed to the following to support the new convention:
// record service usage
new TxnUpdater(txn).addServiceCallLog('MitekTidenId Prefill',"EXCHANGE|mitek-tiden|EvidenceId: $evidenceId", endPoint).update()
Please note that the Exchange project code should match the "project.code" defined in the build.properties. For example, in the Mitek TIDEN project, build.properties has the following line:
project.code=mitek-tiden
Hence, mitek-tiden should be used as the Exchange project code in the moreInfo string.
Any new project needs to follows this convention.
For all existing projects, we need to follow this convention whenever we upgrade the package.
When utilizing third party services in groovy service definitions it is important to record each successful usage. Usage statistics are very useful and sometimes required to be tracked for reconciliation and billing purposes.
The TxnUpdater provides a function to record these events as demonstrated below.
The service call should be logged only if:
import com.avoka.tm.svc.TxnUpdater
import com.avoka.tm.http.GetRequest
import com.avoka.tm.http.HttpResponse
...
try {
response = new GetRequest(serviceEndpoint).execute()
} catch(Exception e){
// Log and return
new EventLogger().setTxn(txn).setMessage(e.getMessage()).logError()
return result.systemError()
}
if (response?.isDataError() || checkBodyError(response)) {
return result.dataError(getDataErrorMsg(response))
}
if (response?.isSuccess()) {
// Add the 3rd Party Service Call Log entry
new TxnUpdater(txn).addServiceCallLog(serviceName, 'More Info (optional)', serviceEndpoint).update()
// Now process the response
...
}
The inputs to this addServiceLog function are:
You must call the update() function on the TxnUpdater to commit the log record.