Hi Gert, Thx for your feedback. Good idea. I will try to use the header as a holder of the validation result.
Perhaps this is a stupid question but Is there any size limitation of the header regarding to the body object ? Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer ***************************** blog : http://cmoulliard.blogspot.com On Mon, Jun 15, 2009 at 11:17 AM, Gert Vanthienen <[email protected] > wrote: > Charles, > > There currently is no built-in way to preserve state. We could > probably add that to Camel, using the exchange id as the correlation > identifier to figure out which data belongs to which Exchange. > However, wouldn't it be easier to put the validation result in a > header? That way, the validation result could travel along with the > business object, but rather as metadata about the business object > instead of replacing it in the message body. > > Regards, > > Gert Vanthienen > ------------------------ > Open Source SOA: http://fusesource.com > Blog: http://gertvanthienen.blogspot.com/ > > > > 2009/6/15 Charles Moulliard <[email protected]>: > > Hi, > > > > I' m confronted to the following "dilemma". The architecture of a product > > that I currently design uses Apache Camel 2.0 and Spring DSL. I have > decided > > to use Spring DSL because I would benefit of the fact that routing can be > > modified in the XML file. Nevertheless, I' m confronted to the following > > issue who could be solved in different ways. > > > > This is why I ask point of view of Camel designer to have your advices ! > > > > The routing calls different services to parse/validate/transform and save > > content of messages. These services have been designed as interface and > > classes implementing the interface. Spring is used to publish the > services > > top of OSGI server (Apache Karaf). Here is the description of the routing > : > > > > <camel:route> > > <!-- Create request message --> > > <camel:from ref="directRequestMessageEndpoint" /> // direct > > endpoint > > > > <!-- Split the collection of messages --> > > <camel:split> > > <camel:ognl>request.body</camel:ognl> > > > > <!-- (1) Call the service to create the request message > > object based on the content received --> > > <camel:bean ref="serviceHelper" > > method="createRequestMessage"/> // Receive as input parameter : > Map<String, > > Object> and return a RequestMessage object > > > > <!-- (2) Validate the business message --> > > <camel:bean ref="serviceHelper" > > method="validateRequestMessage"/> // Receive as input parameter : > > RequestMessage and return a ValidationResultHolder containing List of > > Errors/ boolean isValid > > > > <camel:choice> > > <camel:when> > > <camel:ognl>request.isValid = true</camel:ognl> > > > > <!-- (3) Save business message --> // Receive as > > input parameter : RequestMessage and does not return anything ?????? > > <camel:bean ref="serviceHelper" > > method="saveRequestMessage"/> > > <camel:to ref="queueRequestMessageEndpoint" /> > > </camel:when> > > <camel:when> > > <camel:ognl>request.isValid = false</camel:ognl> > > <!-- (4) Error reported --> > > <camel:bean ref="serviceHelper" > > method="saveErrors"/> > > <camel:to ref="queueReportingEndpoint" /> > > > > </camel:when> > > </camel:choice> > > </camel:split> > > </camel:route> > > > > ISSUE : After calling the bean process : (2) Validate the business > message, > > my RequestMessage is lost and replaced by a ValidationResultHolder > > containing information about List of Errors, boolean isValid BUT the > > requestMessage object is required in the process (3) Save business > message > > > > Scenario possible to solve the issue : > > > > 1) Encapsulate RequestMessage class in the ValidationResultHolder class > and > > use the ValidationResultHolder class as input parameter for (3) save > > business message process. Is it a good idea to copy objects between > classes > > 2) Add property in the RequestMessage class to extract from > > ValidationResultHolder class : List of Errors/ boolean isValid(). Is the > > purpose of a java bean model class to expose result from a validation > > service ? > > 3) Merge service 1), 2) 3) into one. Granularity/flexility of Camel is > lost > > 4) Use Java DSL instead of Spring DSL. Routing is hardcoded > > > > Question : Is a session context available to keep my requestMessage > object > > during the validation process ? > > > > Regards, > > > > Charles Moulliard > > Senior Enterprise Architect > > Apache Camel Committer > > > > ***************************** > > blog : http://cmoulliard.blogspot.com > > >
