Suggestion 2 works... However if i have single object (singleton) and do the
bidning later on before acutally using the object to make the api call,
wouldn't that be a problem when running it in a multi threaded application
as the binding might be mixed up between threads? Would you be able ti
suggest any better way to handle it
dkulp wrote:
>
>
>
> It really should have no impact. The default if you don't set it is to
> call
> BusFactory.getDefaultBus() anyway.
>
> My suggestion would be one of:
> 1) Keep one of your BasicReportService objects around. If you keep it
> around, the JAXBContext and such can be cached so it doesn't need to be
> recreated. That's part of the slowdown.
>
> 2) Just use a single BasicReportService object. Don't create a new one
> each
> time. Call:
> ((BindingProvider)ret).getRequestContext().put(
> "thread.local.request.context", Boolean.TRUE);
> and it will flip it to ThreadLocal storage for the request context which
> allows it to be mostly threadsafe (unless you turn on session support).
> Set
> the URL as needed via
> ((BindingProvider)ret).getRequestContext().put(
> BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> aServiceURL);
>
>
> Dan
>
>
>
>
> On Monday 08 December 2008 3:54:04 pm nmt999 wrote:
>> Below is the code i use for creating service. Would it impact the memory
>> or
>> performance if I use or do not use the setBus line that is commented.
>> This
>> cxf client seems to take more time to run than the existing axis client
>> and
>> also seems to use high cpu. not sure if i'm doing anything wrong. Also
>> these services get created for each account that the service is used for
>> as
>> the service url differs from account to account
>>
>>
>> public BasicReportService createService(String aServiceURL)
>> {
>> BasicReportService ret = null;
>>
>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>> factory.getInInterceptors().add(new LoggingInInterceptor());
>> factory.getOutInterceptors().add(new LoggingOutInterceptor());
>> factory.setServiceClass(BasicReportService.class);
>> factory.setAddress(aServiceURL);
>> // factory.setBus(BusFactory.getDefaultBus());
>>
>> ret = (BasicReportService) factory.create();
>>
>> Client client = ClientProxy.getClient(ret);
>> HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
>>
>> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>>
>> httpClientPolicy.setConnectionTimeout(theService.DEFAULT_API_CONNECT_TIMEOU
>>T);
>>
>> httpClientPolicy.setReceiveTimeout(theService.DEFAULT_API_READ_TIMEOUT);
>> httpClientPolicy.setAllowChunking(false);
>>
>> httpConduit.setClient(httpClientPolicy);
>>
>> Debug.msg(Debug.INFORMATION, "BasicReportService created");
>> return ret;
>> }
>
>
>
> --
> Daniel Kulp
> [email protected]
> http://dankulp.com/blog
>
>
--
View this message in context:
http://www.nabble.com/service-creation---busfactory-going-to-impact-performance--tp20903304p20962125.html
Sent from the cxf-user mailing list archive at Nabble.com.