Feed aggregator

Streaming Microservices With Akka Streams and Kafka Streams [Webinar]

Javalobby Syndicated Feed - Fri, 16-Mar-18 22:02

One of the most frequent questions that we at Lightbend have been asked is “what’s the difference between Akka Streams and Kafka Streams?” After all, there is only a 1 letter difference between these two technologies, so how different could they be?

Well, as we are about to learn, they are actually quite different. Both tools are part of Lightbend Fast Data Platform, but were created with entirely different technological approaches in mind. For example, Akka Streams emerged as a dataflow-centric abstraction for the Akka Actor model, designed for general-purpose microservices, very low-latency event processing, and supports a wider class of application problems and third-party integrations via Alpakka. Kafka Streams, by comparison, is purpose-built for reading data from Kafka topics, processing it, and writing the results to new topics in a Kafka-centric way.

Categories: Java

Building Spring Boot 2.0 Apps: VS Code, Initializr, and Azure Starters

Javalobby Syndicated Feed - Fri, 16-Mar-18 09:01

We are excited to announce full support of Spring Boot 2.0 on the Spring Boot Starters for Azure, already available on Spring Initializr. Plus, with new Java and Spring extensions for Visual Studio Code you can build production-ready apps and easily deploy them to the cloud.

Integrate Azure Services With Spring Boot 2.0 Apps

Spring Initializr enables developers to handle the dependency management and makes the bootstrapping process for Spring projects much easier. Today, we’re announcing that the Azure Starters have been updated to support Spring Boot 2.0, so you can easily integrate cloud services with your application.

Categories: Java

Using Reactive Streams, Akka Streams, Akka HTTP, and Alpakka For Legacy Integrations

Javalobby Syndicated Feed - Fri, 16-Mar-18 03:01

Software is turning more and more into individual services that provide value to individual consumers. It is a part of a greater whole, and in a typical enterprise, we see that multiple generations of technologies must co-exist for systems to function properly as a whole.

In addition to that, the need to integrate with existing systems is increasing. The technologies used can be WebServices, HTTP APIs, databases, or even external devices such as sensors.

Categories: Java

Creating an AWS Lambda Deployment JAR Using Maven

Javalobby Syndicated Feed - Fri, 16-Mar-18 00:01

One key aspect of AWS Lambda functions (with Java) is creating deployment packages (JAR or ZIP files) for uploading/deploying on the AWS Lambda service. In this post, you will learn different ways in which you can create a deployment JAR file for AWS Lambda projects using Maven. We will look at:

  • Deployment JAR using Maven and Eclipse IDE
  • Deployment JAR using Maven and the command prompt

I recommend using the "Maven and command prompt" technique for creating your deployment JAR package, but we will cover both methods.

Categories: Java

Duke Takes His Last Tumble

Javalobby Syndicated Feed - Thu, 15-Mar-18 21:01

When Java was first released, the world was a very different place. This was 1995, and the Internet and World Wide Web were still very much in their infancy. When James Gosling and John Gage demonstrated the WebRunner browser (as it was then called) running a Java applet that could rotate a molecule, the world changed. Suddenly, the web went from having only static content with hypertext links to a dynamic, interactive system.

From tiny acorns, mighty oak trees grow (if you’ll excuse the pun) and that’s precisely what we’ve seen with the web. Almost every aspect of our lives, from information access to banking to social interaction, now takes place through the Internet and the web. What we experience through the browser has changed beyond all recognition.

Categories: Java

Java Version Upgrades: GC Overview

Javalobby Syndicated Feed - Thu, 15-Mar-18 13:01

I'm guessing there are many companies on the verge of upgrading to a newer Java version because developers love to upgrade, but besides this adventurous attitude, there is also fear. The biggest fear of such a change is that applications can produce unexpected behaviors. In my opinion, the root of this fear is the GC system, the fear of the unknown. 

First, we will do a quick walkthrough of how memory management architecture looks, what kind of GC algorithms are available, and what GC types exist. We will then go over how to come up with a plan that is safe and can persuade management that switching to a newer Java version won't be the end of worlds. If you are pretty confident on how the GC works, you can skip to the end of the article where the TODOs are listed. For others, let's start with the architecture for the JVM.

Categories: Java

This Week in Spring: Even More Spring Boot 2

Javalobby Syndicated Feed - Thu, 15-Mar-18 09:01

Hi, Spring fans! Welcome to another installment of This Week in Spring! This week I’m in blizzard-besieged Boston, Massachusetts, for the epic Spring One Tour Boston event. Unfortunately, due to this crazy snow storm/blizzard, the event’s been postponed one day as we all grapple with the weather. Hope you were able to join the Spring Boot 2.0 launch webinar! If not the replay will be available here and don’t forget to check out the launch blog!

Snow or no snow! The show must go on, at least here on the Spring blog, so without further ado:

Categories: Java

Concurrent Java: Scalability, Deadlocks, and Garbage Creation

Javalobby Syndicated Feed - Thu, 15-Mar-18 08:54

On the example of three concurrent map implementations, we will see that we have low scalability, the risk of deadlocks, or unnecessary garbage creation. Locks lead to low scalability when we use only one — or risk deadlocks when using multiple locks. Compare and swap operations and immutable data structures, on the other hand, lead to unnecessary object creation, which causes more garbage collection cycles.

So what technique should you choose? If we have a small data structure, we can use an immutable class. And if our data structure is not performance critical, we can use a single lock. In all other cases, I would start with multiple locks, since it is easier to implement than compare and swap operations. But let us first start with the easiest case, a hash map synchronized with a single lock.

Categories: Java

Updates on JavaFX, Valhalla, Data Classes, and Java's Floating-Point

Javalobby Syndicated Feed - Thu, 15-Mar-18 00:01

There have been some interesting posts this and recent weeks that provide more insight into the future of Java and the JDK.

JavaFX Removed From JDK with JDK 11

In the blog post "The Future of JavaFX and Other Java Client Roadmap Updates," Oracle's Donald Smith announced that "starting with JDK 11, Oracle is making JavaFX easier to adopt by making the technology available as a separate download, decoupled from the JDK." Smith provides a brief history of JavaFX and discusses other motivations for the decision to decouple JavaFX from the JDK.

Categories: Java

Build a Microservices Architecture for Microbrews With Spring Boot

Javalobby Syndicated Feed - Wed, 14-Mar-18 21:01

Adopting a microservice architecture provides unique opportunities to add failover and resiliency to your systems, so your components can handle load spikes and errors gracefully. Microservices make change less expensive too. It can also be a good idea when you have a large team working on a single product. Your project can likely be broken up into components that can function independently of one another. Once components can function independently, they can be built, tested, and deployed independently. This gives an organization and its teams the agility to develop and deploy very quickly.

In a previous article, I showed you how to build a Spring Boot API with an Angular client. I then showed you how to convert the Angular app into a progressive web application that works offline. The Angular PWA is a good example of a resilient application because it still works when connectivity fails. Did you know you can develop similar resiliency in your API with Spring Boot, Spring Cloud, and a microservices architecture? This article shows you how to convert the previously created Spring Boot application to use microservices. You’ll create a beer catalog service, an edge service (for filter and displaying good beers), and a Eureka service that registers the services and allows them to communicate with one another.

Categories: Java

How Synchronization Works in Java (Part 2)

Javalobby Syndicated Feed - Wed, 14-Mar-18 13:01

In my previous article, we saw how synchronized blocks execute in Java. We did some debugging in Eclipse IDE as well to understand the flow of execution clearly.

This article focuses more on synchronized methods in Java, so let's begin.

Categories: Java

Java Out of Memory Heap Analysis

Javalobby Syndicated Feed - Wed, 14-Mar-18 09:01

Any software developer who has worked with Java-based enterprise-class backend applications would have run into this infamous or awkward error from a customer or QA engineer: java.lang.OutOfMemoryError: Java heap space.

To understand this, we have to go back to the computer science fundamentals of the complexity of algorithms, specifically "space" complexity. If we recall, every application has a worst-case performance. Specifically, in the memory dimension, when this is unpredictable or is spiky, more than the recommended memory is being allocated to the application. That leads to an over-usage of the heap memory allocated and hence an "out of memory" condition.

Categories: Java

Hello OpenJ9 on Windows, I Didn’t Expect You so Soon!

Javalobby Syndicated Feed - Wed, 14-Mar-18 03:01

Faster startup time, lower memory footprint, and higher application throughput only by replacing the Java Virtual Machine? That sounds too good to be true. So far, there has been no real alternative to Oracle’s Java HotSpot VM on Windows. With Eclipse OpenJ9, which emerged from open-sourcing IBM’s J9 VM, there is now the alternative that promises exactly this.

At the end of January, the first OpenJDK 9 with Eclipse OpenJ9 nightly builds for Windows were published, but they were not very stable at that time. This week, I tested the nightly builds again to run the Eclipse IDE and I was pleasantly surprised: OpenJ9 ran without crashing. Here are my results: the start time of the Eclipse Oxygen.2 Java IDE improves with OpenJ9 from 20 to 17 seconds, with some tuning (see below) even to 12 seconds compared to the Java 9 JDK with Oracle’s HotSpot VM on my more than six-year-old laptop. Also, the Windows Task Manager shows less memory used by the Eclipse IDE and tasks like compiling a large project are a bit faster with OpenJ9.

Categories: Java

Fluent Assertions With AssertJ

Javalobby Syndicated Feed - Wed, 14-Mar-18 00:01

I recently gave a presentation to my Keyhole team members about JUnit 5. I started off the presentation by covering the importance of automated testing, how lack of automated testing affects an organization's ability to deliver code to production, and how without automated testing you are building legacy.

I pointed out two key benefits of automated testing: confidence you are fixing what you set out to fix, and confidence you are not introducing a new bug. A co-worker however pointed out an important third benefit of automated testing: providing living documentation.

Categories: Java

Upgrading start.spring.io to Spring Boot 2

Javalobby Syndicated Feed - Tue, 13-Mar-18 21:01

Spring Boot 2 was released recently and the production instance of Spring Initializr (start.spring.io) was upgraded to Spring Boot 2 the same day.

In this post, I’d like to walk you through the process of upgrading a Spring Boot 1.x app to Spring Boot 2.

Categories: Java

Features in Java 10

Javalobby Syndicated Feed - Tue, 13-Mar-18 10:27

Java 9 has changed Java's structure by introducing modular development (Project Jigsaw). Meanwhile, Java 10 will add flavors by introducing new features of its own. A few features are explained below, with snippets.

Local Variable Type Inference

Java 7 introduced the diamond operator:

Categories: Java

5 Annotations Every Java Developer Should Know

Javalobby Syndicated Feed - Tue, 13-Mar-18 10:02

Since their inception in Java Development Kit (JDK) 5, annotations have become an indispensable part of the Java ecosystem. While there are countless custom annotations developed for use by Java frameworks (such as @Autowired for Spring), there are a few annotations recognized by the compiler that are of supreme importance. In this article, we will take a look at 5 of the annotations supported by all Java compilers and take a look at their intended uses. Along the way, we will explore the rationale behind their inception, some idiosyncrasies that surround their use, and some examples of their proper application. Although some of these annotations are more common than others, each should be internalized by non-beginner Java developers. To start off, we will delve into one of the most commonly used annotations in Java: @Override.


The ability to override the implementation of a method, or provide an implementation for an abstract method, is at the core of any Object-Oriented (OO) language. Being that Java is an OO language and features many of the common OO abstraction mechanisms, a non-final method defined in a non-final superclass or any method in an interface (interface methods cannot be final) can be overridden by a subclass. Although overriding a method appears to be straightforward at first, there are many subtle bugs that can be introduced when overriding is performed incorrectly. For example, it is a common mistake to override the Object#equals method with a single parameter of the type of the overriding class:

Categories: Java

Java Quiz 13: Passing Objects to a Method

Javalobby Syndicated Feed - Tue, 13-Mar-18 07:02

 Before we start with this week's quiz, here is the answer to Java Quiz 12: Unary Operators.

  1. The statement if(a == a++) returns true because the value of a is incremented by one after the evaluation.

Categories: Java

Introducing Spring Boot

Javalobby Syndicated Feed - Tue, 13-Mar-18 02:01

Setting up an enterprise spring-based application has become a tedious and error-prone task due to the required bulky configuration along with the complicated dependency management especially if we're talking about applications which make use of several third-party libraries.

Each time you build an enterprise spring-based application, you have to repeat the same configuration steps:

Categories: Java

MicroProfile Fault Tolerance in WildFly Swarm

Javalobby Syndicated Feed - Mon, 12-Mar-18 21:01

Every developer has the goal of building the most resilient application possible. Due to the distributed nature of microservices, resiliency and handling failures gracefully is mandatory. The Java ecosystem has some nice frameworks for fault tolerance, such as Hystrix or Failsafe. However, none of these provide a standard API, so using them means your application will be tightly coupled to that framework. The primary motivation for the MicroProfile specifications is to provide standard APIs that eliminates the tight coupling and improves deployment flexibility. This article will describe the main features of the MicroProfile Fault Tolerance specification, and then demonstrate how it was implemented in WildFly Swarm, the Red Hat MicroProfile implementation.

About Eclipse MicroProfile Fault Tolerance

Eclipse MicroProfile Fault Tolerance is one of the Eclipse MicroProfile specifications that provides a standard and easy way to add resiliency to your microservice or other Java EE development.
Note: see Jeff Mesnil's article on Develop Cloud-native Applications with MicroProfile

Categories: Java

Thread Slivers eBook at Amazon

Syndicate content