Contents
 Contents

In FioranoMQ, Last-value Caching can be enabled on a JMS Topic. This section explains how this can be configured and thereby used along the various parameters used to enable and support last-value caching on the FioranoMQ Topics. All the related configurations for this feature are done either at the Topic Subsystem Level or at the Topic Level. Below description and corresponding figures explain how a parameter can be configured at the Topic Subsystem-Level and Topic-Level using Fiorano Studio. The same configuration can also be done from the Topics tab of the FioranoMQ Web Management Console, procedures are detailed in the corresponding chapter for Web Console.

Configuring Last-value Caching

To modify a parameter at the Topic Subsystem-Level in FioranoMQ Server Online mode, follow the steps described below:

  1. Launch Fiorano Studio using the executable (bat/sh) from %INSTALLER_HOME%/Studio/bin.
  2. Make sure that the FioranoMQ Server process is running.
  3. Login to the FioranoMQ Server using FMQ-JMX after providing the necessary Host Address, RMI Port, User Name and Password.
  4. Navigate to JMX Connection > Fiorano > mq > pubsub > PubSubManager > TopicSubSystem > config.
  5. Select the required parameter and modify the value in the right-side parameters panel.


Topic Subsystem-Level Configuration

To modify a parameter at the Topic-Level in FioranoMQ Server Online mode, follow the steps described below:

  1. Launch Fiorano Studio using the executable (bat/sh) from %INSTALLER_HOME%/Studio/bin.
  2. Make sure that the FioranoMQ Server process is running.
  3. Login to the FioranoMQ Server using FMQ-JMX after providing the necessary Host Address, RMI Port, User Name and Password.
  4. Navigate to JMX Connection > Fiorano > mq > pubsub > Topics > Topic > %TOPIC_NAME% > config.
  5. Select the required parameter and modify the value in the right-side parameters panel.


Topic-Level Configuration

Parameters used for Last-value Caching

EnableLastValueCache

Identifies the topic as being capable of caching a snapshot of messages which will be delivered to all new subscribers of the topic. This parameter can be configured at the Topic-Level following the way described in the earlier section of this chapter.

CacheKeyPropertyName

Message header property name that contains the Key (String) under which the message will be cached. This parameter determines the property name used to define the last-value cache Key in the JMS Message using which the message is stored in the Topic's last-value cache.

CachePropertyName

Message header property name that contains a Boolean value instructing the broker to add or remove from the cache any message under the specified Key. This parameter determines the property name used to define whether the JMS Message should be considered to be stored in the Topic's last-value cache.

ParConsumptionLVCache

This parameter determines whether to enable parallel consumption of last-value cache messages from Subscriber's copy. When the Subscriber is created, it initiates a creation of Subscriber's copy of the Topic's last-value cache. If set to false (default), the consumption of messages will start only after the Subscriber completely creates the Topic's last-value cache copy. If set to true, the time the copy is created, a parallel mechanism is enabled to consume the messages from the Subscriber's last-value cache copy.
Note: The total time taken to create the Subscriber's copy of Topic's last-value cache might be slightly higher when this parameter is set to true. This is because, in this case, the access to the Subscriber's copy is shared in mutually exclusive manner between the push and pop operations on the Queue data structure that is being used as copy.

LoadLVCIndicesAtLookup

This parameter determines the instance when the last-value cache indices are read from the file storage into the Server's in-memory buffer. These indices are stored in a Hash structure to uniquely identify the current portfolio of a particular equity. For example, if set to true, the last-value cache indices are loaded at the time of the Topic lookup and when set to false, these are loaded at the time when the MessageProducer sends the first JMS Message to the Topic.

IgnoreNullLVCKey

This parameter determines whether to ignore the message sent to a JMS Topic on which last-value cache is enabled with cache-key property not set. This key is set in the JMS Message Header as a property with name defined by CacheKeyPropertyName. If this parameter is set to true, the JMS Message will be ignored at the time of caching, but will be sent to the listening subscribers on the Topic. If this is set to false, an exception is thrown if the message has no cache-key set.

Icon

This is particularly useful when sending Persistent messages on the Topic, since the Exception needs to be propagated to the JMS MessageProducer so that necessary steps can be taken accordingly.

FlushLVCDataAtStartup

This parameter determines whether to clean-up LVC data stores at the time of start-up of the FioranoMQ Server. This parameter accepts boolean values - 'true' or 'false'. Default value is 'false', which means that when the messages stored in the last-value cache are not deleted and any new Subscribers will get those messages.

Icon

This flag can be used to potentially start the last-value caching afresh and to flush the data stored in the Topics' last-value cache after the Server's each run.

Using Last value Caching

Producer Applications should be changed to use Last-value caching on a Topic. This section explains the procedure with an example. Consider a Topic named STOCK_UPDATES is configured with last-value caching enabled. The following properties are set on it:

  • EnableLastValueCache: true
  • CacheKeyPropertyName: (left as default LVCacheKey)
  • CachePropertyName: (left as default IsLVCache)

The MessageProducer that currently generates STOCK_UPDATE messages is modified as below to add two new properties to each JMS Message being placed on the Topic.

  1. Producer calls message.setStringProperty("LVCacheKey", "COM-1"); where "COM-1" is the identifier of the equity.
  2. Producer calls message.setBooleanProperty("IsLVCache", true); using true if the holding amount is > 0, or false otherwise.

The producer can implement the rule that if holding value is 0, the equity should no longer be considered part of the portfolio. If it is > 0, then the equity is part of the portfolio. With the pseudo-code above, the last-value cache on the Topic is added to (if "COM-1" is a new holding) or updated (if a previous holding has been adjusted). If the holding was 0, the producer would have set the IsLVCache property to false, thereby causing the broker to remove COM-1 from the Topic's last-value cache.

The code block in the MessageProducer looks like this to add or adjust an entry in the Topic's last-value cache:

Points to Note

  • DurableSubscriber creation is disabled on a Topic on which Last-value caching is enabled. This is to ensure that when the Subscriber is started, it will only get the latest snapshot from the Topic and any incoming updates to it from that time onwards.
  • Sometimes it might be necessary to compact the file storage used for the Topic's last-value cache because of its size. Generally, when the message is deleted from the FMQ database files, it is only marked as 'deleted' temporarily but it is actually removed from the hard storage when all the messages in the same file are marked as deleted. When the compaction is done, the file storage will only have the readily deliverable and will not have any messages that are already marked as deleted. For this, a JMX-based operation is provided on Topic Runtime Mbean, which can be invoked from Fiorano Studio or Web Management Console.
  • No changes are required for Subscriber applications to accommodate Last-value caching changes.
Adaptavist ThemeBuilder EngineAtlassian Confluence