camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Route with content split and backup
Date Wed, 07 Oct 2009 16:17:23 GMT
On Mon, Oct 5, 2009 at 6:19 PM, S. Ali Tokmen <savas-ali.tokmen@bull.net> wrote:
> Hello
>
> Thank you for this brilliant example.
>
> In my use case, I've used the Expression for only creating a recipient list,
> each of them with direct: destinations, and then some other routes starting
> from these direct: endpoints.
>
> It works well and the routes are easy to read.

Glad it worked for you and the routes are easy to read and understand.
That is very important IMHO that new users can understand the camel
routing.
You can misuse the Camel DSL and create long and complex routes just
as long and complex methods.

So dividing into smaller routes and linking using direct endpoint is
great. Just as you would refactor a method into smaller methods.


>
> Cheers
>
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
>
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
>
> Bull, Architect of an Open World TM
> http://www.bull.com
>
>
>
> Claus Ibsen a écrit :
>>
>> Hi
>>
>> And notice I use org.apache.camel.Message objects as container for the
>> answer to return in the custom Expression.
>> I do this as I can then add the custom header with the destination for
>> the recipient list EIP.
>>
>> If I do not do that then I may have to use the Content Based Router
>> afterwards and check the content where to route the message.
>>
>>
>> On Mon, Oct 5, 2009 at 10:30 AM, Claus Ibsen <claus.ibsen@gmail.com>
>> wrote:
>>
>>>
>>> Hi
>>>
>>> You can use a custom expression to do the splitting and combined with
>>> the recipient list you can in your custom expression also determine
>>> where to message should be routed next.
>>>
>>> See this unit test I added
>>> http://svn.apache.org/viewvc?rev=821717&view=rev
>>>
>>>
>>>
>>> On Mon, Oct 5, 2009 at 9:56 AM, S. Ali Tokmen <savas-ali.tokmen@bull.net>
>>> wrote:
>>>
>>>>
>>>> Hello
>>>>
>>>> I'm trying to create a route which does the following:
>>>>
>>>>  * Reads a file from the /input path, containing Java-property-like
>>>>    entries. Let's assume it for example contains:
>>>>        o p1 = x
>>>>        o p2 = y
>>>>        o p3 = z
>>>>        o p4 = t
>>>>  * Splits the file into two files and puts it into /output_2 and
>>>>    /output_3
>>>>        o /output_2 should only receive the properties p1 and p2, e.g.:
>>>>              + p1 = x
>>>>              + p2 = y
>>>>        o /output_3 should only receive the properties p1 and p3, e.g.:
>>>>              + p1 = x
>>>>              + p3 = z
>>>>  * Once the writing of these files finished, move the original file
>>>>    in /input into /backup
>>>>
>>>> I'm attaching some images for illustrating this.
>>>>
>>>> Now, here's the issue: when I do a route like the following:
>>>>
>>>>  from("file:/input").
>>>>  to("direct:output_2", "direct:output_3").
>>>>  to("file:/backup");
>>>>
>>>>  from("direct:output_2").process(OnlyKeepPropertyProcessor("p1",
>>>>  "p2").to("file:/output_2");
>>>>  from("direct:output_3").process(OnlyKeepPropertyProcessor("p1",
>>>>  "p3").to("file:/output_3");
>>>>
>>>> Then only p1 and p2 is passed to the process3, and the file in /output_3
>>>> contains only p1. Worse, the backup only backs up what's in output_3...
>>>>
>>>> What is the good EIP for such a route?
>>>>
>>>> Thanks
>>>>
>>>> --
>>>>
>>>> S. Ali Tokmen
>>>> savas-ali.tokmen@bull.net
>>>>
>>>> Office: +33 4 76 29 76 19
>>>> GSM:    +33 66 43 00 555
>>>>
>>>> Bull, Architect of an Open World TM
>>>> http://www.bull.com
>>>>
>>>>
>>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message