Showing posts from August, 2015

How to build a replicated ehcache through firewall and not to die trying

It's assumed that: You already have a java application and you have an ehcache instance running in your program with 1 cache configured to replicate. You want to connect 1 instance to another instance you have in a remote machine The remote machine you are connecting to is located behind a firewall. You have been given access to only 1 port to make an ssh connection to the remote (firewalled) machine. Ehcache uses RMI to connect the remote instances. When the cache in host 1 tries to connect to cache in host 2, RMI opens a new server socket in host 1 to listen for incoming connections from the host 2. The problem here is that these random ports are not accesible to remote hosts because the hosts are behind a firewall. So to fix it, we need to configure ehcache to only use 2 ports. The " remoteObjectPort " does the magic. So we have this ehcache.xml configuration: 1 server port for the ehcache server to listen to other ehcache servers. 1 server port for the e