If an XTP cache is to be referenced in complex event processing rules, consideration must be given to an application for storing initial data in the XTP cache. If an existing cache can be used, use an existing cache access application.
Refer to the Interstage eXtreme Transaction Processing Server manuals for information on designing and developing a cache access application.
Refer to "5.4.10.1 XTP Cache Compatible Formats" for information on the format of the cache to be updated.
Each "HashMap" to be specified in "Key" and "Value" for an XTP cache must be associated as follows:
In the "HashMap" key, set the value to be specified in "keyProperty" of the Virtual Data Window.
In "Key" in the XTP cache, set the same value as that of the "HashMap" key above.
Example
Example of a Virtual Data Window
@VDW(cacheName='CacheA', keyProperty='key')
create window windowName.isxtp:vdw() as (key string, address string);
Example of a program to add entries to an XTP cache
import javax.cache.*;
import java.util.HashMap;
(...)
CacheManager cacheManager = Caching.getCacheManager();
Cache<String,HashMap> cache = cacheManager.getCache("CacheA"); ... 1.
String keyProperty = "key"; ... 2.
String keyValue = "1"; ... 2.
HashMap value = new HashMap(); ... 3.
value.put(keyProperty, keyValue); ... 3.
value.put("address", "Boston"); ... 3.
cache.putIfAbsent(keyValue, value); ... 4.
(...)
Obtain the cache to be used by the Virtual Data Window.
Create the key property name and its value to be specified in "keyProperty" of the Virtual Data Window. Here, "key" is set as the "keyProperty".
Create the "java.util.HashMap" object to be stored as "Value" of the cache. Here, a "java.lang.String" type value is set in the "address" property. Also, ensure that the "keyProperty" created in "2." is set.
Add entries to the cache.