Sunday 2 March 2014

CXF Asynchronous Features Overview

Introduction
Asynchronous communication is very important to achieve services scalability. It also plays essential role in use cases, when service responses with certain delay.
In this post I tried to classify and summarize the different aspects of asynchronous communication for WS- stack providing in Apache CXF and illustrate them with examples.

Asynchronous Levels
Architecturally I would separate two different levels of asynchronous communication: 
  1. API  level
  2. Transport level
API level
API level provides a possibility to implement client or service code in non-blocking manner. Normally this can be achieved by using:
  • Pooling approach based on java Future 
  • Pushing approach using callbacks
Non-blocking API does not automatically mean that physical communication is asynchronous: transport can still consume a separate thread and communicate synchronously even if user code is based on non-blocking API.

Transport level 
There are following alternatives for transport level of asynchronous communication:
  • Native asynchronous transports (JMS, SMTP): provide decoupled communication from nature. Response can be sent completely independent on request.
  • Simulation of decoupled communication using synchronous transports (HTTP decoupled response): simulates natively asynchronous transports using separate communication channels for request and response.
  • Asynchronous thread model in synchronous transports (continuations and non-blocking IO model): provides a possibility to reuse threads for multiple communications in synchronous transports
I try to summarize these asynchronous options and aspects supported by CXF in following table:
Client Server
API WSDL asynchronious binding, Dispatch.invokeAsync() @UseMethodAsync annotation
Transport [async] JMS JMS
Transport [simulation sync] WSA decoupled responses, independent oneways WSA decoupled responses, independent oneways
Transport [async thread model] HttpAsyncClient (NIO) Servlet 3 API, Jetty Continuations

Next posts will describe each of these CXF features.

No comments:

Post a Comment