[aerogear-dev] AeroGear WebPush Java Client

Idel Pivnitskiy idel.pivnitskiy at gmail.com
Wed Aug 19 00:30:19 EDT 2015


Hi all!

I've just implemented a lightweight java client for receiving push messages
from AeroGear WebPush Server [1]. It is easy to use and fully async!

A few words about decision to use Jetty as a HTTP/2 client:

Currently there are only 3 Java libraries, which implement client side of
HTTP/2 protocol [2]: Netty, Jetty and OkHttp. I tried all of them:

   - First of all I tried to use OkHttp. This is a lightweight http client
   for Android and other Java apps. But currently this library supports HTTP/2
   protocol only via old HTTP/1.1 API. It works well for simple
   request-response, but its client API does not allow to use HTTP/2 features,
   like Server Push Frames. I looked at GRPC [3], because Googlers use OkHttp
   for HTTP/2 transport. But they don't use public API, they use only inner
   classes to handle frames and built their own logic atop this classes. It
   would be too complicated for our purposes.
   - Secondary, I tried to refactor our WebPush console to a client
   library. But this way is complicated too. netty-codec-http2 does not
   provide a client API, it is only codec, low level protocol implementation.
   - Now I use jetty-http2-client. It is easy to configure and use, fast
   and async. Jetty provides a user friendly API to handle HTTP/2 streams and
   get PUSH_PROMISE frames.

For more information, look at my commit history.
In the future, if there will be more lightweight alternatives than Jetty
(for example, new version of OkHttp or Java 9 API), I will rewrite the
transport layer of my library.

Here is an example, how to use my library [4].

[1] https://github.com/idelpivnitskiy/aerogear-webpush-java-client
[2] https://github.com/http2/http2-spec/wiki/Implementations
[3] https://github.com/grpc/grpc-java/tree/master/okhttp
[4]
https://github.com/idelpivnitskiy/aerogear-webpush-java-client/blob/master/src/example/java/org/jboss/aerogear/webpush/Example.java

Best regards,
Idel Pivnitskiy
-- 
E-mail: Idel.Pivnitskiy at gmail.com
Twitter: @idelpivnitskiy <https://twitter.com/idelpivnitskiy>
GitHub: @idelpivnitskiy <https://github.com/idelpivnitskiy>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20150819/50b47f57/attachment.html 


More information about the aerogear-dev mailing list