Sunday, August 03, 2008

When you let the Grid do your job

In event driven systems typically a business process needs to be executed when an event is raised. These events are usually a message received from an external system. As infrastructures grow more complex and flexible, computation is shifting from externally run applications to auto-magic processes being run inside the system of records itself. The idea is not new. For number of years companies have relied on scheduled jobs like cron invoked by Operating Systems. Timer services still play an important role in EJB driven systems. The same is true and increasingly getting popular with Oracle Coherence. Oracle Coherence manages data inside a resource called a Cache that behaves like a Map but in a clustered environment. Unlike any off-the-shelf Map implementation, Coherence' NamedCache supports events. A MapListener can be attached to any Cache that can handle events like Inserts, Updates and Deletes. Coherence supports an advanced listener called a Backing Map Listener. A backing map is a data structure that actually manages the data on a node for a given Cache. A backing map listener is like any MapListener but is attached to a backing map and listens to events being generated on a Cache on a specific partition that it is defined on. Backing map listener provides a powerful framework for in-grid-processing. It opens up a facility limited by only your creativity. If a business process is placed inside the backing map listener, these processes will be invoked upon any change in the Cache.
Things to know
1. Events are handled in a synchronous way. It means, the client that raised a Cache event has to wait for BML to return or finish what it is doing.
2. Java5's ExecutorService can be a powerful help to off-load any processing inside the BML for client to not wait for the entire processing to finish.
3. Coherence only manages the flow not how the events should be handled. Process decoupling is left to the business requirements.
Enjoy Coherence!

No comments: