On Wednesday 27 October 2010 5:40:25 am Djoser wrote:
> Hello,
> 
> I have developed a standalone web service with CXF and it's currently
> running in production. When there are lots of requests simultaneously, the
> response time of the service is sometimes too long (it rarely happens
> though). So I'm trying to create a pool of 10 instances. The problem is
> that although I specify a maximum value of 10 instances in the
> org.apache.cxf.service.invoker.PooledFactory constructor, the service
> creates an instance for each request, regardless of the maximum value. If
> 20 requests arrive at the same time, 20 instances are created. I
> absolutely need to limit the number of instances. Is there something wrong
> in my code ?
> 
> Factory factory = new PerRequestFactory(XpcmsResponder.class);
> factory = new PooledFactory(factory, 10, false);
> JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory);
> JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
> factoryBean.setAddress(XPCMS_RESPONDER_ADDRESS);
> factoryBean.setServiceClass(XpcmsResponder.class);
> factoryBean.setInvoker(invoker);
> factoryBean.create();

That looks correct.    Hmm...   You could create the 10 up front.   There is a 
PooledFactory constructor that takes a collection of objects and just uses 
them.   In that case, it wouldn't have the .class at all, not factory, etc.. 
and thus couldn't create anymore.  Can you try that?

If that doesn't work, then it's likely that the invoker you are passing in 
isn't being used at all.  That would require some extra debugging to figure 
out why.

-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog

Reply via email to