Trouble with camel splitter

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble with camel splitter

avermout
I'm using camel 1.4 in Servicemix. I want to make something like that. I want to split an XML, and to send the parts to different targets following an xpath, and also set properties. All seems to be OK, except I don't the splitSize property in any of my targets (TARGET1, TARGET2). I don't see the property neither on the message (all inOnly messages), nor on the exchange.

from(JBI1).splitter(xpath).to(JBI2);
from(JBI2).choice()
                        .when(xpath1).setHeader(PROPERTY,"25")
                                .to(TARGET1)
                        .when(xpath2).setHeader(PROPERTY, "40")
                                .to(TARGET2)
                        .otherwise().end();

Does anyone see what I'm doing wrong?

Thanks


Reply | Threaded
Open this post in threaded view
|

Re: Trouble with camel splitter

Claus Ibsen-2
Hi

Looks good to me
- Can you see the other header that is added: splitCounter?
- What is the body type?, because Camel invokes size() on the type

You can enable the tracer for trace logs:
http://activemq.apache.org/camel/tracer.html



On Wed, Jan 14, 2009 at 12:16 AM, avermout <[hidden email]> wrote:

>
> I'm using camel 1.4 in Servicemix. I want to make something like that. I want
> to split an XML, and to send the parts to different targets following an
> xpath, and also set properties. All seems to be OK, except I don't the
> splitSize property in any of my targets (TARGET1, TARGET2). I don't see the
> property neither on the message (all inOnly messages), nor on the exchange.
>
> from(JBI1).splitter(xpath).to(JBI2);
> from(JBI2).choice()
>                        .when(xpath1).setHeader(PROPERTY,"25")
>                                .to(TARGET1)
>                        .when(xpath2).setHeader(PROPERTY, "40")
>                                .to(TARGET2)
>                        .otherwise().end();
>
> Does anyone see what I'm doing wrong?
>
> Thanks
>
>
>
> --
> View this message in context: http://www.nabble.com/Trouble-with-camel-splitter-tp21446708s22882p21446708.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with camel splitter

avermout
Hello,

Thanks for your help.
Th bodyType is DOMSource, and neither splitSize or splitCounter are propagated to my target. What is looking strange is that I don't see any splitSize in the traces generated by the TraceFormatter, but well in the logs from the instrumentationProcessor. For example,
Recording duration: 66.817641 millis for exchange: Exchange[JbiMessage: org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@770494{properties: {org.apache.camel.splitSize=2, ....., org.apache.camel.splitCounter=0}}

My message seems to be splitted in the right way, but splitSize is not well propagated.

Thanks,
Aymeric

Claus Ibsen-2 wrote
- Can you see the other header that is added: splitCounter?
- What is the body type?, because Camel invokes size() on the type
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with camel splitter

Claus Ibsen-2
Hi

Ah so the JBI2 loses these headers?

I guess they are not propogated as they are kinda internal since they
are prefixed with org.apache.camel

As a workaround you can use a processor or the likes to copy these
headers into your own header name so they wont be filtered.

rom(JBI1).splitter(xpath).process(new Processor() ....
  // java code here where you copy to your own headers
);to(JBI2);


On Wed, Jan 14, 2009 at 11:38 AM, avermout <[hidden email]> wrote:

>
> Hello,
>
> Thanks for your help.
> Th bodyType is DOMSource, and neither splitSize or splitCounter are
> propagated to my target. What is looking strange is that I don't see any
> splitSize in the traces generated by the TraceFormatter, but well in the
> logs from the instrumentationProcessor. For example,
> Recording duration: 66.817641 millis for exchange: Exchange[JbiMessage:
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@770494{properties:
> {org.apache.camel.splitSize=2, ....., org.apache.camel.splitCounter=0}}
>
> My message seems to be splitted in the right way, but splitSize is not well
> propagated.
>
> Thanks,
> Aymeric
>
>
> Claus Ibsen-2 wrote:
>>
>> - Can you see the other header that is added: splitCounter?
>> - What is the body type?, because Camel invokes size() on the type
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Trouble-with-camel-splitter-tp21446708s22882p21453485.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with camel splitter

jstrachan
Agreed - I wonder if you temporarily switched from using a JBI
endpoint to using a seda:foo endpoint - does that fix it?

2009/1/14 Claus Ibsen <[hidden email]>:

> Hi
>
> Ah so the JBI2 loses these headers?
>
> I guess they are not propogated as they are kinda internal since they
> are prefixed with org.apache.camel
>
> As a workaround you can use a processor or the likes to copy these
> headers into your own header name so they wont be filtered.
>
> rom(JBI1).splitter(xpath).process(new Processor() ....
>  // java code here where you copy to your own headers
> );to(JBI2);
>
>
> On Wed, Jan 14, 2009 at 11:38 AM, avermout <[hidden email]> wrote:
>>
>> Hello,
>>
>> Thanks for your help.
>> Th bodyType is DOMSource, and neither splitSize or splitCounter are
>> propagated to my target. What is looking strange is that I don't see any
>> splitSize in the traces generated by the TraceFormatter, but well in the
>> logs from the instrumentationProcessor. For example,
>> Recording duration: 66.817641 millis for exchange: Exchange[JbiMessage:
>> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@770494{properties:
>> {org.apache.camel.splitSize=2, ....., org.apache.camel.splitCounter=0}}
>>
>> My message seems to be splitted in the right way, but splitSize is not well
>> propagated.
>>
>> Thanks,
>> Aymeric
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> - Can you see the other header that is added: splitCounter?
>>> - What is the body type?, because Camel invokes size() on the type
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/Trouble-with-camel-splitter-tp21446708s22882p21453485.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with camel splitter

avermout
In reply to this post by Claus Ibsen-2
Your workaround works. Thanks.  However, I face a new problem now, if I use 2 splitters in the same JBI.
The first one puts the splitSize in a property let's say 'splitSize'.
The second one, represented by the simple following route, uses the same implementation, so I expect it to overwrite 'splitSize' with the new one:

from(direct:A).splitter(xpath).process(new SplitterProcessor( //puts the splitSize in 'splitSize' )).
                        to(direct:B);

But it is not the case. It seems that the previous value is kept. How could it be explained?

Thanks,
Aymeric

Reply | Threaded
Open this post in threaded view
|

Re: Trouble with camel splitter

Claus Ibsen-2
Hi

We use Maps for properties. And the put method should replace existing values.

Can you reproduce the issue in pure Camel?
Can you show the entire route?



On Wed, Jan 14, 2009 at 4:06 PM, avermout <[hidden email]> wrote:

>
> Your workaround works. Thanks.  However, I face a new problem now, if I use 2
> splitters in the same JBI.
> The first one puts the splitSize in a property let's say 'splitSize'.
> The second one, represented by the simple following route, uses the same
> implementation, so I expect it to overwrite 'splitSize' with the new one:
>
> from(direct:A).splitter(xpath).process(new SplitterProcessor( //puts the
> splitSize in 'splitSize' )).
>                        to(direct:B);
>
> But it is not the case. It seems that the previous value is kept. How could
> it be explained?
>
> Thanks,
> Aymeric
>
>
> --
> View this message in context: http://www.nabble.com/Trouble-with-camel-splitter-tp21446708s22882p21457564.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/