You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Muhammad Rayhan <sa...@gmail.com> on 2011/04/04 10:24:33 UTC

String processing with Apache Camel with Spring DSL

Hi, this is my first email to this mailing-list. Although already
knowing for some time, I only recently got the opportunity to deploy
integration solution using Apache Camel. And Camel did wonder! I and
my fellow friends were amazed by the concept and simplicity of Apache
Camel

Now, I have another problem to solve using Camel. One of my tasks to
be done is doing string processing / transformation. I need to parse
and extract several information from a text log. The string format
itself is fixed, but string is not in comma separated value. For
example, the text is:

2011-04-04 14:34:05,003  INFO  - cli_to_gw submit_sm_req text ip
:10.2.xxxxx:37xxx to:62xxxxx msg:Congratulations, the product ABC
activation to subscriber DEF is successful. The serial number is XYZ.
from:xxxxx

I want to extract only ABC, DEF and XYZ from the text log. In order to
avoid heavy changes in our production environment, I intend to use
Spring XML DSL to configure my routes. Is it possible to do so? What
functions should I use? I have no problem filtering the log to only
process certain type of log (using 'regex' simple operator), but have
no idea of extract those information using Spring XML.

Thanks in advance :)


-- 
Twitter: @md_ray
Email/IM: saviourcat@gmail.com

Re: String processing with Apache Camel with Spring DSL

Posted by Muhammad Rayhan <sa...@gmail.com>.
Thanks John for the reply

I tend to agree with you on POJO doing the parsing dirty work.
Creating new POJO is actually the thing we want to avoid. Our team
prefer configuring Spring DSL rather than using POJO. On this case
where the parsing will be too complex, however, POJO maybe the
cleanest solution



On Mon, Apr 4, 2011 at 3:35 PM, John McDonald <mc...@gmail.com> wrote:
> If you are using Spring then  I would be looking at a POJO to do this parsing work - routing to it using the beanRef - this would encapsulate your string manipulation and leave camel to perform delivery and routing.  There are predicates and  conditionals you could use in your dsl - but for my taste this wouldn't give me the transparency and simplicity of testing I would like.   My inclination is to use Camel for the heavy lifting and pojos or processors for the fine grained stuff
>
>
>
>
> On 4 Apr 2011, at 09:24, Muhammad Rayhan wrote:
>
>> Hi, this is my first email to this mailing-list. Although already
>> knowing for some time, I only recently got the opportunity to deploy
>> integration solution using Apache Camel. And Camel did wonder! I and
>> my fellow friends were amazed by the concept and simplicity of Apache
>> Camel
>>
>> Now, I have another problem to solve using Camel. One of my tasks to
>> be done is doing string processing / transformation. I need to parse
>> and extract several information from a text log. The string format
>> itself is fixed, but string is not in comma separated value. For
>> example, the text is:
>>
>> 2011-04-04 14:34:05,003  INFO  - cli_to_gw submit_sm_req text ip
>> :10.2.xxxxx:37xxx to:62xxxxx msg:Congratulations, the product ABC
>> activation to subscriber DEF is successful. The serial number is XYZ.
>> from:xxxxx
>>
>> I want to extract only ABC, DEF and XYZ from the text log. In order to
>> avoid heavy changes in our production environment, I intend to use
>> Spring XML DSL to configure my routes. Is it possible to do so? What
>> functions should I use? I have no problem filtering the log to only
>> process certain type of log (using 'regex' simple operator), but have
>> no idea of extract those information using Spring XML.
>>
>> Thanks in advance :)
>>
>>
>> --
>> Twitter: @md_ray
>> Email/IM: saviourcat@gmail.com
>
>



-- 
Sent using Telkomsel network
Twitter: @md_ray
Email/IM: saviourcat@gmail.com and md_ray@yahoo.com

Re: String processing with Apache Camel with Spring DSL

Posted by John McDonald <mc...@gmail.com>.
If you are using Spring then  I would be looking at a POJO to do this parsing work - routing to it using the beanRef - this would encapsulate your string manipulation and leave camel to perform delivery and routing.  There are predicates and  conditionals you could use in your dsl - but for my taste this wouldn't give me the transparency and simplicity of testing I would like.   My inclination is to use Camel for the heavy lifting and pojos or processors for the fine grained stuff




On 4 Apr 2011, at 09:24, Muhammad Rayhan wrote:

> Hi, this is my first email to this mailing-list. Although already
> knowing for some time, I only recently got the opportunity to deploy
> integration solution using Apache Camel. And Camel did wonder! I and
> my fellow friends were amazed by the concept and simplicity of Apache
> Camel
> 
> Now, I have another problem to solve using Camel. One of my tasks to
> be done is doing string processing / transformation. I need to parse
> and extract several information from a text log. The string format
> itself is fixed, but string is not in comma separated value. For
> example, the text is:
> 
> 2011-04-04 14:34:05,003  INFO  - cli_to_gw submit_sm_req text ip
> :10.2.xxxxx:37xxx to:62xxxxx msg:Congratulations, the product ABC
> activation to subscriber DEF is successful. The serial number is XYZ.
> from:xxxxx
> 
> I want to extract only ABC, DEF and XYZ from the text log. In order to
> avoid heavy changes in our production environment, I intend to use
> Spring XML DSL to configure my routes. Is it possible to do so? What
> functions should I use? I have no problem filtering the log to only
> process certain type of log (using 'regex' simple operator), but have
> no idea of extract those information using Spring XML.
> 
> Thanks in advance :)
> 
> 
> -- 
> Twitter: @md_ray
> Email/IM: saviourcat@gmail.com


Re: String processing with Apache Camel with Spring DSL

Posted by Richard Kettelerij <ri...@gmail.com>.
Looking at the example string, I think you need a component that is capable
of parsing fixed-width records. This can be accomplished using either of the
following Camel components:

- camel-bindy (POJO based), http://camel.apache.org/bindy.html
- camel-flatpack (XML based), http://camel.apache.org/flatpack.html

Both camel components can be used with Spring XML, but flatpack also allows
your record definitions to be specified in XML.

If you need advanced data mapping capabilities you should have a look at
Smooks (http://www.smooks.org). It integrates with Camel out-of-the-box.

On Mon, Apr 4, 2011 at 10:24 AM, Muhammad Rayhan <sa...@gmail.com>wrote:

> Hi, this is my first email to this mailing-list. Although already
> knowing for some time, I only recently got the opportunity to deploy
> integration solution using Apache Camel. And Camel did wonder! I and
> my fellow friends were amazed by the concept and simplicity of Apache
> Camel
>
> Now, I have another problem to solve using Camel. One of my tasks to
> be done is doing string processing / transformation. I need to parse
> and extract several information from a text log. The string format
> itself is fixed, but string is not in comma separated value. For
> example, the text is:
>
> 2011-04-04 14:34:05,003  INFO  - cli_to_gw submit_sm_req text ip
> :10.2.xxxxx:37xxx to:62xxxxx msg:Congratulations, the product ABC
> activation to subscriber DEF is successful. The serial number is XYZ.
> from:xxxxx
>
> I want to extract only ABC, DEF and XYZ from the text log. In order to
> avoid heavy changes in our production environment, I intend to use
> Spring XML DSL to configure my routes. Is it possible to do so? What
> functions should I use? I have no problem filtering the log to only
> process certain type of log (using 'regex' simple operator), but have
> no idea of extract those information using Spring XML.
>
> Thanks in advance :)
>
>
> --
> Twitter: @md_ray
> Email/IM: saviourcat@gmail.com
>