You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by simafengyun <yi...@citi.com> on 2014/03/04 11:14:38 UTC

jaxb non-thread safe issue

Hi,

Below case is not thread safe because marshal is not thread safe. Is there
anybody know how to fix it?

Case as below

 *       <endpoint id="toMarshal"
           
uri="seda:toMarshal?multipleConsumers=false&amp;concurrentConsumers=5" />*

      <dataFormats>
            <jaxb id="MarketData" prettyPrint="true"
                contextPath="com.rr.md.tt.entity" encoding="UTF-8"  />
        </dataFormats>

        <camel:route id="marketDataRoute">
            <from ref="marketDataQueue" />
            <to uri="toMarshal" />
       </camel:route>
        <camel:route id="jaxbRoute">
            <from uri="toMarshal" />
            *<marshal ref="MarketData" />*
            <to uri="file:outbox?" />
        </camel:route>

Issue:  the route jaxbRoute get data from seda:toMarshal whose
concurrentConsumers > 1,  then marshal the data to XML by 5 threads. And I
found the some xml file's content in the outbox is not correct because the
marshal is not thread-safe. I tried to config the element marshal's
attribute scope to "prototype". But it doesn't support the scope attribute.
Do you know how to make it thread safe in this case?










--
View this message in context: http://camel.465427.n5.nabble.com/jaxb-non-thread-safe-issue-tp5748274.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: jaxb non-thread safe issue

Posted by Claus Ibsen <cl...@gmail.com>.
Try and test with latest Camel release.


On Wed, Mar 5, 2014 at 7:02 AM, simafengyun <yi...@citi.com> wrote:
> Hi,
>
> Thanks for your quick reponse.
>
> I used camel 2.10.4.
>
> Sorry, I didn't introduce my issue in detail.
>
> Actually, in the route marketDataRoute,  it get message from jms queue, and
> the jms message will be  encapsulated to java object in the jmsProcessor
> them the object will be sent to seda queue.
>
>         <camel:route id="marketDataRoute">
>             <from ref="marketDataQueue" />
>             <to id="ToJmsProcessor" uri="jmsProcessor"/>
>             <to uri="toMarshal" />
>         </camel:route>
>
> in the route jaxbRoute, it just get the java object from seda queue, then
> marshall the data to xml.
>
> these objects  are not shared,  they are independent objects.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/jaxb-non-thread-safe-issue-tp5748274p5748313.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Re: jaxb non-thread safe issue

Posted by simafengyun <yi...@citi.com>.
Hi,

Thanks for your quick reponse.

I used camel 2.10.4.

Sorry, I didn't introduce my issue in detail.

Actually, in the route marketDataRoute,  it get message from jms queue, and
the jms message will be  encapsulated to java object in the jmsProcessor
them the object will be sent to seda queue.

        <camel:route id="marketDataRoute"> 
            <from ref="marketDataQueue" /> 
            <to id="ToJmsProcessor" uri="jmsProcessor"/> 
            <to uri="toMarshal" /> 
        </camel:route> 

in the route jaxbRoute, it just get the java object from seda queue, then
marshall the data to xml.

these objects  are not shared,  they are independent objects.



--
View this message in context: http://camel.465427.n5.nabble.com/jaxb-non-thread-safe-issue-tp5748274p5748313.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: jaxb non-thread safe issue

Posted by Claus Ibsen <cl...@gmail.com>.
What Camel version do you use?

And what data do you send to the seda endpoint? Is it by any chance a
shared object instance? Or are you sure they are totally indepedent
objects?

On Tue, Mar 4, 2014 at 11:14 AM, simafengyun <yi...@citi.com> wrote:
> Hi,
>
> Below case is not thread safe because marshal is not thread safe. Is there
> anybody know how to fix it?
>
> Case as below
>
>  *       <endpoint id="toMarshal"
>
> uri="seda:toMarshal?multipleConsumers=false&amp;concurrentConsumers=5" />*
>
>       <dataFormats>
>             <jaxb id="MarketData" prettyPrint="true"
>                 contextPath="com.rr.md.tt.entity" encoding="UTF-8"  />
>         </dataFormats>
>
>         <camel:route id="marketDataRoute">
>             <from ref="marketDataQueue" />
>             <to uri="toMarshal" />
>        </camel:route>
>         <camel:route id="jaxbRoute">
>             <from uri="toMarshal" />
>             *<marshal ref="MarketData" />*
>             <to uri="file:outbox?" />
>         </camel:route>
>
> Issue:  the route jaxbRoute get data from seda:toMarshal whose
> concurrentConsumers > 1,  then marshal the data to XML by 5 threads. And I
> found the some xml file's content in the outbox is not correct because the
> marshal is not thread-safe. I tried to config the element marshal's
> attribute scope to "prototype". But it doesn't support the scope attribute.
> Do you know how to make it thread safe in this case?
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/jaxb-non-thread-safe-issue-tp5748274.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io