XmlBlaster Logo

REQUIREMENT

client.cache

XmlBlaster Logo


Type NEW
Priority LOW
Status CLOSED
Topic Allows Java clients to poll synchronously for messages with the getCached() method, and access the up to date message high performing from a local cache.
Des
cription

The Java I_XmlBlasterAccess class (the Java client side interface) has a built in cache. If you activate this cache with the createSynchronousCache() method, the xmlBlasterAccess.getCached() method accesses a message on the first call synchronously and returns it to you.

Behind the scenes, a subscribe() is done as well, and incoming updates of this messages are put into the cache. This way the messages in the cache are never outdated. Following getCached() invocations for the same message, are retrieved from the local cache.

getCached() requests where the GetKey contains an EXACT oid are automatically removed from cache when the topic with this oid is erased. XPATH queries are removed from cache on disconnect. You can explicitly remove XPATH cache entries with

  GetKey getKey = new GetKey(glob, "//key[starts-with(@oid,'foo-')]", Constants.XPATH);
  ...
  SynchronousCache cache = xmlBlasterAccess.createSynchronousCache(100);
  ...
  cache.removeEntryByQueryString(cache.getQueryString(getKey));

Note that this is a pure client behavior, and for the moment the only reference implementation is in Java.

A typical use case for this caching feature is a servlet environment where synchronous browser requests need high performing html responses.

Example
Java
      
      try {
         xmlBlasterAccess = glob.getXmlBlasterAccess(); // Hides Corba/RMI stuff

         // Setup cache ...
         xmlBlasterAccess.createSynchronousCache(10);

         // and do the login ...
         xmlBlasterAccess.connect(null, this);

         GetKey getKey = new GetKey(glob, "HelloMessage");
         GetQos getQos = new GetQos(glob);

         // This getCached() is only on the first call a write through to xmlBlaster
         // Following calls retrieve the up to date data from the local cache:
         MsgUnit[] msgUnitArr = xmlBlasterAccess.getCached(getKey, getQos);
      }
      catch (XmlBlasterException e) {
          System.out.println("ERROR: " + e.getMessage());
      }
      
   
Configure

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

See API org.xmlBlaster.client.I_XmlBlasterAccess
See API org.xmlBlaster.client.SynchronousCache
See TEST org.xmlBlaster.test.client.TestSynchronousCache

This page is generated from the requirement XML file xmlBlaster/doc/requirements/client.cache.xml

Back to overview