Component Tests for Spring Cloud Microservices

Introduction

The shift towards microservices has a direct impact on the testing strategies applied and has introduced a number of complexities that need to be addressed. In fact, microservices require additional levels of testing since we have to deal with multiple independently deployable components.

An excellent explanation of these concepts and the various levels of microservices testing is given by Martin Fowler in his Testing Strategies in a Microservice Architecture presentation. Let's have a look at the revised "test pyramid" from this presentation:

Externalize Application Configuration With Spring Cloud Config

Introduction

One of the principles from the 12 Factor App, states that we have to separate our application configuration from the code. The configuration varies based on the environment and it's better to organize them based on the environment your application is running. 

So in this article, we will be looking at how we can externalize configurations with Spring Cloud Config.

Stateful Microservices With Apache Ignite

Stateful microservices are not a new concept. They have their pros and cons and can shine in highly loaded systems. There are examples of using stateful microservices with Apache Cassandra on board. In this article, I will describe how you can combine this approach with Apache Ignite.

Stateless Architecture

The traditional microservices architecture is stateless. In this case, the database cluster is deployed away from the application instances, as is the distributed cache. In case of increased load, each of these elements is scaled independently.

Exploring Spring Cloud Configuration Server  in Microservices

In this article, we will learn how to use the Spring Cloud Configuration server to centralize managing the configuration of our microservices. An increasing number of microservices typically come with an increasing number of configuration files that need to be managed and updated. 

With the Spring Cloud Configuration server, we can place the configuration files for all our microservices in a central configuration repository that will make it much easier to handle them. Our microservices will be updated to retrieve their configuration from the configuration server at startup. 

Implementing Circuit Breaker Pattern Using Spring Cloud Hystrix

Spring Cloud Hystrix is another important component of the Spring Cloud project. It is used to implement the Circuit Breaker pattern. The role of the circuit breaker is to enable fault tolerance in a microservice architecture in case some underlying service is down.

In other words, using a circuit breaker, we can fall back to a different path of the program automatically. Spring Cloud Hystrix helps make the switch seamless.

Shared Microservice Configurations Using Spring Cloud Config

The microservice architecture pattern, which is used widely across tech companies large and small, enables businesses to distribute functionality between many small applications, instead of larger monolithic portions. Each piece has a specifically defined task, along with communications and other services, usually via a REST API channel. The benefits of utilizing a microservice architecture include, but are not limited to: 

  • Simple development and maintenance of applications: developers and teams are able to focus on one application rather than multiple, with the benefit of faster development, and fewer hitches (such as bug and easy to miss errors) in the larger project. 

Azure Spring Cloud: A Comprehensive Overview

logos

In this article, you will learn about Azure Spring Cloud and its main features quickly and with ease, through a very down-to-earth approach.

What Made it Possible

Azure Spring Cloud is the natural consequence of Microsoft getting closer to the Java community over the last few years, on top of the fact that the Java ecosystem has been completely dominated by Spring for a long time now.

How to Implement Oauth2 Security in Microservices

Purpose

I wanted a solution where we can easily captured Oauth2 and Oauth2 client for the secure communication with all of the microservices. Focusing, how to achieve oauth2 full flavor into microservices architecture. User can’t access API without token. The token will be available when user given basic and authentication details to generate token for access API.

All requests will consider one entry point API-Gateway but, service-to-service can communicate. The API-Gateway will dynamic routing using Zuul Netflix OSS component. Every request will check authorization when request will arrived into service and service will request authorization server to verify is either authenticate or not. The entire Meta configuration settled into the central configuration on github (You can manage on any repository).

Create an API Gateway with Load Balancer Using Java

Used Libraries

  1.   Netflix Eureka naming server 
  2.   Netflix Zuul
  3.   Ribbon
  4.   Feign

Network Architecture of the system

This Architecture Contains Four Applications

  1. Load balancing application [netflix-eureka-naming-server]
  2. API gateway application [api-gateway-server]
  3. Server application [micro-service-server]
  4. Client application [micro-service-client]

Steps To Run The Applications

  1. Install JDK 11 or latest. 
  2. Clone git repository of the project into local.
  3. Github: https://github.com/VishnuViswam/LOAD-BALANCER-WITH-API-GATEWAY.git
  4. Run Load balancing application first. 
  5. Run The API gateway application.
  6. Then run Server application in two ports. 
  7. At last run Client application.

1) Load Balancing Application

All client server communication will be done through this load balancing server application. 

SSL-Based/Secured FeignClient Example in Java Microservices With Eureka

Prerequisite:

  • You should have one Discovery Server up and running
  • An SSL based microservice registered with the above Discovery Server up and running which we are going to consume from below FeignClient
  • You need to generate your client application's keystore and trust store. You need to add your server certificate into your client application's trustStore and add your client application's certificate in the Server application's trustStore.

Before reading this article make sure that you know about Spring Feign Client. In this article, I will explain how to develop a Feign Client application/service to establish two way SSL based communication. In simple words, how a Feign Client can make an HTTPS REST service call. Also for this project, I assumed that we have a Eureka discovery server and one SSL based Spring boot microservice called global-repository. In other words from our FeignClient below, we are going to consume an SSL based microservice (global-repository)with a valid certificate.

Spring Cloud and Turbine

In this article, we'll introduce you to Spring Cloud Netflix Turbine. It aggregates multiple Hystrix Metrics Streams into one, so that it could be displayed into a single dashboard view.

To give a small introduction to Hystrix. In a microservice architecture, we have many small applications that talk to each other to complete a request.

Configuration As A Service: Spring Cloud Config – Using Kotlin

Developing a microservice architecture with Java and Spring Boot is quite popular these days. In microservice architecture we hundreds of services and managing services for each service and for each profile which is a quite tedious task. In this article, we will demonstrate the Spring cloud config server using Kotlin. 

Spring Boot provided a much-needed spark to the Spring projects.

Spring Cloud Stream + Apache Kafka

Spring Cloud Stream is a framework for building highly scalable event-driven microservices connected with shared messaging systems.

The framework provides a flexible programming model built on already established and familiar Spring idioms and best practices, including support for persistent pub/sub semantics, consumer groups, and stateful partitions.

Spring Cloud Config Server

Learn how to set up a Spring config server

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems and it enables engineers to quickly develop cloud-native applications. One of the features is to maintain application configurations ouddtside the application. This will enable configuration change without restarting microservice application.

Spring Cloud Streams ETL

Spring clouds. Get it?

Spring Cloud Data Flow is a cloud-native toolkit for building real-time data pipelines and batch processes. Spring Cloud Data Flow is ready to be used for a range of data processing use cases like simple import/export, ETL processing, event streaming, and predictive analytics.

We can categorize SCDF applications as Streams and Tasks. Generally, Streams are long-running applications and continue processing data as long as desired; on the other hand, Tasks are short-lived applications which are created, executed and terminated within a relatively short span of time. Our focus in this article is the former.