Implementing Reactive Client-Server Communication over TCP or Websockets with RSocket and Java

Reactive design or reactive architecture has an impact on how modern software systems are implemented. RSocket is a project that aims to adapt the benefits of the patterns described in the Reactive Manifesto and resulting tools like Reactive Streams or Reactive Extensions to a formal new communication protocol. RSocket works with TCP, WebSockets and Aeron transport layers and offers additional features like session resumption. In the following tutorial I’m going to demonstrate how to implement simple client-server communication over TCP and Websockets for different interaction models like request-response, request-stream, fire-and-forget and event subscription. ...

November 25, 2018 · 8 min · 1558 words · Micha Kops

Using Deferred Objects and Promises with Java 8 and JDeferred

Promises may help us when dealing with asynchronous code and we need to merge, pipe or track the progress and the results of single parts of computation in our applications. In the following tutorial I’d like to demonstrate a small library, JDeferred that helps us for this specific use case. Figure 1. JDeferred examples running in Eclipse IDE. Dependencies Using Maven here, we simply need to add one dependency for jdeferred-core to our pom.xml: ...

September 27, 2015 · 8 min · 1631 words · Micha Kops

Testing Asynchronous Applications with Java and Awaitility

Writing tests for asynchronous applications has never been much fun as we’re always struggling with the problem how to determine state changes, handle process terminations, dealing with timeouts or failures and stuff like this. Awaitility eases this process for us offering a nice DSL, rich support for languages like Scala or Groovy and an easy-to-use syntax that’s even more fun when using it with Java 8′s lambda expressions. In the following short introduction I’d like to demonstrate writing some tests different scenarios. ...

August 23, 2015 · 6 min · 1143 words · Micha Kops

JAX-RS 2.0 REST Client Features by Example

JAX-RS 2.0 aka JSR 339 not also specifies the API to build up a RESTful webservice but also enhances the client side API to ease up the process of writing a client for a REST service. In the following tutorial we’re building up a client for a ready-to-play REST service and explore the different new options e.g. how to handle requests in a synchronous or asynchronous way, how to add callback handlers for a request, how to specify invocation targets to build up requests for a later execution or how to filter the client-server communication using client request filters and client response filters. ...

December 30, 2013 · 10 min · 1941 words · Micha Kops

HTML5 Server Send Events using Node.js or Jetty

The HTML5 working draft describes different techniques to push information from a server to the client and the one described in this tutorial are Server-Send Events (SSE). Using Server-Send-Events eliminates the need to poll a server periodically for information using AJAX and is really easy to implement because of the simple specification and the fact that nearly all modern browsers already implement this specification. The Client Side Registering for Server Send Events (SSE) is quite easy .. simply create a new EventSource object that is bound to the URL where the events are propagated. ...

October 21, 2012 · 4 min · 720 words · Micha Kops

Message Driven Beans in Java EE 6

Message Driven Beans are no new concept due to the fact that they exist since EJB 2.0 but in Java EE 6 and the EJB 3.0 specification it is even more fun to use them. In this tutorial we’re going to take a look at the specification and create an example application that transfers some objects via the Java Message Service to a Message-Driven Bean deployed on a GlassFish application server. ...

June 5, 2011 · 12 min · 2430 words · Micha Kops