Cache Sessions in the PubSub+ JCSMP API
If you want to use the PubSub+ JCSMP API to enable your application to be able to send and receive requests for cached messages for a topic of interest, you must create one or more cache session objects in a session. A session can support multiple cache session objects. To create a cache session, create a CacheSession
object, which gives you access to the following methods:
cancelCacheRequests()
—Cancels any outstanding cache requests that are currently in progress.close()
—Closes the cache session, which also cancels any outstanding cache requests.getJCSMPSession()
—Retrieves theJCSMPSession
that created thisCacheSession
.getProperties()
—Retrieves theCacheSessionProperties
associated with this cache session, which likely contain configuration details.isClosed()
—Checks if the cache session has been closed, returningtrue
if it is closed.sendCacheRequest()
—Sends a synchronous cache request message. This method is used to request cached messages based on the provided topic and live data action. There is also an asynchronous version of this function, that uses aCacheRequestListener
to handle results.
For more information about the preceding methods, see the PubSub+ Messaging API for JCSMP reference.
The PubSub+ Cache feature is only available to Sessions connected to an event broker that has implemented PubSub+ Cache.