users@jaxb.java.net

Re: Is Marshall thread safe?

From: jyoti chhabra <jyoti.chhabra_at_gmail.com>
Date: Thu, 27 Aug 2009 08:16:04 +0530

Thanks!

Stax is not an option, because i need object to load them to database.

So i can make context as a static object. Is there some limit on how
many marshallers could be created. My load is quite large, around 100K
to 500K calls per day. Could be more.

Also is marshaller a costly operation. I did profiling only on cpu
time and for that context creation was costliest operation, marshall
creation was comparative quite low. Did you saw any performance
improvement after using the thread pool for Marshaller and
Un-marshaller objects.

Regards,
Jyoti

On Thu, Aug 27, 2009 at 12:04 AM, Adam Zell<zellster_at_gmail.com> wrote:
> The following URLs may be useful:
>
> https://jaxb.dev.java.net/faq/index.html#threadSafety
> https://jaxb.dev.java.net/guide/Performance_and_thread_safety.html
>
> In my application, I maintain separate pools for marshaller and unmarshaller
> objects.  It is advisable to reset the objects to their default properties
> (e.g. setXXX) before returning them to the pool.
>
> On Wed, Aug 26, 2009 at 7:06 AM, jyoti chhabra <jyoti.chhabra_at_gmail.com>
> wrote:
>>
>> Hey,
>>
>> I am using Jaxb in my application. Currently it's cpu intensive.
>> This is how i use it :
>>            JAXBContext jaxbContext = JAXBContext.newInstance(packageName);
>>            StringWriter xmlStringWriter = new StringWriter();
>>            Marshaller marshaller = jaxbContext.createMarshaller();
>>            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
>> new Boolean(true));
>>            marshaller.marshal(enqueueObj, xmlStringWriter);
>>
>> enqueueObj is input to function and if of type JAXBElement<T>
>>
>> I profile my code and found that creation of jaxbContext is costly
>> compared to other methods.
>> What i was wondering is that could i make jaxbContext as a static
>> variable, assuming there is only 1 kind of packageName.
>> Is the creation of marshaller thread safe? Is there any limit to how
>> many marshaller could i create? Would it spawn a new thread for it?
>> What would be a better way to improve performance. Currently size of
>> my object is from couple of Kbs to Mb. But i do expect it to grow to
>> couple of Mbs.
>>
>> Appreciate any pointers.
>>
>> Regards,
>> Jyoti
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>
>
>
> --
> Adam
> zellster_at_gmail.com
>