Showing posts with label Spring. Show all posts
Showing posts with label Spring. Show all posts

Sunday, April 18, 2021

Javabrains POC - Microservices - Part 2 [ Netflix OSS]

https://jsonplaceholder.typicode.com/posts/


https://spring.io/projects/spring-cloud-netflix

Spring Cloud Azure
Spring Cloud for Amazon Web Services
Spring Cloud GCP
Spring Cloud Netflix [Ribbon, Feign, Eureka]
Spring Cloud Kubernetes
Spring Cloud Gateway
Spring Cloud Circuit Breaker
Spring Cloud Config
Spring Cloud OpenFeign
Spring Cloud Consul
Spring Cloud Vault
Spring Cloud Zookeeper

Spring Cloud Netflix OSS 
Feign - Declarative HTTP Client
Eureka - Service Register and Discovery
Ribbon - Client Side Load Balancing
Hytrix - Fault Tolerance Library

Spring Cloud Netflix features:

  • Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans

  • Service Discovery: an embedded Eureka server can be created with declarative Java configuration

  • Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator

  • Circuit Breaker: embedded Hystrix dashboard with declarative Java configuration

  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations

  • Client Side Load Balancer: Ribbon

  • External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions)

  • Router and Filter: automatic registration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation


-----------------------------------------------------------------------------------------------------------


Release TrainBoot Version

2020.0.x aka Ilford

2.4.x

Hoxton

2.2.x, 2.3.x (Starting with SR5)

Greenwich

2.1.x

Finchley

2.0.x

Edgware

1.5.x

Dalston

1.5.x


<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

This is happening because http://microservice_provider_user/ is not a legal host name.

Don't use Underscore for Hostnames


Using Ribbon with Eureka
Use Ribbon Without Eureka
----------------------------------------------------------------------------------------------------------------
Feign

----------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------


Monday, February 1, 2021

Spring: contextConfigLocation context-param and init-param in web.xml

https://stackoverflow.com/questions/15818047/spring-namespace-vs-contextconfiglocation-init-parameters-in-web-xml

https://stackoverflow.com/questions/27539610/order-of-loading-contextconfiglocation-in-web-xml-of-spring-servlet-project

https://howtodoinjava.com/spring-mvc/contextloaderlistener-vs-dispatcherservlet/


DispatcherServlet – Child application contexts

DispatcherServlet is essentially a Servlet (it extends HttpServlet) whose primary purpose is to handle incoming web requests matching the configured URL pattern. It take an incoming URI and find the right combination of controller and view. So it is the front controller.

When you define a DispatcherServlet in spring configuration, you provide an XML file with entries of controller classes, views mappings etc. using contextConfigLocation attribute.

web.xml
<servlet>
    <servlet-name>employee-services</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:employee-services-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>



ContextLoaderListener – Root application context

ContextLoaderListener creates the root application context and will be shared with child contexts created by all DispatcherServlet contexts. You can have only one entry of this in web.xml.

web.xml
<listener>
  <listener-class>
    org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>
  
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
</context-param>

The context of ContextLoaderListener contains beans that globally visible, like services, repositories, infrastructure beans, etc.


Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass