PRODUCTS AND SERVICES INDUSTRIES SUPPORT PARTNERS COMMUNITIES ABOUT
  The Coherence Incubator
  Processing Pattern 1.0.0
Added by Rob Misek, last edited by Rob Misek on Oct 29, 2009  (view change)

Labels

 
This documentation applies to the Processing Pattern 1.0.0. The latest Processing Pattern documentation is available here.

The Processing Pattern

This is an example implementation of a Processing pattern, a generalized approach for submitting and asynchronously processing (ie: executing) "work" in a system.

The Processing Pattern advocates that;

  1. Submitters are used to submit "work" (typically regular objects) for asynchronous processing.
  2. Dispatchers are responsible for dispatching Submissions for processing.
  3. A Submission Outcome must be returned after each submission to track/cancel processing of said Submissions.

This implementation of the Processing Pattern additionally advocates that;

  1. Many Dispatchers may be "registered" to enable specific processing of different types of Submission.
  2. Dispatchers are consulted in order of "registration" for each Submission to determine suitability for routing. (This is called "dispatch chaining)
  3. Out of the box, two Dispatcher implementations are provided, one to Log the submissions, and another to execute Java Runnables or Java Callables.

Rationale

This implementation of the Processing Pattern provides a simple and yet powerful extensible framework for the processing of "work" across a Coherence Cluster, without needing to know the internals of Coherence or build custom configurations. Unlike traditional hub-and-spoke / master-worker / broker-agent Processing Pattern implementations, this implementation avoids the classic "single-point-of-failure", "single-point-of-dispatch", "single-point-of-contention" problems as the core state management and distribution is managed by the Data Grid.

Outline

Release Name: Version 1.0.0: August 11th, 2009
Target Platforms: Java Standard Edition 5+
Requires Coherence Version: 3.3.1+, 3.4+ or 3.5.2+
Dependencies: Coherence Common 1.4.0
Download: coherence-processingpattern-1.0.0.jar
MD5:29a071d41617aab24f00f6e5f0037fc8
Source Code and Documentation: coherence-processingpattern-1.0.0-src.zip
MD5:56572cca165dd7d6002c8914eda38a3f
Previous Releases: (none)

Dependencies

This project (like other Coherence Incubator projects) uses Apache Ivy for dependency specification and management. While a standard ivy.xml definition file ships with the source and documentation distribution, the following diagram visually indicates the current dependencies.

Example

The following demonstrates a simple example of the Processing Pattern.

//register dispatchers (across the cluster)
DispatcherManager dispatcherManager = DefaultDispatcherManager.getInstance();		
Dispatcher loggingDispatcher = new LoggingDispatcher("MyLogger");
Dispatcher localExecutor     = new LocalExecutorDispatcher("MyExecutor");
		
dispatcherManager.registerDispatcher(loggingDispatcher);
dispatcherManager.registerDispatcher(localExecutor);

//submit a callable with a submitter
Submitter submitter = DefaultSubmitter.getInstance();
SubmissionOutcome result = submitter.submit(new TestCallable(), new RequestData());

//get (and wait) for the result		
Object r = result.get();
		
System.out.println("*** got result r: " + r);
		
assert(r.equals("Hello Client!"));
		
//(optional) if you never use the dispatchers again, you can unregister them
dispatcherManager.unregisterDispatcher(loggingDispatcher);
dispatcherManager.unregisterDispatcher(localExecutor);