Cache control provides a framework for multiple WOW instances to communicate between each other for the purpose of server load balancing and redundancy.
The ActiveMQ framework (created by the Apache Software Foundation, developers of the Tomcat server) will handle the messaging between multiple WOW instances. A single WOW instance (known as the "manager" instance) will be configured to run ActiveMQ. When a table is updated on a WOW instance, that specific WOW instance publishes a message using ActiveMQ indicating which table was updated. Other WOW instances will then receive that message and update their caches accordingly. The instances which will receive these messages (and send their own) are defined by Cache control groups.
Cache Control Groups
A cache control group is a group of two or more WOW instances that you want to be informed when a table is updated by any of the WOW instances assigned to that group. All instances in the cache control group both publish and consume messages (meaning they both inform the group when their own tables are updated and also listen for table updates from other instances). The manager instances is also part of the cache control group and has the additional responsibility of also running ActiveMQ.
A cache control group is defined by an entry in WOW Configuration Values inside WOW Utilites. It requires a Key value of 'CACHE_CONTROL_GROUP', a Value set to a unique cache control group name and the Display Value set to the URL for the ActiveMQ
instance. In theory, multiple cache control groups could be defined in Configuration Values.
Joining Cache Control Groups
Just because there is an entry in the Configuration Values in WOW doesn't automatically mean that the WOW instance is part of that cache control group. To actually assign an instance to a cache control group there must be an entry in the wow.properties file with the "wow.cache.control.groups" property. For example, a WOW instance that has the above Configuration Values could have the following in its wow.properties file:
wow.cache.control.groups = GROUPA, GROUPB
The WOW instance with the above wow.properties would be a part of cache control group GROUPA and GROUPB but not part of GROUPC
Cache Control Manager Instance
The manager instance has to indicate that it is the manager instance. This is done in the wow.properties file, similarly to joining cache control groups. For example:
wow.cache.control.manager = GROUPA, GROUPB
That instance would be the manager for both GROUPA and GROUPB
Unique ID
A WOW instance has to define an ID in the wow.properties that is unique among all instances in the cache control group. For example:
wow.cache.control.id = WOW1
In that example, it is up to the WOW developers/deployers to make sure that no other WOW instance has that specific cache control ID.
Restricting Aliases
A WOW instance also has the ability to restrict the connection aliases that participate in a cache control group. For example, when a table is updated with the CONN_ALIAS_A or CONN_ALIAS_B aliases then a message should go out to all the members of the cache control group, but not when CONN_ALIAS_C is used to update a table. Additional entries in WOW Configuration Values determine the aliases that participate in a cache control group. For example:
Listing alias is optional - if there are no aliases listed in Configuration Values for a cache control group then all aliases participate in a cache control group.
ActiveMQ Messages
ActiveMQ messages are published using a topic (not a queue). Messages are asynchronous and not persisted. The topic name begins with a prefix of "CCG_" and end with the name of the cache control group. So the GROUPA cache control group would use the CCG_GROUPA topic for messages.
Whenever WOW updates a table (or inserts/deletes from a table) it checks to see if it is part of any cache control groups, and if the table's alias is active for any of its cache control groups. If so then it publishes a message indicating that the table was updated.
The message includes the following information:
SenderID - The unique cache control ID for this WOW instance (as read from wow.properties)
Connection Alias - The alias for the updated table
Library - The library of the updated table
Table Owner - The owner of the updated table
Table Name - The name of the updated table
A background thread waits to process any messages received from the topic. When a message is received, the background thread first checks to make sure the message did not come from the same WOW instance. If the message came from a different WOW instance then the processing thread clears the cache for the table (but only if that connection has already been started).
Note: This assumes that corresponding DB connections have the same alias on ALL WOW instances in the cache control group.