Developing Apama Applications > Writing 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 release 5.1 to work with Apama 5.1, you must re-compile it. 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, and new plug-ins that do not mark themselves as thread-safe, 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 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, which returns an interface that defines a sendEventTo() method.
The sendEventTo() method takes three arguments:
*C string that represents the event
*Target context ID
*Sending context ID — This is required to avoid deadlocks when the plug-in is called from one of the EPL interpreter’s threads. This should be 0 if the plug-in is not calling from an EPL interpreter thread.
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 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.