On Tuesday 27 January 2009 1:20:25 am Gox wrote:
> I use CXF 2.1.3 version. I had same problem with some older versions.

Shoot.   Just checked and sure enough, the default executor it is picking up 
is a Syncronous executor and not the workqueue.  :-(      I'll get this fixed 
for 2.1.4.

In any case, the workaround would be create your own threadpool executor and 
set that on the dispatch object.   That should work fine.

Dan


>
> dkulp wrote:
> > Can I ask what version of CXF?   I think one of the older versions of CXF
> > sufferred from something similar to this.    I think the newer versions
> > work
> > better by forking a thread for the invoke, which is still not idea.
> > This
> > area does need a bit more work.   There is a jira open for it:
> > https://issues.apache.org/jira/browse/CXF-1907
> > just haven't had any time to really dig into it.
> >
> >
> > Dan
> >
> > On Monday 26 January 2009 7:26:51 am Gox wrote:
> >> Hi
> >>
> >> I tried to invoke implementation of Provider web service asynchronously
> >> using invokeAsync methods of Dispatch but booth asynchronous methods
> >> blocks
> >> until response is received. i.e. invokeAsync work same as invoke method.
> >>
> >> Any help?
> >>
> >>
> >> This is client code
> >>
> >>
> >>
> >>
> >> Service service = Service.create(wsdlLocation, serviceName);
> >>
> >> Dispatch dispatch = service.createDispatch(portName, DOMSource.class,
> >> Service.Mode.PAYLOAD);
> >>
> >> Document doc = buildHelloRequest();
> >>
> >> System.out.println("Request sent to WS");
> >> Response response = dispatch.invokeAsync(new DOMSource(doc));
> >> System.out.println("Going to wait for response...");
> >>
> >> while(!response.isDone()) {
> >>    System.out.println("Response not received yet, go to sleep 1000ms");
> >>    Thread.sleep(1000);
> >> }
> >>
> >> System.out.println("Response received");
> >>
> >> Transformer transformer =
> >> TransformerFactory.newInstance().newTransformer();
> >> transformer.setOutputProperty(OutputKeys.INDENT, "yes");
> >> StreamResult result = new StreamResult(System.out);
> >> transformer.transform(response.get(), result);
> >>
> >>
> >>
> >>
> >> This is server code
> >>
> >>
> >>
> >>
> >> @WebServiceProvider(portName = "HelloMessagePort",
> >>                                    serviceName = "HelloMessageService",
> >>                                    
> >> targetNamespace="http://mycompany.com/ws/async/message";)
> >> @ServiceMode(value = Service.Mode.PAYLOAD)
> >> public class HelloMessageProvider implements Provider {
> >>
> >>    public DOMSource invoke(DOMSource request) {
> >>            DOMSource response = null;
> >>            try {
> >>
> >>                    Thread.sleep(3000);
> >>
> >>            Document doc = buildHelloResponse(request);
> >>            transformer.transform(new DOMSource(doc), result);
> >>
> >>            response = new DOMSource(doc);
> >>
> >>            } catch (Exception e) {
> >>                    e.printStackTrace();
> >>            }
> >>
> >>            return response;
> >>    }
> >> }
> >
> > --
> > Daniel Kulp
> > [email protected]
> > http://dankulp.com/blog



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

Reply via email to