Apama Documentation : Developing Apama Applications : Developing Correlator Plug-ins : Advanced Plug-in Functionality in C++ and C : Writing correlator plug-ins for parallel processing applications
Writing correlator plug-ins for parallel processing applications
For a plug-in created before Apama 9.9 to work with Apama 9.9, you must re-compile it.
Beginning with release 5.0, all plug-ins are required to be thread-safe. Beginning with release 4.2, the interface is more accurate with respect to the use of const, so minor code changes may be required.
Plug-ins created before Apama 4.2 run in a single operating system thread at a time. The correlator assumes that such plug-ins are not thread-safe. For each call to such a plug-in, the correlator acquires a mutex to ensure that multiple correlator contexts cannot use the plug-in at the same time.
When multiple contexts need to concurrently use a plug-in, you must ensure that the plug-in is thread safe. A plug-in can export a function that returns the capabilities of the plug-in. See the AP_PluginCommon.h header file in the include directory of your Apama installation for the definition of AP_PLUGIN_GET_CAPABILITIES_FUNCTION_NAME. The correlator calls this function before it calls the plug-in's init() function. The return value is a bit-wise OR of capabilities, as defined in the AP_PluginCommon.h header file. If the return value indicates that the plug-in is thread-safe, multiple contexts can make concurrent calls to the plug-in. When multiple contexts need to concurrently use a plug-in, you must ensure that the plug-in is thread-safe.
A plug-in can use a context's ID to send events to a particular context. Use the AP_Context.getContextId() method to obtain the context ID. The correlator passes an AP_Context object to each plug-in. This object has a getCorrelator() method that returns an interface that defines a sendEventTo() method, which has the following signature:
sendEventTo(const char *event, AP_uint64 targetContextId,
const AP_Context &source)
The sendEventTo() method takes three arguments:
*event — For the event to send, specify a string in the format described in Event file format.
*targetContextId — Specify the ID of the context you want to send the event to.
*&source — Specify the context that this plug-in call is running in. This is the AP_Context object that was passed to the plug-in method or event handler method. If this method is called from a background thread then that thread passes an AP_Context::NoContext() object to this method. Specify that object as the source context.
You can obtain the current context ID with a call to AP_Context.getContextId(), which might be useful for sending or passing events to other threads. However, you should not use the returned object as the value for the &source argument.
The following overloading of the sendEventTo() method is deprecated and will be removed in a future release. Use the previously described overloading instead.
sendEventTo(const char *event, AP_uint64 targetContextId,
AP_uint64 sourceContextId)
Note:  
The class AP_Context, which you use for correlator plug-in development, is completely different and unrelated to contexts that you define in EPL for parallel processing.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback