An SOA odyssey

Thursday, December 15, 2005

Inter Action Communication

One of the interesting issues we tackled in this release was that of allowing EDAF business actions to communicate their state information.

Our original design made the assumption that we would have controller type business actions that would invoke other business actions using the in-process dispatching adapter in EDAF. Each of the invoked business actions would when necessary create exceptions and return those to the controller who would then add them to its exception collection that eventually is sent back to the caller as a series of XML elements.

While this design allows the business actions to be independent and the controller to rollback the work of all the invoked actions, it does not allow for business actions that have dependencies to communicate when called by the controller. In other words the communication model here is essentially from the controller to each invoked action whereas pairs of invoked actions have no visibility to each other.

Fortunately, EDAF allow for this by supporting the concept of a Context object. So the mechanism to do this is to add items to the EDAF Context object (this.Context) before invoking the action. We were using this technique already to send flags like a ValidateOnly flag that instructs each action to validate the request but do not process it.

However, for this release we added the capability for actions to be aware of the exceptions that have been created within the entire request. We use a base class called BusinessActionBase from which all of our actions are derived. To this class we added a protected method called DoesExceptionExist that accepts one of our custom exception codes and looks in the context item with a specific key. If the item doesn’t exist it returns false.

if (this.DoesExceptionExist("COUNTRY_CODE_NOT_FOUND")==false)
{ …

When invoking an action that has dependencies developers can therefore add an ArrayList populated with exceptions (also provided by the base class) to the context before submitting the request.

We added this capability because one of our actions needed to determine whether the COUNTRY_CODE_NOT_FOUND exception was previously thrown. So when action A invokes action B it does the following:

// Added to context so exceptions can be searched
daContext.Add("Exceptions",this.Exceptions);
da.Submit(daContext);

EDAF and our base class handle the rest.

0 Comments:

Post a Comment

<< Home