Friday, 13 September 2019

Java microservices with spring cloud

INTRODUCTION TO MICROSERVICES, SPRING BOOT, AND SPRING CLOUD

Overview
➤Why are microservices architectures popular?
➤Core characteristics of microservices
➤Questions about microservices architecture
➤Microservices scaffolding with Spring Cloud
➤What is Spring Boot?

What are microservices?

microservices can be best described as-
➤An architectural style
➤An alternative to monolith applications
➤Decomposition of single system into a suit of small services,each running as independent process
and intercommunicating via open protocols(HTTP,rest,messaging.....)
➤ seperatley written deployed and maintained.
➤ services encapsulate business capability(rather than language constructs ie- classes,packages as primary way of encapsulation

Definition of Microservices:

➤ fine grained SOA (Adrian Cockcroft- Netflix)

➤ Loosely coupled service oriented architecture with bounded context.(Adrian Cockcroft, Battery Ventures)


Why Are Microservices Architectures Popular?

➤Desire for faster changes
➤Need for greater availability
➤Motivation for fine-grained scaling
➤Compatible with a DevOps mindset


Core Characteristics
  • Components exposed as services
  • Tied to a specific domain
  • Loosely coupled
  • Built to tolerate failure
  • Delivered continuously via automation
  • Built and run by independent teams

Microservices Scaffolding with Spring Cloud

Released March 2015
Build common distributed systems patterns
Open source software Optimized for Spring apps
Run anywhere Includes NetflixOSS technology

Microservices interview questions- 

https://javacmlearning.blogspot.com/2019/09/microservices-interview-questions.html


Catalog of Spring Cloud projects

Spring Cloud Config              ⇥                 Git-backed configuration server
Spring Cloud Netflix              ⇥                 Suite for service discovery, routing, availability
Spring Cloud Consul              ⇥                 Service discovery with Consul
Spring Cloud Security            ⇥                 Simplify OAuth 2.0 flows
Spring Cloud Sleuth               ⇥                 Distributed tracing
Spring Cloud Stream              ⇥                 Message bus abstraction
Spring Cloud Task                  ⇥                Short-lived, single-task microservices
Spring Cloud Dataflow           ⇥                Orchestration of data microservices
Spring Cloud Zookeeper        ⇥                 Service discovery and configuration with Zookeeper
Spring Cloud for AWS           ⇥                 Exposes core AWS services to Spring developers
Spring Cloud Spinnaker          ⇥                Multi-cloud deployment
Spring Cloud Contract            ⇥                Stubs for service contracts




Spring Cloud Config
https://javacmlearning.blogspot.com/p/spring-cloud.html

Spring Boot


Getting java application up and running quickly

Offers opinionated runtime for Spring 
  • intelligent defaults
  • get out of way quickly

setup Simple dependency management 

Embeds app server in executable JAR 

Built in endpoints for health metrics

Spring Boot Prat-1


1- Removing setting from complied code.
--code is printable between environments and configuration can changed as they target dev/qa or test.

2- Change runtime behaviours
Help change behaviours of services easily and quickly if you want to change behaviour you can use configuration of microservices without deploying entire application again.

3- Enforcing consistency across services

4-cache values to reduce load on database













main application file:

@SpringBootApplication
@EnableConfigServer
public class MainAppication{

    public static void main(String args[])
   {
            SpringApplication.run(MainAppication.class,args);
    }

}

create application properties like below-


put values in

➤app1.properties
greeting= hello i am in app1

➤app2.properties
greeting= hello i am in app2

➤app3.properties
greeting= hello i am in app3


now changes in application.properties.

➤application.properties

server.port=8080
spring.profile.active=native

now when you run:

➤http://localhosst:8080/app1/default

hello i am in app1

➤http://localhosst:8080/app2/default

hello i am in app2


➤http://localhosst:8080/app3/default

hello i am in app3


Creating Config Server

https://javacmlearning.blogspot.com/2019/09/spring-boot-creating-config-server.html

No comments:

Post a Comment

Note: only a member of this blog may post a comment.