-
Note: Do NOT have WebFlux and Spring MVC both on the same classpath - unpredictable result will occur
-
Also need to run Eureka Server with ("local-discovery") Profile set so that the Failover Service can be found (GET requested by the other Microservices) at http://localhost:8083/inventory-failover
-
Access Eureka Console to verify @ http://localhost:8761/
- The idea with this Inventory Failover Service is if our main Beer Inventory Service fails or is unavailable, this Failover service will kick in and at least provide inventory values for new Beer Inventory Requests. It may not be able to fulfill any Order Requests, but can at least prevent some downstream errors of failed inventory requests
Service Name | Port |
---|---|
Brewery Beer Service | 8080 |
Brewery Beer Order Service | 8081 |
Brewery Beer Inventory Service | 8082 |
Inventory Failover Service | 8083 |
-
- The Circuit Breaker Pattern is a simple concept which allows you to recover from errors
- If a mission critical service is unavailable or has unrecoverable errors, via the Circuit Breaker Pattern you can specify an alternative action
- For example, we wish to always have inventory for potential orders
- If the inventory service is down, we can provide a fallback service to respond with inventory
-
- Spring Cloud Circuit Breaker is a project which provides abstractions across several circuit breaker implementations
- Thus your source code is not tied t a specific implementation (like SLF4J)
- Supported:
- Netflix Hystrix
- Resilience4J
- Sentinel
- Spring Retry
- Spring Cloud Circuit Breaker is a project which provides abstractions across several circuit breaker implementations
-
- Spring Cloud Gateway supports Netflix Hystrix and Resilience4J
- Gateway Filters are used on top of the Spring Cloud Circuit Breaker APIs
- Netflix has placed Hystrix into maintenance mode, Spring suggests to use Resilience4J
-
- Configure Spring Cloud Gateway to use circuit breaker for failover
- Configure Beer Inventory Service Feign to use Circuit Breaker
For microservices to use JMS Messaging on localhost, Docker must be installed and localhost must be connected to an ActiveMQ Server
https://github.com/vromero/activemq-artemis-docker
spring.artemis.user=artemis spring.artemis.password=simetraehcapa
Beer Service is responsible for generating the Beer objects used in the application and stores that Beer object data in a database. Beer Order Service and Beer Inventory make calls to Beer Service to get information about the Beer objects.
Beer object example:
- UUID id = '026cc3c8-3a0c-4083-a05b-e908048c1b08'
- String beer_name = 'Pinball Porter'
- String beer_style = 'PORTER'
- Timestamp created_date = CURRENT_TIMESTAMP
- Timestamp last_modified_date = CURRENT_TIMESTAMP
- Integer min_on_hand = 12
- Integer quantity_to_brew = 200
- BigDecimal price = 12.95
- String upc = '0083783375213'
- Long version = 1