Designing Microservices

When designing microservices and their APIs, you need to think like a designer focusing on the users, Nic Benders claimed in his presentation at the recent Microservices Practitioner Summit. Design the API first, then build your services with an outside-in approach. Benders is chief architect at New Relic, a company that started off with a […]

Choosing Deployment Strategy for MicroServices

Motivations Deploying a monolithic application means running multiple, identical copies of a single, usually large application. You typically provision N servers (physical or virtual) and run M instances of the application on each one. The deployment of a monolithic application is not always entirely straightforward, but it is much simpler than deploying a microservices application. […]

Java Collection backs another

If a collection backs another, it means that changes in one are reflected in the other and vice-versa. For example, suppose we wanted to create a whitelist function that removes invalid keys from a Map. This is made far easier with Map.keySet, which returns a set of keys that is backed by the original map. […]

Java Method References

Method references were introduced in Java 8 and allow constructors and methods (static or otherwise) to be used as lambdas. They allow one to discard the boilerplate of a lambda when the method reference matches an expected signature. For example, suppose we have a service that must be stopped by a shutdown hook. Before Java […]

How to catch Exception thrown by Another Thread ?

// create our uncaught exception handler Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread th, Throwable ex) { System.out.println(“Uncaught exception: ” + ex); } }; // create another thread Thread otherThread = new Thread() { public void run() { System.out.println(“Sleeping …”); try { Thread.sleep(1000); } catch (InterruptedException e) { System.out.println(“Interrupted.”); } System.out.println(“Throwing exception …”); […]

HTTP/2 JumpStart for Java Developers

HTTP/2 was approved in February 2015 as the successor to the original web communication protocol. While it is in the last stages of finalization, the standard has already been implemented by early adopters such as Jetty and Netty, and will be incorporated into Servlet 4.0. Find out how HTTP/2 renovates HTTP’s text-based protocol for better […]