Transfer has become almost a necessity for me these days. I recently had to deploy it on a clustered environment, and had to find a way to keep the Transfer cache between nodes in sync.
A centralized caching system like memcache would work, but a lot of refactoring would be required. Not to mention, Transfer’s cache is its claim to fame.
I turned to google, and it led me to Sean Corfield’s Blog. Where I found a number of good posts on the issue. Even some code that would do most of the dirty work for me. Score!
Almost…It didn’t support composite keys.
After I went at that, I decided to change the approach from requiring 2 gateways to just 1, and instead of 1 CFC to act as an observer and a gateway, I split them up.
The gateway gets set up in the CF Administrator. A config file is provided, and doesn’t require any modification to get you going. Once it’s running the JMS acknowledges it as a listener.
The observer gets attached to Transfer. It will trigger a method that sends a message to the JMS. The message carries the Transfer Object Class name and the ID of the Object that was either deleted or updated.
The JMS then brokers the message to all listening nodes.
That’s right, there is a catch. It requires an instance of Active MQ JMS Message Broker, on each node That’s an opensource Java Messaging Service by the Apache foundation.
It’s fairly light, taking up around 2MB RAM, and minimal CPU when at work. Not to mention, it’s default installation will get you going instantly. The best part is the auto discovery that will detect other brokers on the same network. This frees you from having to maintain the config files for the CF gateway. No need to keep an up-to-date list of IPs for the nodes. You can deploy the gateway as-is to all nodes, and let ActiveMQ do it’s thing.
The project is on RIAForge. I’ve included a sample app along with the code, for a couple reasons. If you are new to all this, then I suggest installing ActiveMQ, and using the sample app to verify everything is setup correctly. The other reason, is to provide sample code to speed up integration.