Skip to content

A wrapper around the Apache HTTP components async client to read server sent events

License

Notifications You must be signed in to change notification settings

preet-dev/apache-sseclient

Repository files navigation

apache-sseclient

Java CI with Gradle Sonar Coverage GitHub last commit GitHub all releases

GitHub code size in bytes GitHub GitHub Repo stars

This is a wrapper around the Apache HTTP components async client to send Server-Sent Events.

Usage

implementation 'dev.manpreet:apache-sseclient:1.0'

Create an instance of the async client & start it

CloseableHttpAsyncClient asyncClient = HttpAsyncClients.createDefault();
asyncClient.start();

Create the request.

SseRequest request = new SseRequest(YOUR_REQUEST_URI);

Create the SSE client instance and provide ExecutorService instance to run the requests in a new thread.

ApacheHttpSseClient sseClient = new ApacheHttpSseClient(asyncClient, Executors.newFixedThreadPool(CONCURRENT_SSE_STREAMS));

Execute the request and get the Future response instance.

Future<SseResponse> sseResponse = sseClient.execute(request);

Authors

Created by @ytoh & @manpreet333 when in the middle of a project we realized Apache client doesn't have this functionality.