Search in sources :

Example 1 with ServerAsyncResponse

use of org.apache.cxf.jaxws.ServerAsyncResponse in project cxf by apache.

the class GreeterImpl method greetMeSometimeAsync.

public Future<?> greetMeSometimeAsync(final String me, final AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
    LOG.info("Executing operation greetMeSometimeAsync asynchronously");
    System.out.println("Executing operation greetMeSometimeAsync asynchronously\n");
    final ServerAsyncResponse<GreetMeSometimeResponse> r = new ServerAsyncResponse<GreetMeSometimeResponse>();
    new Thread() {

        public void run() {
            GreetMeSometimeResponse resp = new GreetMeSometimeResponse();
            resp.setResponseType("How are you " + me);
            r.set(resp);
            System.out.println("Responding on background thread\n");
            asyncHandler.handleResponse(r);
        }
    }.start();
    return r;
}
Also used : ServerAsyncResponse(org.apache.cxf.jaxws.ServerAsyncResponse) GreetMeSometimeResponse(org.apache.hello_world_async_soap_http.types.GreetMeSometimeResponse)

Example 2 with ServerAsyncResponse

use of org.apache.cxf.jaxws.ServerAsyncResponse in project cxf by apache.

the class CatalogServiceImpl method addBookAsync.

public Future<?> addBookAsync(Book book, AsyncHandler<Book> handler) {
    final ServerAsyncResponse<Book> response = new ServerAsyncResponse<Book>();
    executor.submit(() -> {
        final Span span = brave.tracer().nextSpan().name("Inserting New Book").start();
        try (SpanInScope scope = brave.tracer().withSpanInScope(span)) {
            books.put(book.getId(), book);
            handler.handleResponse(response);
        } finally {
            span.finish();
        }
    });
    return response;
}
Also used : Book(demo.jaxws.tracing.server.Book) SpanInScope(brave.Tracer.SpanInScope) ServerAsyncResponse(org.apache.cxf.jaxws.ServerAsyncResponse) Span(brave.Span)

Aggregations

ServerAsyncResponse (org.apache.cxf.jaxws.ServerAsyncResponse)2 Span (brave.Span)1 SpanInScope (brave.Tracer.SpanInScope)1 Book (demo.jaxws.tracing.server.Book)1 GreetMeSometimeResponse (org.apache.hello_world_async_soap_http.types.GreetMeSometimeResponse)1