Microservices

Microservices

Microservices are a software development technique—a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services
Jade Bird

Jade Bird

1659928800

Building Event-Driven Microservices with Spring Boot & Apache Kafka

In this tutorial, you'll learn how to build a simple Event-Driven Microservices with Spring Boot and Apache Kafka.

Basically, you will learn how to use Apache Kafka as a message broker for Asynchronous communication between multiple microservices.

Event-driven architecture (EDA) is a software design pattern in which decoupled applications can asynchronously publish and subscribe to events via an event broker/message broker.

Course content: 15 Lectures:
1 - Course Overview [00:00]
2 - What is Event Driven Architecture? [02:49]
3 - How Event-Driven Architecture Works and Its Advantages [06:40]
4 - Install and Setup Apache Kafka on Mac and Windows [11:44]
5 - Create 4 Microservices [34:47]
6 - Import and Setup 4 Microservices in IntelliJ IDEA [40:26]
7 - Create Order and OrderEvent DTO Classes in Base-Domains [47:23]
8 - Configure Kafka Producer in OrderService Microservice [50:40]
9 - Configure Kafka Topic in OrderService Microservice [57:48]
10 - Create Kafka Producer in OrderService Microservice [01:01:46]
11 - Create REST API and Test Kafka Producer in OrderService Microservice [01:09:22]
12 - Configure Kafka Consumer in StockService Microservice [01:16:30]
13 - Create Kafka Consumer in StockService Microservice [01:24:34]
14 - Configure and Create Kafka Consumer in EmailService Microservice [01:36:10]
15 - Run 3 Microservices Together and Have a Demo [01:40:43]

Blog post and source code at https://www.javaguides.net/2022/07/event-driven-microservices-using-spring-boot-and-apache-kafka.html 

#microservices #springboot #kafka

Building Event-Driven Microservices with Spring Boot & Apache Kafka
Louis Jones

Louis Jones

1659759512

DRY, Coupling and Microservices: DRY Software Patterns & Microservices

DRY, Coupling and Microservices: DRY Software Patterns & Microservices

Probably the most popular advice to improve the design of your code is DRY - Don’t Repeat Yourself. It is good advice, a good general guideline even, but it is not always the best answer. This is particularly true in Microservices, where DRY can result in too much coupling between services. So when should you aim for DRY software, and when not? What is microservice that means that DRY is a problem? What are good guidelines for DRY in different parts of your system?

In this episode, Dave Farley of Continuous Delivery explores DRY, Coupling and Microservices and how they interact. Dave takes a pragmatic software engineering approach to exploring the pros and cons of DRY on different scales and describes why the microservices example may be more complicated than it looks.

#microservices

DRY, Coupling and Microservices: DRY Software Patterns & Microservices

How to Use Kafka with Spring Boot in Microservices

Description

There are three microservices:
order-service - it sends Order events to the Kafka topic and orchestrates the process of a distributed transaction
payment-service - it performs local transaction on the customer account basing on the Order price
stock-service - it performs local transaction on the store basing on number of products in the Order

Here's the diagram with our architecture:

image

(1) order-service send a new Order -> status == NEW
(2) payment-service and stock-service receive Order and handle it by performing a local transaction on the data
(3) payment-service and stock-service send a reponse Order -> status == ACCEPT or status == REJECT
(4) order-service process incoming stream of orders from payment-service and stock-service, join them by Order id and sends Order with a new status -> status == CONFIRMATION or status == ROLLBACK or status == REJECTED
(5) payment-service and stock-service receive Order with a final status and "commit" or "rollback" a local transaction make before

Articles

This repository is used as the example for the following articles:

  1. Distributed Transactions in Microservices with Kafka Streams and Spring Boot - how to implement distributed transaction based on the SAGA pattern with Spring Boot and Kafka Streams
  2. Deep Dive into Saga Transactions with Kafka Streams and Spring Boot - how to implement distributed transaction based on the SAGA pattern with Spring Boot and fully Kafka Streams KStream and KTable. You need to switch to the streams-full branch.

Download details:
Author: piomin
Source code: https://github.com/piomin/sample-spring-kafka-microservices?
License:

#spring #java #springboot #kafka #microservices 

How to Use Kafka with Spring Boot in Microservices

Discovery Server, Discovery Client, API-Gateway with Spring Boot Micro

SpringMicroServices

SpringBoot Micro Services, Discovery Server, Discovery Client, API-Gateway (Load-Balancing), Circuit Breaker

Main URIs:

Eureka Discovery Server

http://localhost:8761

The RESTful UI App

http://localhost:8000

Service1 - URI

http://localhost:8001/service1/message

Service2 - URI

http://localhost:8002/service2/message

Load Balanced (API - Gateway)

http://localhost:8003/service1/message

http://localhost:8003/service2/message

Circuit Breaker

http://localhost:8004/home

SpringMicroServices Eureka Discovery Server

springbootrocks

Download details:
Author: 
Source code: 
License:

#spring #java #springboot #microservices 

Discovery Server, Discovery Client, API-Gateway with Spring Boot Micro

Spring Boot Microservices CQRS Event Sourcing

Prerequisites to run the project:

Spin up the development environment through: docker-compose up -d

Start the project through starting all the defined microservices (starting with config-server)

API documentation:

  • Add product
POST http://localhost:8080/command/create

Request Body:

  {
    "ref": "string",
    "name": "string",
    "description": "string",
    "price": "number",
    "quantity": "integer"
  }
  • Buy Product
POST http://localhost:8080/command/buy/<product-ref>
  • Refill Product
POST http://localhost:8080/query/
  • Get All Products
GET http://localhost:8080/command/refill/<product-ref>?quantity=<quantity>
  • Get Product by reference
GET http://localhost:8080/query/<product-ref>
  • Clear query database
DELETE localhost:8080/query/purge
  • Clear command database
DELETE localhost:8080/command/purge

Application Architecture

cqrs

Service registry (Eureka server)

Screen Shot 2022-01-31 at 3 02 33 AM

Config Server

Github repository containing the microservices configuration.

Download details:
Author: AyariAhmed
Source code: https://github.com/AyariAhmed/springboot-microservices-cqrs-event-sourcing
License:

#spring #java #springboot #microservices

Spring Boot Microservices CQRS Event Sourcing

Practice and Testing with Java 11, Prometheus, and Spring-boot

This application was written by Andrew Aslakson

Built to run on minikube using kubernetes

General race tracking system?

Secure with Firebase Authentication?

Build React app too? - realistically probably just postman.

Tech Stack

  • Java 11
  • Maven
  • Spring-Boot
  • Prometheus
  • Jacoco
  • Lombok

Running Instructions

  • tests "mvn clean test -Dspring.profiles.active=test"
    • this generates jacoco reports and runs all Unit and Integration tests
    • test profile uses H2 database, and populates it with 5 test users
  • Running: because tests have special configuration
    • package with "mvn clean package -Dmaven.test.skip"
      • default package is set to "local"
    • package with: "mvn clean package -Dmaven.test.skip"
      • !Not implemented!
    • run with "mvn spring-boot:run -Dspring.profile.active=dev"
  • local Environment: Uses h2 database, used while developing
  • Dev Environment: meant to be for kubernetes, most likely connects to DB hosted on kubernetes
    • Not yet actually configured
  • h2-console: configured to be at: "localhost:5000/h2-console", URL: "jdbc:h2:mem:local"
    • Username: admin
    • password: password
  • Prometheus Statistics: reached at: "localhost:5000/actuator/prometheus"

Database Structure

Database Diagram

Production History

02-04-2022

  • Initialized Project
  • Created Git Repository
  • Added POM dependencies
  • Created Driver class (Just starts Spring Boot Application)
  • Added ERD Documentation
  • Refactored to just be UserService
  • Added Basic CRUD operations

02-08-2022

  • Finished MetricsAspect
  • Finished LoggingAspect
  • Added more Exceptions to Exception Handler
  • h2-console and prometheus metrics are available on endpoints

02-09-2022

  • Added Unit Testing For Service Layer Logic
  • Did a lot more reconfiguring of things today

02-10-2022

  • Added integration testing
  • finished configuring local and test profiles
  • Changed UserId to be GenerationStrategy.IDENTITY
  • Finalized project, cleaned code
  • Massive project reorganization

Download details:
Author: andrewaslakson1
Source code: https://github.com/andrewaslakson1/UserService
License:

#spring #java #springboot #prometheus #microservices 

Practice and Testing with Java 11, Prometheus, and Spring-boot

Building .NET Microservices Applications with Dapr

Building .NET Microservices Applications with Dapr

Build powerful distributed applications with Dapr and .NET. Learn how to build .NET Microservices applications with Dapr. Create robust microservices solutions that run on-premises or in any cloud

There are so many different concerns that developers and architects have to tackle when building reliable distributed applications, including failure recovery, state management, service discoverability, and service to service communication.

By adopting Dapr, you can quickly solve those concerns and create robust microservices solutions that run on-premises or in any cloud. After attending this session, you will be able to describe Dapr's immediate and practical benefits for building great .NET microservices applications.

#dotnet #dapr #microservices #cloud 

Building .NET Microservices Applications with Dapr
Quan Huynh

Quan Huynh

1656931178

Set up a Microservices on Kubernetes - Write Configuration File

Hi Guys! In this tutorial, we will learn how to set up a Microservices System on Kubernetes. In part one we are going to talk about how to write a configuration file for each component of the microservice system.

#devops #kubernetes #microservices 

https://medium.com/@hmquan08011996/set-up-microservice-on-kubernetes-write-config-file-8df7c2b07a4c

Set up a Microservices on Kubernetes - Write Configuration File
Dylan  Iqbal

Dylan Iqbal

1656919170

What is Spin | Introducing Spin

Spin is a framework for building and running event-driven microservice applications with WebAssembly (Wasm) components. With Spin, we’re trying to make it easier to get started with using WebAssembly on the server so that we can all take advantage of the security, portability, and speed WebAssembly provides when it comes to running microservices.

Structure of a Spin Application

  1. A Spin application manifest (spin.toml) file which defines where your WebAssembly components live and what triggers them.
  2. One or more WebAssembly components.

Spin executes the component(s) as a result of events being generated by the trigger(s) defined in the spin.toml file.

Example Spin Application

The following illustrates how to define an HTTP application.

HTTP Handler

This hello_world function written in Rust defines a component that takes a Request and returns a Result<Response>.

#[http_component]​
fn hello_world(_req: Request) -> Result<Response> {​
    Ok(http::Response::builder()​
        .status(200)​
        .body(Some("Hello, Fermyon!".into()))?)​
}​

Spin Manifest

Once the code is compiled to a WebAssembly component, it can be referenced in a spin.toml file to create an HTTP application like below.

spin_version = "1"
name = "spin-hello-world"
trigger = { type = "http", base = "/" }
version = "1.0.0"

[[component]]
id = "hello"
source = "<path to compiled Wasm module>"
[component.trigger]
route = "/hello"

Running a Spin Application

Running this application with the spin CLI is as simple as using the spin up command. Because a trigger type of http is specified in the spin.toml, spin up will start a web server:

$ spin up
Serving HTTP on address http://127.0.0.1:3000
Available Routes:
  hello: http://127.0.0.1:3000/hello

Any time a request is made on the /hello route, it will invoke the hello_world function. Adding another component is as simple as adding another [[component]] stanza to the spin.toml file.

Original article source at https://spin.fermyon.dev/ 

#spin #webapp #microservices #webassembly #wasm 

What is Spin | Introducing Spin

How to Deploy Node.js Microservices to AWS using EKS & Helm

In this video, we learn how to deploy Node.js Microservices to AWS using EKS & Helm, the package manager for Kubernetes.

Timestamps
00:00:00 Introduction
00:00:32 Setup Helm
00:14:55 Add Charts
00:26:18 Using EKS
00:33:30 Load Balancer Controller
00:37:30 Install & Test

Github Repo: https://github.com/mguay22/nestjs-rabbitmq-microservices/tree/eks 
Helm Installation: https://helm.sh/docs/intro/install/
Kubernetes Deployments: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
Kubernetes Secrets: https://kubernetes.io/docs/concepts/configuration/secret/#use-case-as-container-environment-variables
AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
AWS Load Balancer Controller: https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/
Eksctl: https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html

Subscribe: https://www.youtube.com/user/RumblyFoil/featured 

#nodejs #aws #microservices 

How to Deploy Node.js Microservices to AWS using EKS & Helm

Annotations In Java

How to create Custom Annotations In Java?

https://javatechonline.com/annotations-in-java/ 

#java #javaprogramming #javaprogramminglanguage #javadeveloper #javadevelopment #javadevelopers #javadeveloperjobs #javabackend #javabackenddeveloper #javafullstack #javafullstackdeveloper #javadeveloper #javaprogrammer #javatraining #javaee #j2ee #j2eedeveloper #java8 #microservices #microservicesarchitecture #microservice #microservicios #mvcframework #mvc #collections #sorting #java8 #javacode #spring #springframework #javaspring #javaspringboot #springmvc #springboot #interviewquestions #interviewpreparation #interview #annotation

Brooke  Giles

Brooke Giles

1655969735

Build Modern Cloud Native Applications using Spring and Kubernetes

Cloud Native with Spring Boot & Kubernetes

Thomas is a senior software engineer specialized in building modern, cloud native, robust, and secure enterprise applications and author of Cloud Native Spring in Action, published by Manning.

The Spring ecosystem provides you with all you need to build cloud native applications, focusing on productivity, simplicity and speed. It’s ready to leverage cloud environment features and integrates with Kubernetes natively.

In this session, Thomas will cover common patterns and best practices to build cloud native applications using Reactive Spring, which provides better performance, resilience, and efficiency. You’ll then see how to containerize them, configure them through the natively supported ConfigMaps and Secrets, and deploy them to a Kubernetes cluster. Finally, he’ll show how to use Spring Native to build GraalVM native executables.

TIMECODES
00:00 Intro
00:53 Cloud native
03:00 Demo
15:03 Cloud native development
16:08 Containerization
19:50 Demo
23:04 Spring Boot on Kubernetes
23:59 Demo
29:07 Externalized configuration
31:24 Demo
36:21 Health probes
37:54 Demo
46:00 Spring Native
49:51 Demo
54:12 Conclusion
54:50 Outro

#springboot #kubernetes #k8s #cloudnative #cloud #microservices 

Build Modern Cloud Native Applications using Spring and Kubernetes