Apache Commons logo

Commons JCS™

Lateral UDP Discovery

Rather than list all the other lateral servers in the configuration file, you can configure the TCP lateral to use UDP discovery. In discovery mode, lateral TCP caches will broadcast to a multicast address and port, letting all listeners know where they are.

On startup each lateral will issue a special message requesting a broadcast from the other caches. Normal broadcasts occur every 30 seconds. (This is to be made configurable.) Regions that don't receive, are running in send only mode, don't broadcast anything but requests.

When a lateral receives a discovery message it will try to add the lateral to the nowait facade for the region. If it already exists nothing happens. If a region is not configured to send laterally, nothing happens, since it doesn't have a no wait.

This allows you to have the same configuration on every machine.

Configuration

The configuration is fairly straightforward and is done in the auxiliary cache section of the cache.ccf configuration file. In the example below, I created a TCP Lateral Auxiliary Cache referenced by LTCP. It uses UDP Discovery to locate other servers. It broadcasts to multicast address 228.5.6.8 and port 6780. It listens to port 1110.

jcs.auxiliary.LTCP=org.apache.commons.jcs.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes
jcs.auxiliary.LTCP.attributes.TcpListenerPort=1110
jcs.auxiliary.LTCP.attributes.PutOnlyMode=true
jcs.auxiliary.LTCP.attributes.UdpDiscoveryAddr=228.5.6.8
jcs.auxiliary.LTCP.attributes.UdpDiscoveryPort=6780
jcs.auxiliary.LTCP.attributes.UdpDiscoveryEnabled=true