Apama Predictive Analytics Plug-in 10.15 | Apama Predictive Analytics Plug-in | Working with Predictive Analytics Plug-in | Connecting Predictive Analytics Plug-in to Messaging Services
 
Connecting Predictive Analytics Plug-in to Messaging Services
Predictive Analytics plug-in can accept and process PMML data received from messaging services like Digital Event Services, MQTT, Universal Messaging and so on.
Working with PMML data received from messaging services
The Predictive Analytics plug-in supports data received from other messaging services through interfaces addModelFromStream, addModelFromStreamCb, updateModelFromStream, updateModelFromStreamCb . For more information on interfaces, see ApamaDoc.
action onServiceInitialised(ServiceHandler servicehandler)
{
ModelManager modelmanager := serviceHandler.getModelManager();

// Add MODEL_NAME of PMML_DATA received as sequence of integers
// any errors while loading a model will be reported
// using the default error callback registered during service initialisation

modelManager.addModelFromStream(MODEL_NAME, PMML_DATA);

// Alternatively register a new error handler
//modelManager.addModelFromStreamCb(MODEL_NAME, PMML_DATA, modelConfigError);
..
..

// Update an exiting PMML model with another source pmmlData2 received as
// sequence of integers, any errors while updating the model will be reported
// using the default error callback registered during service initialisation

modelManager.updateModelFromStream(MODEL_NAME, UPDATE_PMML_DATA);

// Alternatively register a new error handler
//modelManager.updateModelFromStreamCb
(MODEL_NAME, UPDATE_PMML_DATA, modelConfigError);

...
...
}

// Optional error handler for reeporting errors encounted while setting up PMML models
action modelConfigError(ServiceError serviceError)
{
log "Model Manager Stream Sample, error with Add/Update model" +
serviceError.getErrorMessage() at ERROR;
}

// Error handler for reeporting errors encounted with the instance
action onServiceError(ServiceError serviceError)
{
log "Model Manager Stream Sample " + serviceError.getErrorMessage()
at ERROR;
}