You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Xavier Coulon <xc...@gmail.com> on 2011/02/08 18:45:59 UTC

Problems with multiple threads on FlatPack component

Hello,

I'm trying to consume messages from a seda component with multiple threads.
Those String-based messages are lines coming from a flat file that I want to
parse with the FlatPack component/marshaller. [Later on, those Java
Map-based messages will be converted into Entities and persisted with the
Camel JPA Component, and keeping the multithreaded approach should improve
performance of the overhaul file processing]

On a mono-thread usage, every thing works fine, but when I set a number of
threads (greater than 1) in my route (as in the DSL below):

from("seda:dataintegration.filtered.elements")
	.threads(1, 10)	
	.unmarshal(df)
	.convertBodyTo(PointOfInterest.class)
	.to("seda:dataintegration.unmarshalled.elements");
 
... things start going bad (see the stacktraces below). 

Failed delivery for exchangeId: 2d044b8f-0658-43af-897b-05c7ac557b81.
Exhausted after delivery attempt: 1 caught:
org.apache.camel.InvalidPayloadException: No body available of type:
x.y.z.PointOfInterest but has value: [{...}] of type:
org.apache.camel.component.flatpack.DataSetList on: Message: [{...}].
Exchange[Message: [{...}]]
org.apache.camel.InvalidPayloadException: No body available of type: 
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type:
org.apache.camel.component.flatpack.DataSetList to the required type:
x.y.z.PointOfInterest with value [{...}]]
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:103)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	at
org.apache.camel.processor.ConvertBodyProcessor.process(ConvertBodyProcessor.java:57)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	...
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[na:1.6.0_12]
	at java.lang.Thread.run(Thread.java:619) [na:1.6.0_12]
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type:
org.apache.camel.component.flatpack.DataSetList to the required type:
x.y.z.PointOfInterest with value [{...}]
	at
org.apache.camel.impl.converter.DefaultTypeConverter.mandatoryConvertTo(DefaultTypeConverter.java:128)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	... 32 common frames omitted
Caused by: org.apache.camel.RuntimeCamelException:
java.lang.NumberFormatException: multiple points
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:823)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	at
org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:50)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	at
org.apache.camel.impl.converter.DefaultTypeConverter.doConvertTo(DefaultTypeConverter.java:171)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	at
org.apache.camel.impl.converter.DefaultTypeConverter.mandatoryConvertTo(DefaultTypeConverter.java:126)
~[camel-core-2.4.0-fuse-02-00.jar:2.4.0-fuse-02-00]
	... 33 common frames omitted
Caused by: java.lang.NumberFormatException: multiple points
	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1084)
~[na:1.6.0_12]
	at java.lang.Double.parseDouble(Double.java:510) ~[na:1.6.0_12]
	at java.text.DigitList.getDouble(DigitList.java:151) ~[na:1.6.0_12]
	at java.text.DecimalFormat.parse(DecimalFormat.java:1303) ~[na:1.6.0_12]
	at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1936)
~[na:1.6.0_12]
	at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1312)
~[na:1.6.0_12]
	at java.text.DateFormat.parse(DateFormat.java:335) ~[na:1.6.0_12]

Is the FlatPack component thread-safe ? 


Thank you in advance
Best regards,

Xavier
	
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problems-with-multiple-threads-on-FlatPack-component-tp3376267p3376267.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problems with multiple threads on FlatPack component

Posted by Xavier Coulon <xc...@gmail.com>.
No, no, that was my convertBodyTo() statement that uses a custom
TypeConverter which itself used the SimpleDateFormat class, which is not
threadsafe... All my fault. I replaced it with JodaTime and it works fine
now.

Xavier

On Wed, Feb 9, 2011 at 12:20 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Tue, Feb 8, 2011 at 8:51 PM, Xavier Coulon <xc...@gmail.com> wrote:
> > Damn', I should have seen it.
> > Thank you, Richard.
> >
>
> Maybe report an issue at the flatpack project.
>
>
> > Regards,
> > Xavier
> >
> > On Tue, Feb 8, 2011 at 7:56 PM, Richard Kettelerij <
> > richardkettelerij@gmail.com> wrote:
> >
> >>
> >> As you can see from the stacktrace a SimpleDateFormat is used under the
> >> hood.
> >> SimpleDateFormat isn't thread safe.
> >> --
> >> View this message in context:
> >>
> http://camel.465427.n5.nabble.com/Problems-with-multiple-threads-on-FlatPack-component-tp3376267p3376393.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
> >
> >
> >
> > --
> > Xavier
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>



-- 
Xavier

Re: Problems with multiple threads on FlatPack component

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Feb 8, 2011 at 8:51 PM, Xavier Coulon <xc...@gmail.com> wrote:
> Damn', I should have seen it.
> Thank you, Richard.
>

Maybe report an issue at the flatpack project.


> Regards,
> Xavier
>
> On Tue, Feb 8, 2011 at 7:56 PM, Richard Kettelerij <
> richardkettelerij@gmail.com> wrote:
>
>>
>> As you can see from the stacktrace a SimpleDateFormat is used under the
>> hood.
>> SimpleDateFormat isn't thread safe.
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Problems-with-multiple-threads-on-FlatPack-component-tp3376267p3376393.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Xavier
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Problems with multiple threads on FlatPack component

Posted by Xavier Coulon <xc...@gmail.com>.
Damn', I should have seen it.
Thank you, Richard.

Regards,
Xavier

On Tue, Feb 8, 2011 at 7:56 PM, Richard Kettelerij <
richardkettelerij@gmail.com> wrote:

>
> As you can see from the stacktrace a SimpleDateFormat is used under the
> hood.
> SimpleDateFormat isn't thread safe.
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Problems-with-multiple-threads-on-FlatPack-component-tp3376267p3376393.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Xavier

Re: Problems with multiple threads on FlatPack component

Posted by Richard Kettelerij <ri...@gmail.com>.
As you can see from the stacktrace a SimpleDateFormat is used under the hood.
SimpleDateFormat isn't thread safe.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problems-with-multiple-threads-on-FlatPack-component-tp3376267p3376393.html
Sent from the Camel - Users mailing list archive at Nabble.com.