
WebSocket websocket = c.prepareGet("ws:///echo") You need to pass a WebSocketUpgradeHandler where you would register a WebSocketListener. You may get the complete maven project for this simple demo from WebSocketĪsync Http Client also supports WebSocket. WhenResponse.join() // wait for completion } catch (InterruptedException | ExecutionException e) )

You can configure listeners to be notified of the Future's completion. The point of using a non blocking client is to NOT BLOCK the calling thread! Setting callbacks on the ListenableFutureĮxecute methods actually return a similar to Guava's.
#Java async http client code#
This is useful for debugging but you'll most likely hurt performance or create bugs when running such code on production. Future whenResponse = asyncHttpClient.prepareGet("").execute() You can simply block the calling thread to get the response. Use the addBodyPart method to add a multipart part to the request.ĭealing with Responses Blocking on the FutureĮxecute methods return a. Have a look at FeedableBodyGenerator if you're looking for a way to pass requests chunks on the fly.
#Java async http client free#
Basicsįeel free to check the Javadoc or the code for more information. FIX = no API change, just bug fixes, only those are source and binary compatible with same minor versionĬheck CHANGES.md for migration path between versions.MINOR = new features and minor API changes, upgrading should require 1 hour of work to adapt sources.The async-http-client-extras-* and other modules can also be added without having to specify the version for each dependency, because they are all managed via the BOM. Import the AsyncHttpClient Bill of Materials (BOM) to add dependency management for AsyncHttpClient artifacts to your project: Īdd a dependency on the main AsyncHttpClient artifact: Please add an issue and label it RFC and I'll take a look! Installation Well, not really RFCs, but as I am ramping up to release a new version, I would appreciate the comments from the community. It's currently compiled on Java 8 but runs on Java 9 too.


The library also supports the WebSocket Protocol. The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and asynchronously process HTTP responses.
