camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Ravindra.Godb...@cognizant.com>
Subject RE: TokenizeXML by value from message header
Date Wed, 30 Jul 2014 02:45:36 GMT
As of now tokenizer does not evaluate properties/expression, so you have to pass string value.

I am curious to know if one can refer/access current exchange object while defining the route.
If that is possible then something like this will work in your case.

from("direct:start").split().tokenize(header("tokenheader").evaluate(exchange, type) ,2)......

-Ravi


________________________________________
From: Costash [costache_v_vlad@yahoo.com]
Sent: Tuesday, July 29, 2014 7:07 PM
To: users@camel.apache.org
Subject: TokenizeXML by value from message header

Hi,

I'm trying to tokenize (by grouping) a body of a message based on a values
from message header. The value from message header differs from one message
to another. But it is not working.
Is this not supported by camel? or should be done in a specific way?

I've tried different ways. ( int groupSize = 10 )

Case1:
.split().tokenizeXML("${headers.myTagHeader}" , groupSize)

Result:  Illegal repetition near index 13
<(.{1,15}?:|)${headers.myTagHeader}(\s+.*?|)>




Case2:
.process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                        exchange.setProperty("myTagHeaderInExchange",
exchange.getIn().getHeader("myTagHeader"));
                }
        })
.split().tokenizeXML(header("myTagHeaderInExchange").toString() , groupSize)

Result:  Illegal repetition near index 18
<(.{1,15}?:|)header{myTagHeaderInExchange}(\s+.*?|)>



Case3:
.setHeader("myTagHeaderInExchange", simple("${headers.myTagHeader}"))
.split().tokenizeXML(header("myTagHeaderInExchange").toString() , groupSize)

Result:  Illegal repetition near index 18
<(.{1,15}?:|)header{myTagHeaderInExchange}(\s+.*?|)>



Case4:

public static String myTagHeaderInExchange = "dummy";

.process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                        EslRouteBuilder.myTagHeaderInExchange    = (String)
exchange.getIn().getHeader("myTagHeader");
                }
        })
.split().tokenizeXML(myTagHeaderInExchange , groupSize)

Result: tokenize by "dummy" instead of value of "myTagHeader" header. Witch
is normal as Anonymous class.
But if instead of  the anonymous processor i call an existing processor
class with same code. Still processing after "dummy".


Thanks in advance,
Vlad




--
View this message in context: http://camel.465427.n5.nabble.com/TokenizeXML-by-value-from-message-header-tp5754589.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s)
and may contain confidential and privileged information. If you are not the intended recipient(s),
please reply to the sender and destroy all copies of the original message. Any unauthorized
review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or
any action taken in reliance on the contents of this e-mail is strictly prohibited and may
be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications
sent to and from Cognizant e-mail addresses may be monitored.

Mime
View raw message