Articles Tagged ‘reactive’

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

Sunday, November 25th, 2018

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.

(more…)

Reactive Streams – Java 9 Flow API, RxJava, Akka and Reactor Examples

Sunday, January 14th, 2018

Reactive Streams is an initiative trying to standardize asynchronous stream processing with non-blocking  back-pressure. With Java 9, new classes in the java.util.concurrent.flow package offer a semantically equivalent counterpart to this standard that may be adopted by other frameworks.

In the following short tutorial we’re implementing examples for reactive streams with Java 9 and the Flow API, with RxJava2, with Akka, with Reactor and finally there is an example in RxJava1, too though it does not follow the standard.

(more…)

Resilient Architecture in Practice – Circuit Breakers for Java: Failsafe, Javaslang, Hystrix and Vert.x

Tuesday, February 14th, 2017

When dealing with remote services or APIs there is always the risk of latency issues, failures or connection losses. The worst thing to happen is when the remote service is down and our application hangs until the underlying protocol’s (e.g. TCP) connection timeout is reached and we’re receiving an exception. Until this moment is reached, our application might hang, memory is allocated for threads or bound objects and at last, our continuous requests might prevent the remote system from recovering.

We might use timeouts here but circuit-breakers take this approach one step further: A potential failing, critical or dangerous operation is encapsulated with a circuit breaker tracking failures and when a specified threshold is reached it tripping the breaker.  Now all calls to the API fail immediately and the  system does not even try to communicate with the failing remote system or the isolated API.
This avoids  flooding a  dead remote system with requests and allocating memory and system resources for waiting threads etc. and is also a good mechanism and  integration point to track business-critical errors.

In the following tutorial I’m going to demonstrate four different circuit-breaker implementations for Java forced to interact with a failing API.

(more…)

Dynamic Configuration Management with Netflix Archaius and Apache ZooKeeper, Property-Files, JMX

Wednesday, April 13th, 2016

Though having written about other configuration management libraries for Java before, I would like to demonstrate another one today: Netflix Archaius.

Archaius offers some nice features like dynamic typed properties, thread-safe operations, an event system for property changes/updates, a JMX MBean to read and update properties and adaptors for a variety of dynamic configuration sources like Amazon DynamoDB, JDBC, URLs and Apache ZooKeeper.

In the following tutorial I’d like to demonstrate how to read and update application configuration properties with Archaius and data sources like property-files, system-properties, JMX and Apache ZooKeeper.

(more…)

Reactive Programming: Handling Service Timeouts and Retries with Retry4j

Wednesday, December 2nd, 2015

The Reactive Manifesto specifies responsive, resilient, elastic and message-driven as attributes for a reactive application.

When implementing specific mechanisms to achieve this requirements, we often need to deal with timeout and retry-operations in our application and depending on our setup and environment, different tools and libraries exist to help us here.

In the following short tutorial I’d like to demonstrate how to handle exceptions and operation retries on service boundaries with a lesser know, slim library named Retry4j.

(more…)

Search
Categories