WSO2 CEP allows you to map custom content from registry for the XML, JSON and Text mapping types. Custom mapping is stored as a registry resource to be used by the publisher instead of being specified as inline input. WSO2 CEP caches this resource at runtime, and the cache is updated after every cache timeout specified in minutes. If caching is not required, specify the cache timeout as 0.
The following example illustrates how to carry out custom mapping using a registry resource.
Save the following configuration as an XML file in a preferred location in your machine.
- Log into the WSO2 CEP Management Console.
- Add the XML file you created as a registry resource as follows. For more information about the registry, see Registry.
- In the Main tab expand the Registry section and click Browse.
- Under Tree View, navigate to
/_system/configdirectory and click Detail View.
- Click Add Collection. In the Name field, enter
Templateand click Add. This creates a new sub directory named
Navigate to the
/_system/config/Templatesub directory and click Add Resource. Then enter information as shown in the table below, and click Add.
Field Value Method
Upload content from file
File Browse and select the XML file you saved in step 1. Name
Field Value Event Publisher Name
Event Source Select an available event stream. Output Event Adapter Type
Under Mapping Configuration, select Text for the Message Format field. Then click Advanced. This expands the Create a New Event Publisher page to display the Text Mapping sSelect the Pick from Registry option. In the Registry Path field, navigate to the registry location where you saved the registry resource created in step 3.
In this example, the default value of
15is left unchanged for the Cache Timeout (in minutes) field. Therefore, this resource will be cached every 15 minutes.
- Click Add Event Publisher.
Using custom registry paths
The registry resource path itself can be parameterized using runtime attribute values. If the event stream to which the
logger publisher in the example above is connected has an attribute named
meta_language, a different registry source is selected depending on the runtime value of the