Sunday, March 6, 2011

Business delegation of message translation in Apache Camel

In previous posts I wrote about separating business rules from message transformation in middleware systems. I also explained why changes affecting business rules involved in message transformation suck.

To make my further considerations more concrete let's discuss possible model of delegation of business rules based on Apache Camel.
Apache Camel project provides org.apache.camel.Processor interface which can be implemented in order to provide message consumer or translator functionality. What we want to design is the implementation of the Camel Processor which delegates business transformations to the specialized interface responsible for message translation.

Interface specialized in business message transformation is named BusinessTransformation. Its responsibility is to transform single business fact. Transformed fact cannot be a null value. Business fact returned by the transformation can be a different instance than one passed to the BusinessTransformation object. Transformation can return null value, which indicates that input fact has been consumed and processing of the message is finished.

Class named BusinessTransformer aggregates instance of BusinessTransformation and implements Camel’s org.apache.camel.Processor interface. It delegates transformation of the message to the external business component represented by the BusinessTransformation instance. BusinessTrasformer should be immutable and doesn’t change over its lifetime.

In next posts I'll show concrete use case in which BusinessTransformer can be used. And provide some cool Recycled-based implementation of the problem.

No comments:

Post a Comment