├── .editorconfig
├── .gitignore
├── .mvn
├── jvm.config
├── maven.config
└── wrapper
│ └── maven-wrapper.properties
├── LICENSE
├── README.adoc
├── docker-compose.yml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── scripts
├── download_everything.sh
├── setup.sh
└── whats_my_ip.sh
├── week1
├── part1
│ ├── http
│ │ └── part1-week1.http
│ ├── pom.xml
│ └── spring-data
│ │ ├── .mvn
│ │ └── wrapper
│ │ │ ├── MavenWrapperDownloader.java
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ │ ├── HELP.md
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── part2
│ ├── demo-week1-part2
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── http
│ │ │ └── part1-week2.http
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── demo
│ │ │ │ │ └── DemoApplication.java
│ │ │ └── resources
│ │ │ │ ├── application-foo.properties
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ └── DemoApplicationTests.java
│ └── pom.xml
├── part3
│ ├── docker-compose.yml
│ ├── http
│ │ ├── assignment.http
│ │ └── encryption.http
│ ├── pom.xml
│ ├── scripts
│ │ └── script.sh
│ ├── spring-cloud-config-client
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── docker-compose.yml
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── demo
│ │ │ │ │ └── DemoApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ └── DemoApplicationTests.java
│ └── spring-cloud-config-server
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ │ ├── docker-compose.yml
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ └── resources
│ │ │ └── application.yml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── demo
│ │ └── DemoApplicationTests.java
├── part4
│ ├── boot-k8s
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── docker-compose.yml
│ │ ├── k8s
│ │ │ ├── config-map-changed.yml
│ │ │ ├── config-map-refresh.yml
│ │ │ ├── config-map.yml
│ │ │ ├── deployment.yml
│ │ │ └── kind-with-registry.sh
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── demo
│ │ │ │ │ └── DemoApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ └── DemoApplicationTests.java
│ ├── buildpacks
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── demo
│ │ │ │ │ └── DemoApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ └── DemoApplicationTests.java
│ └── pom.xml
└── pom.xml
├── week2
├── docker-compose.yml
├── part1
│ ├── fraud-detection
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── frauddetection
│ │ │ │ │ └── FraudDetectionApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── frauddetection
│ │ │ └── FraudDetectionApplicationTests.java
│ ├── http
│ │ └── assignment.http
│ ├── loanissuance-loadbalancer
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ └── pom.xml
├── part2
│ ├── circuit-breaker-reactive
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ ├── circuit-breaker-retry
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ ├── circuit-breaker
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ ├── fraud-detection
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── frauddetection
│ │ │ │ │ └── FraudDetectionApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── frauddetection
│ │ │ └── FraudDetectionApplicationTests.java
│ ├── http
│ │ └── assignment.http
│ └── pom.xml
├── part3
│ ├── docker-compose.yml
│ ├── fraud-detection
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── frauddetection
│ │ │ │ │ └── FraudDetectionApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── frauddetection
│ │ │ └── FraudDetectionApplicationTests.java
│ ├── http
│ │ └── assignment.http
│ ├── loan-issuance-stream-reactive
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ ├── loan-issuance-stream
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ └── pom.xml
├── part4
│ ├── docker-compose.yml
│ ├── fraud-detection
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── frauddetection
│ │ │ │ │ └── FraudDetectionApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── frauddetection
│ │ │ └── FraudDetectionApplicationTests.java
│ ├── gateway-mvc
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── gateway
│ │ │ │ │ └── GatewayApplication.java
│ │ │ └── resources
│ │ │ │ └── application.yml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── gateway
│ │ │ └── GatewayApplicationTests.java
│ ├── gateway
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── gateway
│ │ │ │ │ └── GatewayApplication.java
│ │ │ └── resources
│ │ │ │ └── application.yml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── gateway
│ │ │ └── GatewayApplicationTests.java
│ ├── http
│ │ └── assignment.http
│ ├── loan-issuance-gateway
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── loanissuance
│ │ │ │ │ └── LoanIssuanceApplication.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── loanissuance
│ │ │ └── LoanIssuanceApplicationTests.java
│ └── pom.xml
└── pom.xml
└── week3
├── part1
├── .gitignore
├── docker-compose.yml
├── docker
│ ├── grafana
│ │ └── provisioning
│ │ │ └── datasources
│ │ │ └── datasource.yml
│ └── prometheus
│ │ └── prometheus.yml
├── docker_backup
│ ├── grafana
│ │ └── provisioning
│ │ │ ├── dashboards
│ │ │ ├── dashboard.json
│ │ │ └── dashboard.yml
│ │ │ └── datasources
│ │ │ └── datasource.yml
│ └── prometheus
│ │ └── prometheus.yml
├── fraud-detection
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── frauddetection
│ │ │ │ └── FraudDetectionApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── frauddetection
│ │ └── FraudDetectionApplicationTests.java
├── http
│ └── assignment.http
├── pom.xml
└── scripts
│ ├── replace_ip.sh
│ ├── setup.sh
│ └── whats_my_ip.sh
├── part2
├── docker-compose.yml
├── fraud-detection
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── frauddetection
│ │ │ │ └── FraudDetectionApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── frauddetection
│ │ └── FraudDetectionApplicationTests.java
├── http
│ └── assignment.http
├── loanissuance
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── loanissuance
│ │ │ │ └── LoanIssuanceApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── loanissuance
│ │ └── LoanIssuanceApplicationTests.java
└── pom.xml
├── part3
├── docker-compose.yml
├── fraud-detection
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── frauddetection
│ │ │ │ └── FraudDetectionApplication.java
│ │ └── resources
│ │ │ ├── application.properties
│ │ │ └── data.sql
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── frauddetection
│ │ └── FraudDetectionApplicationTests.java
├── http
│ └── assignment.http
├── loanissuance
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── loanissuance
│ │ │ │ └── LoanIssuanceApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── loanissuance
│ │ └── LoanIssuanceApplicationTests.java
├── pom.xml
└── scripts
│ ├── disableAllWatchers.json
│ ├── disableAttacks.json
│ ├── disableAttacks.sh
│ ├── enableExceptionAssault.json
│ ├── enableRepositoryExceptionAssault.sh
│ ├── enableRepositoryWatcher.json
│ ├── enableServiceExceptionAssault.sh
│ └── enableServiceWatcher.json
├── part4
├── fraud-detection
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── frauddetection
│ │ │ │ ├── EmptyFraudService.java
│ │ │ │ ├── FraudCheckingService.java
│ │ │ │ ├── FraudDetectionApplication.java
│ │ │ │ ├── MyFeatures.java
│ │ │ │ ├── StaticFraudService.java
│ │ │ │ └── toggles
│ │ │ │ ├── FeatureProxyFactoryBean.java
│ │ │ │ └── FeatureProxyInvocationHandler.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── frauddetection
│ │ │ └── FraudDetectionApplicationTests.java
│ │ └── resources
│ │ └── application-test.properties
├── http
│ └── assignment.http
├── pom.xml
└── spring-cloud-config-server
│ ├── .gitignore
│ ├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ └── DemoApplication.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── demo
│ └── DemoApplicationTests.java
└── pom.xml
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 |
7 | [*.java]
8 | indent_style = tab
9 | indent_size = 4
10 | continuation_indent_size = 8
11 |
12 | [*.kt]
13 | indent_style = tab
14 | indent_size = 4
15 | continuation_indent_size = 8
16 |
17 | [*.groovy]
18 | indent_style = tab
19 | indent_size = 4
20 | continuation_indent_size = 8
21 |
22 | [*.xml]
23 | indent_style = tab
24 | indent_size = 4
25 | continuation_indent_size = 8
26 |
27 | [*.yml]
28 | indent_style = space
29 | indent_size = 2
30 |
31 | [*.yaml]
32 | indent_style = space
33 | indent_size = 2
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | pom.xml.tag
3 | pom.xml.releaseBackup
4 | pom.xml.versionsBackup
5 | pom.xml.next
6 | release.properties
7 | dependency-reduced-pom.xml
8 | buildNumber.properties
9 | .mvn/timing.properties
10 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
11 | .mvn/wrapper/maven-wrapper.jar
12 | nohup.log
13 | .vscode/
14 | *.iml
15 | .idea
16 | .classpath
17 | .project
18 | .settings
19 | bin/
20 | *.log
21 | *.gz
22 |
--------------------------------------------------------------------------------
/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom
--------------------------------------------------------------------------------
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -P spring
2 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | wrapperVersion=3.3.2
18 | distributionType=only-script
19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
20 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = Java Microservices Workshop
2 |
3 | Requirements:
4 |
5 | - JDK 17
6 | - Docker
7 | - Vault CLI
8 | - KIND - Kubernetes in Docker
9 |
10 | == How to prepare
11 |
12 | You can call the script that fetches docker images and downloads all application JARs.
13 |
14 | ```
15 | $ ./scripts/download_everything.sh
16 | ```
17 |
18 | Go to https://developer.hashicorp.com/vault/tutorials/getting-started/getting-started-install to learn how to install Vault CLI. Then you can make this call
19 |
20 | ```
21 | $ vault --version
22 | ```
23 |
24 | Go to https://kind.sigs.k8s.io/docs/user/quick-start to learn how to install KIND. If you install it then you can run this command to create a cluster
25 |
26 | ```
27 | $ kind create cluster
28 | ```
29 |
30 | === Manual preparation
31 |
32 | In the sections below you can find hints on how to manually prepare your environment.
33 |
34 | ==== Docker Images
35 |
36 | If you're using Windows and can't run this script then ensure that you pull the Docker images for these docker compose files (`$ docker compose pull`)
37 |
38 | - `./docker-compose.yml`
39 | - `./week3/part1/docker-compose.yml`
40 |
41 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 | services:
3 | consul:
4 | image: progrium/consul
5 | extra_hosts: ['host.docker.internal:host-gateway']
6 | command: -server -bootstrap
7 | ports:
8 | - 8400:8400
9 | - 8500:8500
10 | - 8600:8600
11 |
12 | rabbitmq:
13 | image: rabbitmq:management
14 | ports:
15 | - 5672:5672
16 | - 15672:15672
17 |
18 | # https://developer.confluent.io/quickstart/kafka-docker/
19 | zookeeper:
20 | image: confluentinc/cp-zookeeper:6.2.0
21 | extra_hosts: ['host.docker.internal:host-gateway']
22 | environment:
23 | ZOOKEEPER_CLIENT_PORT: 2181
24 | ZOOKEEPER_TICK_TIME: 2000
25 |
26 | broker:
27 | image: confluentinc/cp-kafka:6.2.0
28 | extra_hosts: ['host.docker.internal:host-gateway']
29 | ports:
30 | # To learn about configuring Kafka for access across networks see
31 | # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
32 | - "9092:9092"
33 | depends_on:
34 | - zookeeper
35 | environment:
36 | KAFKA_BROKER_ID: 1
37 | KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
38 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
39 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
40 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
41 | KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
42 | KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
43 |
44 | zipkin:
45 | image: openzipkin/zipkin
46 | extra_hosts: ['host.docker.internal:host-gateway']
47 | ports:
48 | - 9411:9411
49 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 | com.example
7 | oreilly-java-microservices-with-spring
8 | pom
9 |
10 | ${project.artifactId}
11 | ${project.artifactId}
12 | 1.0.0-SNAPSHOT
13 |
14 |
15 |
16 |
17 | maven-deploy-plugin
18 |
19 | true
20 |
21 |
22 |
23 |
24 |
25 |
26 | week1
27 | week2
28 | week3
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/scripts/download_everything.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 |
5 | echo "Fetching dependencies"
6 | ./mvnw dependency:go-offline
7 |
8 | echo "Fetching docker images"
9 | docker compose pull
10 | pushd week3/part1
11 | docker compose pull
12 | popd
13 |
14 | echo "Running KIND"
15 | kind delete cluster || echo "Already deleted"
16 | ./week1/part4/boot-k8s/k8s/kind-with-registry.sh
17 | kind delete cluster || echo "Already deleted"
18 |
19 | echo "Checking if Vault CLI is installed"
20 | # https://developer.hashicorp.com/vault/tutorials/getting-started/getting-started-install
21 | vaultMissing="false"
22 | vault --version || echo "Vault missing" && vaultMissing="true"
23 | if [[ "${vaultMissing}" == "false" ]]; then
24 | echo "Please check https://developer.hashicorp.com/vault/tutorials/getting-started/getting-started-install on how to install Vault"
25 | fi
26 |
--------------------------------------------------------------------------------
/scripts/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 |
5 | echo "Sets up IPs for datasources"
6 | ./scripts/replace_ip.sh
7 |
--------------------------------------------------------------------------------
/scripts/whats_my_ip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 |
5 | case "`uname`" in
6 | Darwin* )
7 | echo "host.docker.internal"
8 | ;;
9 | * )
10 | isIfConfigPResent="$( ifconfig &> /dev/null || echo 'no' )"
11 | if [[ "${isIfConfigPResent}" == "no" ]]; then
12 | hostname -I | cut -d' ' -f1
13 | else
14 | ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1
15 | fi
16 | ;;
17 | esac
18 |
--------------------------------------------------------------------------------
/week1/part1/http/part1-week1.http:
--------------------------------------------------------------------------------
1 | # What is the default logging level for
2 | GET localhost:4321/actuator/loggers/org.apache.catalina.util.LifecycleBase
3 |
4 | ###
5 |
6 | # Which endpoint ensures that your application is healthy?
7 | GET localhost:4321/actuator/health
8 |
9 |
10 | ###
11 |
12 | # Which Java Home variable does your application take into consideration (it's there as a JAVA_HOME env var)
13 | GET localhost:4321/actuator/env/JAVA_HOME
14 |
15 | ###
16 |
17 | # Why wasn't the R2dbcAutoConfiguration read?
18 | GET localhost:4321/actuator/conditions
19 |
20 |
21 |
--------------------------------------------------------------------------------
/week1/part1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week1
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week1-part1
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | spring-data
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/week1/part1/spring-data/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week1/part1/spring-data/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week1/part1/spring-data/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/week1/part1/spring-data/HELP.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | ### Reference Documentation
4 | For further reference, please consider the following sections:
5 |
6 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
7 | * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.6.3/maven-plugin/reference/html/)
8 | * [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.6.3/maven-plugin/reference/html/#build-image)
9 | * [Spring Data JPA](https://docs.spring.io/spring-boot/docs/2.6.3/reference/htmlsingle/#boot-features-jpa-and-spring-data)
10 |
11 | ### Guides
12 | The following guides illustrate how to use some features concretely:
13 |
14 | * [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
15 |
16 |
--------------------------------------------------------------------------------
/week1/part1/spring-data/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | demo
13 | 0.0.1-SNAPSHOT
14 | demo
15 | Demo project for Spring Boot
16 |
17 | 17
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-actuator
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-data-jpa
31 |
32 |
33 |
34 | com.h2database
35 | h2
36 | runtime
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-starter-test
41 | test
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-maven-plugin
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/week1/part1/spring-data/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.CommandLineRunner;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.data.jpa.repository.JpaRepository;
8 | import org.springframework.stereotype.Repository;
9 | import org.springframework.util.Assert;
10 |
11 | import jakarta.persistence.Entity;
12 | import jakarta.persistence.GeneratedValue;
13 | import jakarta.persistence.GenerationType;
14 | import jakarta.persistence.Id;
15 | import jakarta.transaction.Transactional;
16 |
17 | @SpringBootApplication
18 | public class DemoApplication implements CommandLineRunner {
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(DemoApplication.class, args);
22 | }
23 |
24 | @Autowired
25 | MyEntityRepository myEntityRepository;
26 |
27 | @Override
28 | @Transactional
29 | public void run(String... args) throws Exception {
30 | MyEntity save = myEntityRepository.save(new MyEntity("name"));
31 | System.out.println("Saved [" + save + "]");
32 | MyEntity read = myEntityRepository.getById(save.getId());
33 | System.out.println("Read [" + read + "]");
34 | Assert.isTrue(save.getId().equals(read.getId()), "Entities should be the same");
35 | }
36 |
37 | }
38 |
39 | @Entity
40 | class MyEntity {
41 | @Id
42 | @GeneratedValue(strategy = GenerationType.AUTO)
43 | private Long id;
44 |
45 | private String name;
46 |
47 | public MyEntity() {
48 |
49 | }
50 |
51 | public MyEntity(String name) {
52 | this.name = name;
53 | }
54 |
55 | public Long getId() {
56 | return id;
57 | }
58 |
59 | public void setId(Long id) {
60 | this.id = id;
61 | }
62 |
63 | public String getName() {
64 | return name;
65 | }
66 |
67 | public void setName(String name) {
68 | this.name = name;
69 | }
70 |
71 | @Override
72 | public String toString() {
73 | return "MyEntity{" +
74 | "id=" + id +
75 | ", name='" + name + '\'' +
76 | '}';
77 | }
78 | }
79 |
80 | @Repository
81 | interface MyEntityRepository extends JpaRepository {
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/week1/part1/spring-data/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | management.endpoints.web.exposure.include=*
2 | server.port=4321
3 |
--------------------------------------------------------------------------------
/week1/part1/spring-data/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week1/part2/demo-week1-part2/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/http/part1-week2.http:
--------------------------------------------------------------------------------
1 | # Send 3 requests - should return default values and no logging
2 | GET localhost:7654/refreshed
3 |
4 | ###
5 | GET localhost:7654/nonrefreshed
6 |
7 | ###
8 | GET localhost:7654/configprop
9 |
10 |
11 | # Change the contents of the file and make the 3 calls again - nothing changes
12 |
13 | ###
14 |
15 | # Call refresh and try again
16 | POST localhost:7654/actuator/refresh
17 |
18 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | demo-week1-part2
13 | 0.0.1-SNAPSHOT
14 | demo-week1-part2
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-web
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-actuator
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | ${spring-cloud.version}
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.beans.factory.annotation.Value;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.boot.context.properties.ConfigurationProperties;
9 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
10 | import org.springframework.cloud.context.config.annotation.RefreshScope;
11 | import org.springframework.stereotype.Service;
12 | import org.springframework.web.bind.annotation.GetMapping;
13 | import org.springframework.web.bind.annotation.RestController;
14 |
15 | @SpringBootApplication
16 | @EnableConfigurationProperties(MyConfigProp.class)
17 | public class DemoApplication {
18 |
19 | public static void main(String[] args) {
20 | SpringApplication.run(DemoApplication.class, args);
21 | }
22 |
23 | }
24 |
25 | @RestController
26 | class TestController {
27 |
28 | private final RefreshedService refreshedService;
29 |
30 | private final NonRefreshedService nonRefreshedService;
31 |
32 | private final MyConfigPropService myConfigPropService;
33 |
34 | TestController(RefreshedService refreshedService, NonRefreshedService nonRefreshedService, MyConfigPropService myConfigPropService) {
35 | this.refreshedService = refreshedService;
36 | this.nonRefreshedService = nonRefreshedService;
37 | this.myConfigPropService = myConfigPropService;
38 | }
39 |
40 | @GetMapping("/refreshed")
41 | String refreshedService() {
42 | return refreshedService.test();
43 | }
44 |
45 | @GetMapping("/nonrefreshed")
46 | String nonRefreshedService() {
47 | return nonRefreshedService.test();
48 | }
49 |
50 | @GetMapping("/configprop")
51 | String myConfigPropService() {
52 | return myConfigPropService.test();
53 | }
54 | }
55 |
56 | @RefreshScope
57 | @Service
58 | class RefreshedService {
59 |
60 | private static final Logger log =
61 | LoggerFactory.getLogger(RefreshedService.class);
62 |
63 | private final String test;
64 |
65 | RefreshedService(@Value("${a:test}") String test) {
66 | this.test = test;
67 | }
68 |
69 | String test() {
70 | log.debug("Hello from refresh scope");
71 | return test;
72 | }
73 | }
74 |
75 | @Service
76 | class NonRefreshedService {
77 |
78 | private static final Logger log = LoggerFactory.getLogger(NonRefreshedService.class);
79 |
80 | private final String test;
81 |
82 | NonRefreshedService(@Value("${a:test}") String test) {
83 | this.test = test;
84 | }
85 |
86 | String test() {
87 | log.info("Hello from service");
88 | return test;
89 | }
90 |
91 | }
92 |
93 | @Service
94 | class MyConfigPropService {
95 | private static final Logger log = LoggerFactory.getLogger(MyConfigPropService.class);
96 |
97 | private final MyConfigProp myConfigProp;
98 |
99 | MyConfigPropService(MyConfigProp myConfigProp) {
100 | this.myConfigProp = myConfigProp;
101 | }
102 |
103 | String test() {
104 | log.warn("Hello from config properties");
105 | return myConfigProp.getProperty();
106 | }
107 |
108 | }
109 |
110 | @ConfigurationProperties("config")
111 | class MyConfigProp {
112 | private String property = "default";
113 |
114 | public String getProperty() {
115 | return property;
116 | }
117 |
118 | public void setProperty(String property) {
119 | this.property = property;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/src/main/resources/application-foo.properties:
--------------------------------------------------------------------------------
1 | a=foobarbaz
2 | config.property=some value
3 | logging.level.com.example=DEBUG
4 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | management.endpoints.web.exposure.include=*
2 | logging.level.com.example=ERROR
3 |
--------------------------------------------------------------------------------
/week1/part2/demo-week1-part2/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.context.annotation.Primary;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | @SpringBootTest
12 | class DemoApplicationTests {
13 |
14 | @Test
15 | void contextLoads() {
16 | }
17 |
18 | }
19 |
20 | @Configuration(proxyBeanMethods = false)
21 | class Config {
22 |
23 | @Bean
24 | @Primary
25 | RestTemplate restTemplate() {
26 | return new RestTemplate();
27 | }
28 |
29 | @Bean
30 | @LoadBalanced
31 | RestTemplate loadBalancedRestTemplate() {
32 | return new RestTemplate();
33 | }
34 | }
35 |
36 | class MyClass {
37 |
38 | private final RestTemplate loadBalanced;
39 |
40 | private final RestTemplate nonLoadBalanced;
41 |
42 | MyClass(@LoadBalanced RestTemplate restTemplate,
43 | RestTemplate nonLoadBalanced) {
44 | this.loadBalanced = restTemplate;
45 | this.nonLoadBalanced = nonLoadBalanced;
46 | }
47 |
48 | void foo() {
49 | this.loadBalanced.delete(null);
50 | this.nonLoadBalanced.delete(null);
51 | }
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/week1/part2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week1
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week1-part2
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | demo-week1-part2
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/week1/part3/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | vault-server:
4 | image: hashicorp/vault:latest
5 | ports:
6 | - "8200:8200"
7 | environment:
8 | VAULT_ADDR: "http://0.0.0.0:8200"
9 | VAULT_DEV_ROOT_TOKEN_ID: "vault-plaintext-root-token"
10 |
--------------------------------------------------------------------------------
/week1/part3/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:8888/bar-foo.properties -H "X-Config-Token: vault-plaintext-root-token"
2 | GET localhost:8888/bar-foo.properties
3 | X-Config-Token: vault-plaintext-root-token
4 |
5 | ###
6 |
7 | # curl localhost:7654/refreshed
8 | GET localhost:7654/refreshed
9 |
10 | ###
11 |
12 | # curl localhost:7654/configprop
13 | GET localhost:7654/configprop
14 |
15 | ###
16 |
17 | # curl localhost:7654/encrypted
18 | GET localhost:7654/encrypted
19 |
20 |
21 | ###
22 |
23 |
24 | # Call refresh and try again
25 | POST localhost:7654/actuator/refresh
26 |
--------------------------------------------------------------------------------
/week1/part3/http/encryption.http:
--------------------------------------------------------------------------------
1 | # curl localhost:8888/encrypt -d "my secret"
2 | POST localhost:8888/encrypt
3 | Content-Type: application/x-www-form-urlencoded
4 |
5 | my secret
6 |
7 | ###
8 |
9 | # curl localhost:8888/decrypt -d "3b0b19f0dfeb65f16c25733557448eae53e30e9b2bdafcff191617683ac674b5"
10 | POST localhost:8888/decrypt
11 | Content-Type: application/x-www-form-urlencoded
12 |
13 | 3b0b19f0dfeb65f16c25733557448eae53e30e9b2bdafcff191617683ac674b5
14 |
--------------------------------------------------------------------------------
/week1/part3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week1
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week1-part3
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | spring-cloud-config-client
33 | spring-cloud-config-server
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/week1/part3/scripts/script.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o errtrace
5 | set -o nounset
6 | set -o pipefail
7 |
8 | echo "Add entries to vault"
9 | export VAULT_ADDR='http://127.0.0.1:8200'
10 | export VAULT_TOKEN='vault-plaintext-root-token'
11 |
12 | echo "Adding a property for all applications (same as application.yml)"
13 | vault kv put secret/application only.in.vault="Hello"
14 |
15 | echo "Adding a property for app bar with profile foo"
16 | vault kv put secret/bar,foo a="bar with foo profile value from Vault"
17 |
18 | echo "Reading the properties back"
19 | vault kv get secret/application
20 | vault kv get secret/bar,foo
21 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week1/part3/spring-cloud-config-client/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | vault-server:
4 | image: hashicorp/vault:latest
5 | ports:
6 | - "8200:8200"
7 | environment:
8 | VAULT_ADDR: "http://0.0.0.0:8200"
9 | VAULT_DEV_ROOT_TOKEN_ID: "vault-plaintext-root-token"
10 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | config-client-scratch
13 | 0.0.1-SNAPSHOT
14 | config-client-scratch
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-config
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | ${spring-cloud.version}
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | management.endpoints.web.exposure.include=*
2 | # [Vault] token
3 | spring.cloud.config.token=vault-plaintext-root-token
4 | # [Config client]
5 | spring.application.name=bar
6 | spring.config.import=optional:configserver:
7 | # [Let's fix the port]
8 | server.port=7654
9 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-client/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week1/part3/spring-cloud-config-server/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | vault-server:
4 | image: hashicorp/vault:latest
5 | ports:
6 | - "8200:8200"
7 | environment:
8 | VAULT_ADDR: "http://0.0.0.0:8200"
9 | VAULT_DEV_ROOT_TOKEN_ID: "vault-plaintext-root-token"
10 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | config-server-2
13 | 0.0.1-SNAPSHOT
14 | config-server
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.cloud
23 | spring-cloud-config-server
24 |
25 |
26 | org.springframework.cloud
27 | spring-cloud-starter-vault-config
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-test
33 | test
34 |
35 |
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-dependencies
41 | ${spring-cloud.version}
42 | pom
43 | import
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-maven-plugin
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @SpringBootApplication
8 | @EnableConfigServer
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 |
15 | }
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | vault:
4 | # [Vault] token
5 | token: vault-plaintext-root-token
6 | config:
7 | server:
8 | composite:
9 | - type: vault
10 | # [Vault] Key Value version 2
11 | kv-version: 2
12 | order: 1
13 | - type: git
14 | # [Git] Use your fork
15 | uri: https://github.com/marcingrzejszczak/config-server-properties
16 | order: 2
17 | profiles:
18 | # [Vault & git]
19 | active: composite
20 |
21 | # [Config server] default port
22 | server.port: 8888
23 |
24 | # [Config server] For Encryption
25 | encrypt.key: "Secret Key"
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/week1/part3/spring-cloud-config-server/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week1/part4/boot-k8s/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | vault-server:
4 | image: hashicorp/vault:latest
5 | ports:
6 | - "8200:8200"
7 | environment:
8 | VAULT_ADDR: "http://0.0.0.0:8200"
9 | VAULT_DEV_ROOT_TOKEN_ID: "vault-plaintext-root-token"
10 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/k8s/config-map-changed.yml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: config-map-demo
5 | data:
6 | a: a value from config REFRESHED
7 | config.property: value for config prop from kubernetes REFRESHED
8 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/k8s/config-map-refresh.yml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: config-map-demo
5 | labels:
6 | "spring.cloud.kubernetes.config": "true"
7 | data:
8 | a: a value from config
9 | config.property: value for config prop from kubernetes
10 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/k8s/config-map.yml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: config-map-demo
5 | data:
6 | a: a value from config
7 | config.property: value for config prop from kubernetes
8 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/k8s/deployment.yml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | labels:
5 | app: config-client
6 | name: config-client
7 | spec:
8 | replicas: 1
9 | selector:
10 | matchLabels:
11 | app: config-client
12 | template:
13 | metadata:
14 | labels:
15 | app: config-client
16 | spec:
17 | containers:
18 | # Change the thing below to your registry etc. localhost:5000 points to local registry for kind
19 | # - image: docker.io/library/config-client
20 | - image: localhost:5000/config-client:latest
21 | name: config-client
22 | volumeMounts:
23 | - name: application-config
24 | readOnly: true
25 | mountPath: "/etc/config/default/"
26 | - name: secret-volume
27 | readOnly: true
28 | mountPath: "/etc/config/secret/"
29 | readinessProbe:
30 | httpGet:
31 | port: 7654
32 | path: /actuator/health/readiness
33 | livenessProbe:
34 | httpGet:
35 | port: 7654
36 | path: /actuator/health/liveness
37 | volumes:
38 | - name: application-config
39 | configMap:
40 | name: config-map-demo
41 | - name: secret-volume
42 | secret:
43 | secretName: config-client-secret
44 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/k8s/kind-with-registry.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -o errexit
3 |
4 | # create registry container unless it already exists
5 | reg_name='kind-registry'
6 | reg_port='5000'
7 | if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
8 | docker run \
9 | -d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \
10 | registry:2
11 | fi
12 |
13 | # create a cluster with the local registry enabled in containerd
14 | cat <
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | boot-config-client
13 | 0.0.1-SNAPSHOT
14 | config-server
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | ${spring-cloud.version}
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | management.endpoints.web.exposure.include=*
2 | # [Vault] token
3 | #spring.cloud.config.token=vault-plaintext-root-token
4 | # [Config client]
5 | spring.application.name=bar
6 | spring.config.import=optional:configtree:/etc/config/*/
7 | # [Let's fix the port]
8 | server.port=7654
9 |
--------------------------------------------------------------------------------
/week1/part4/boot-k8s/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week1/part4/buildpacks/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week1/part4/buildpacks/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week1/part4/buildpacks/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week1/part4/buildpacks/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week1/part4/buildpacks/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | buildpacks
13 | 0.0.1-SNAPSHOT
14 | buildpacks
15 | Demo project for Spring Boot
16 |
17 | 17
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-test
28 | test
29 |
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-maven-plugin
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/week1/part4/buildpacks/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DemoApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DemoApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week1/part4/buildpacks/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/week1/part4/buildpacks/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week1/part4/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week1
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week1-part4
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | boot-k8s
33 | buildpacks
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/week1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week1
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | part1
33 | part2
34 | part3
35 | part4
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/week2/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 | services:
3 | consul:
4 | image: progrium/consul
5 | extra_hosts: ['host.docker.internal:host-gateway']
6 | command: -server -bootstrap
7 | ports:
8 | - 8400:8400
9 | - 8500:8500
10 | - 8600:8600
11 |
12 | rabbitmq:
13 | image: rabbitmq:management
14 | ports:
15 | - 5672:5672
16 | - 15672:15672
17 |
18 | # https://developer.confluent.io/quickstart/kafka-docker/
19 | zookeeper:
20 | image: confluentinc/cp-zookeeper:6.2.0
21 | extra_hosts: ['host.docker.internal:host-gateway']
22 | environment:
23 | ZOOKEEPER_CLIENT_PORT: 2181
24 | ZOOKEEPER_TICK_TIME: 2000
25 |
26 | broker:
27 | image: confluentinc/cp-kafka:6.2.0
28 | extra_hosts: ['host.docker.internal:host-gateway']
29 | ports:
30 | # To learn about configuring Kafka for access across networks see
31 | # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
32 | - "9092:9092"
33 | depends_on:
34 | - zookeeper
35 | environment:
36 | KAFKA_BROKER_ID: 1
37 | KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
38 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
39 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
40 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
41 | KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
42 | KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
43 |
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part1/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-load-balancer
13 | 0.0.1-SNAPSHOT
14 | Fraud Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | ${spring-cloud.version}
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import org.springframework.beans.factory.annotation.Value;
7 | import org.springframework.boot.SpringApplication;
8 | import org.springframework.boot.autoconfigure.SpringBootApplication;
9 | import org.springframework.web.bind.annotation.GetMapping;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | @SpringBootApplication
13 | public class FraudDetectionApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(FraudDetectionApplication.class, args);
17 | }
18 |
19 | }
20 |
21 | @RestController
22 | class FraudDetectionController {
23 |
24 | private final int port;
25 |
26 | FraudDetectionController(@Value("${server.port}") int port) {
27 | this.port = port;
28 | }
29 |
30 | @GetMapping("/frauds")
31 | List frauds() {
32 | System.out.println("\n\nGot fraud request, my port [" + port + "] \n\n");
33 | return Arrays.asList("josh", "marcin");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | management.endpoints.web.exposure.include=*
3 | spring.application.name=frauddetection
4 |
--------------------------------------------------------------------------------
/week2/part1/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class FraudDetectionApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part1/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9081/resttemplate
2 | GET localhost:9081/resttemplate
3 |
4 | ###
5 |
6 | # curl localhost:9081/feign
7 | GET localhost:9081/feign
8 |
9 | ###
10 |
11 | # curl localhost:9081/declarative
12 | GET localhost:9081/declarative
13 |
14 | ###
15 |
--------------------------------------------------------------------------------
/week2/part1/loanissuance-loadbalancer/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part1/loanissuance-loadbalancer/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part1/loanissuance-loadbalancer/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part1/loanissuance-loadbalancer/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part1/loanissuance-loadbalancer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-loadbalancer
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-webflux
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-consul-discovery
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-openfeign
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-starter-test
49 | test
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-dependencies
57 | ${spring-cloud.version}
58 | pom
59 | import
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-maven-plugin
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/week2/part1/loanissuance-loadbalancer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | management.endpoints.web.exposure.include=*
3 | logging.level.com.example=ERROR
4 |
5 | spring.application.name=loanissuance
6 |
--------------------------------------------------------------------------------
/week2/part1/loanissuance-loadbalancer/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.context.annotation.Primary;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | @SpringBootTest
12 | class LoanIssuanceApplicationTests {
13 |
14 | @Test
15 | void contextLoads() {
16 | }
17 |
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/week2/part1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week2
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week2-part1
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 | loanissuance-loadbalancer
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-reactive/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-reactive/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part2/circuit-breaker-reactive/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-reactive/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-reactive/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-circuit-breaker-reactive
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-webflux
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-loadbalancer
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-circuitbreaker-reactor-resilience4j
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | ${spring-cloud.version}
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-reactive/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | spring.application.name=loanissuance
3 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-reactive/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class LoanIssuanceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-retry/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-retry/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part2/circuit-breaker-retry/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-retry/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-retry/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-circuit-breaker-retry
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-webflux
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-consul-discovery
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-openfeign
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-circuitbreaker-spring-retry
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-starter-test
55 | test
56 |
57 |
58 |
59 |
60 |
61 | org.springframework.cloud
62 | spring-cloud-dependencies
63 | ${spring-cloud.version}
64 | pom
65 | import
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.springframework.boot
74 | spring-boot-maven-plugin
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-retry/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | spring.application.name=loanissuance
3 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker-retry/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class LoanIssuanceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part2/circuit-breaker/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-circuit-breaker
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-webflux
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-consul-discovery
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-openfeign
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-circuitbreaker-resilience4j
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-starter-test
55 | test
56 |
57 |
58 |
59 |
60 |
61 | org.springframework.cloud
62 | spring-cloud-dependencies
63 | ${spring-cloud.version}
64 | pom
65 | import
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.springframework.boot
74 | spring-boot-maven-plugin
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | spring.application.name=loanissuance
3 |
--------------------------------------------------------------------------------
/week2/part2/circuit-breaker/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class LoanIssuanceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part2/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-simple
13 | 0.0.1-SNAPSHOT
14 | Fraud Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-dependencies
45 | ${spring-cloud.version}
46 | pom
47 | import
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @SpringBootApplication
12 | public class FraudDetectionApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(FraudDetectionApplication.class, args);
16 | }
17 |
18 | }
19 |
20 | @RestController
21 | class FraudDetectionController {
22 | @GetMapping("/frauds")
23 | List frauds() {
24 | System.out.println("\n\nGot fraud request\n\n");
25 | return Arrays.asList("josh", "marcin");
26 | }
27 | }
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 |
--------------------------------------------------------------------------------
/week2/part2/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class FraudDetectionApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part2/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9081/resttemplate
2 | GET localhost:9081/resttemplate
3 |
4 | ###
5 |
6 | # curl localhost:9081/resttemplatewithwrongurl
7 | GET localhost:9081/resttemplatewithwrongurl
8 |
9 | ###
10 |
11 | # curl localhost:9081/resttemplatewithfallback
12 | GET localhost:9081/resttemplatewithfallback
13 |
14 | ### WEBCLIENT
15 |
16 | # curl localhost:9081/webclient
17 | GET localhost:9081/webclient
18 |
19 | ###
20 |
21 | # curl localhost:9081/webclientwithwrongurl
22 | GET localhost:9081/webclientwithwrongurl
23 |
24 | ###
25 |
26 | # curl localhost:9081/webclientwithfallback
27 | GET localhost:9081/webclientwithfallback
28 |
29 |
--------------------------------------------------------------------------------
/week2/part2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week2
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week2-part2
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | circuit-breaker
33 | circuit-breaker-reactive
34 | circuit-breaker-retry
35 | fraud-detection
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/week2/part3/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 | services:
3 | consul:
4 | image: progrium/consul
5 | extra_hosts: ['host.docker.internal:host-gateway']
6 | command: -server -bootstrap
7 | ports:
8 | - 8400:8400
9 | - 8500:8500
10 | - 8600:8600
11 |
12 | rabbitmq:
13 | image: rabbitmq:management
14 | extra_hosts: ['host.docker.internal:host-gateway']
15 | ports:
16 | - 5672:5672
17 | - 15672:15672
18 |
19 | # https://developer.confluent.io/quickstart/kafka-docker/
20 | zookeeper:
21 | image: confluentinc/cp-zookeeper:6.2.0
22 | extra_hosts: ['host.docker.internal:host-gateway']
23 | environment:
24 | ZOOKEEPER_CLIENT_PORT: 2181
25 | ZOOKEEPER_TICK_TIME: 2000
26 |
27 | broker:
28 | image: confluentinc/cp-kafka:6.2.0
29 | extra_hosts: ['host.docker.internal:host-gateway']
30 | ports:
31 | # To learn about configuring Kafka for access across networks see
32 | # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
33 | - "9092:9092"
34 | depends_on:
35 | - zookeeper
36 | environment:
37 | KAFKA_BROKER_ID: 1
38 | KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
39 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
40 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
41 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
42 | KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
43 | KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
44 |
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part3/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-stream
13 | 0.0.1-SNAPSHOT
14 | Fraud Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-starter-stream-rabbit
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-stream-kafka
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-starter-test
49 | test
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-dependencies
57 | ${spring-cloud.version}
58 | pom
59 | import
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-maven-plugin
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 | import java.util.function.Consumer;
6 |
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 | import org.springframework.boot.SpringApplication;
11 | import org.springframework.boot.autoconfigure.SpringBootApplication;
12 | import org.springframework.context.annotation.Bean;
13 | import org.springframework.web.bind.annotation.GetMapping;
14 | import org.springframework.web.bind.annotation.RestController;
15 |
16 | @SpringBootApplication
17 | public class FraudDetectionApplication {
18 | private static final Logger log = LoggerFactory.getLogger(FraudDetectionApplication.class);
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(FraudDetectionApplication.class, args);
22 | }
23 |
24 | @Bean
25 | Consumer frauds() {
26 | return s -> log.info("Got a message with body [{}]", s);
27 | }
28 |
29 | }
30 |
31 | @RestController
32 | class FraudDetectionController {
33 | @GetMapping("/frauds")
34 | List frauds() {
35 | System.out.println("\n\nGot fraud request\n\n");
36 | return Arrays.asList("josh", "marcin");
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 |
4 | spring.cloud.function.definition=frauds
5 | spring.cloud.stream.default-binder=rabbit
6 | spring.cloud.stream.bindings.frauds-in-0.destination=frauds
7 | logging.level.org.springframework.boot.actuate.amqp=ERROR
8 |
9 |
--------------------------------------------------------------------------------
/week2/part3/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class FraudDetectionApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part3/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9081/stream -d 'TEST' -H content-type:application/json -v
2 | POST localhost:9081/stream
3 | Content-Type: application/json
4 |
5 | TEST
6 |
7 | ###
8 |
9 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream-reactive/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream-reactive/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part3/loan-issuance-stream-reactive/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream-reactive/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream-reactive/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-stream-reactive
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-webflux
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-loadbalancer
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-circuitbreaker-reactor-resilience4j
40 |
41 |
42 |
43 | org.springframework.cloud
44 | spring-cloud-starter-stream-rabbit
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-stream-kafka
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-starter-test
55 | test
56 |
57 |
58 |
59 |
60 |
61 | org.springframework.cloud
62 | spring-cloud-dependencies
63 | ${spring-cloud.version}
64 | pom
65 | import
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.springframework.boot
74 | spring-boot-maven-plugin
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream-reactive/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | spring.application.name=loanissuance
3 |
4 | # For functional beans
5 | spring.cloud.function.definition=fraudsFunction;fraudsSupplier
6 |
7 | spring.cloud.stream.default-binder=rabbit
8 |
9 | spring.cloud.stream.poller.fixedDelay=3000
10 |
11 | # For Stream Bridge
12 | spring.cloud.stream.output-bindings=fraudsFromStreamBridge
13 | spring.cloud.stream.bindings.fraudsFromStreamBridge-out-0.destination=fraudsFunctionInput
14 | spring.cloud.stream.bindings.fraudsFunction-in-0.destination=fraudsFunctionInput
15 | spring.cloud.stream.bindings.fraudsFunction-out-0.destination=frauds
16 | spring.cloud.stream.bindings.fraudsSupplier-out-0.destination=frauds
17 |
18 | logging.level.org.springframework.boot.actuate.amqp=ERROR
19 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream-reactive/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class LoanIssuanceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part3/loan-issuance-stream/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-stream
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-webflux
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-consul-discovery
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-openfeign
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-circuitbreaker-resilience4j
50 |
51 |
52 |
53 | org.springframework.cloud
54 | spring-cloud-starter-stream-rabbit
55 |
56 |
57 |
58 | org.springframework.cloud
59 | spring-cloud-starter-stream-kafka
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-starter-test
65 | test
66 |
67 |
68 |
69 |
70 |
71 | org.springframework.cloud
72 | spring-cloud-dependencies
73 | ${spring-cloud.version}
74 | pom
75 | import
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | org.springframework.boot
84 | spring-boot-maven-plugin
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | spring.application.name=loanissuance
3 |
4 | # For functional beans
5 | spring.cloud.function.definition=fraudsFunction;fraudsSupplier
6 |
7 | spring.cloud.stream.default-binder=rabbit
8 |
9 | spring.cloud.stream.poller.fixedDelay=3000
10 |
11 | # For Stream Bridge
12 | spring.cloud.stream.output-bindings=fraudsFromStreamBridge
13 | spring.cloud.stream.bindings.fraudsFromStreamBridge-out-0.destination=fraudsFunctionInput
14 | spring.cloud.stream.bindings.fraudsFunction-in-0.destination=fraudsFunctionInput
15 | spring.cloud.stream.bindings.fraudsFunction-out-0.destination=frauds
16 | spring.cloud.stream.bindings.fraudsSupplier-out-0.destination=frauds
17 |
18 |
19 | logging.level.org.springframework.boot.actuate.amqp=ERROR
20 |
--------------------------------------------------------------------------------
/week2/part3/loan-issuance-stream/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class LoanIssuanceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week2
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week2-part3
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 | loan-issuance-stream
34 | loan-issuance-stream-reactive
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/week2/part4/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 | services:
3 | httpbin:
4 | image: kennethreitz/httpbin
5 | ports:
6 | - 12345:80
7 |
8 | consul:
9 | image: progrium/consul
10 | command: -server -bootstrap
11 | ports:
12 | - 8400:8400
13 | - 8500:8500
14 | - 8600:8600
15 |
16 | rabbitmq:
17 | image: rabbitmq:management
18 | ports:
19 | - 5672:5672
20 | - 15672:15672
21 |
22 | # https://developer.confluent.io/quickstart/kafka-docker/
23 | zookeeper:
24 | image: confluentinc/cp-zookeeper:6.2.0
25 | environment:
26 | ZOOKEEPER_CLIENT_PORT: 2181
27 | ZOOKEEPER_TICK_TIME: 2000
28 |
29 | broker:
30 | image: confluentinc/cp-kafka:6.2.0
31 | ports:
32 | # To learn about configuring Kafka for access across networks see
33 | # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
34 | - "9092:9092"
35 | depends_on:
36 | - zookeeper
37 | environment:
38 | KAFKA_BROKER_ID: 1
39 | KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
40 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
41 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
42 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
43 | KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
44 | KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
45 |
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part4/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-gateway
13 | 0.0.1-SNAPSHOT
14 | Fraud Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-starter-stream-rabbit
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-stream-kafka
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-starter-test
49 | test
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-dependencies
57 | ${spring-cloud.version}
58 | pom
59 | import
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-maven-plugin
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 | import java.util.function.Consumer;
6 |
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 | import org.springframework.boot.SpringApplication;
11 | import org.springframework.boot.autoconfigure.SpringBootApplication;
12 | import org.springframework.context.annotation.Bean;
13 | import org.springframework.web.bind.annotation.GetMapping;
14 | import org.springframework.web.bind.annotation.RestController;
15 |
16 | @SpringBootApplication
17 | public class FraudDetectionApplication {
18 | private static final Logger log = LoggerFactory.getLogger(FraudDetectionApplication.class);
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(FraudDetectionApplication.class, args);
22 | }
23 |
24 | @Bean
25 | Consumer frauds() {
26 | return s -> log.info("Got a message with body [{}]", s);
27 | }
28 |
29 | }
30 |
31 | @RestController
32 | class FraudDetectionController {
33 | @GetMapping("/frauds")
34 | List frauds() {
35 | System.out.println("\n\nGot fraud request\n\n");
36 | return Arrays.asList("josh", "marcin");
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 |
4 | spring.cloud.function.definition=frauds
5 | spring.cloud.stream.default-binder=kafka
6 | spring.cloud.stream.bindings.frauds-in-0.destination=frauds
7 |
8 |
--------------------------------------------------------------------------------
/week2/part4/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class FraudDetectionApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part4/gateway-mvc/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | gateway-mvc
13 | 0.0.1-SNAPSHOT
14 | Gateway Mvc
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.cloud
27 | spring-cloud-starter-circuitbreaker-resilience4j
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-gateway-mvc
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | ${spring-cloud.version}
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/src/main/java/com/example/gateway/GatewayApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.gateway;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.gateway.server.mvc.filter.CircuitBreakerFilterFunctions;
6 | import org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions;
7 | import org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions;
8 | import org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.web.servlet.function.RouterFunction;
11 | import org.springframework.web.servlet.function.ServerResponse;
12 |
13 | import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;
14 |
15 | /*
16 | SCENARIOS:
17 |
18 | (PREDICATE)
19 | When a cookie called [spring] with value [cloud] is set
20 | Under gateway/httpbin/ endpoint
21 | Call https://httpbin.org/headers
22 | (Filter)
23 | StripPrefix 1
24 | Add a response header ([X-Spring-Cloud] with value [Workshops Response])
25 | Circuit breaker
26 | Set status 201
27 |
28 | curl -v localhost:6543/httpbin/headers --cookie "spring=cloud"
29 |
30 | */
31 | @SpringBootApplication
32 | public class GatewayApplication {
33 |
34 | public static void main(String[] args) {
35 | SpringApplication.run(GatewayApplication.class, args);
36 | }
37 |
38 | // @formatter:off
39 | @Bean
40 | public RouterFunction httpBin() {
41 | return GatewayRouterFunctions.route("httpbin_route")
42 | .route(
43 | GatewayRequestPredicates.path("/httpbin/**")
44 | .and(GatewayRequestPredicates.cookie("spring", "cloud")), http("http://localhost:12345"))
45 | .filter(FilterFunctions.stripPrefix(1)
46 | .andThen(CircuitBreakerFilterFunctions.circuitBreaker("httpBinCircuitBreaker"))
47 | .andThen(FilterFunctions.addResponseHeader("X-Spring-Cloud", "Workshops Response"))
48 | .andThen(FilterFunctions.setStatus(201)))
49 | .build();
50 | }
51 | // @formatter:on
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | # Route only when header X-OperationType: Fraud
2 | # Route only for GET
3 | # Route when URL is gateway/check/account
4 | # StripPrefix 1
5 | # (LB filter, RewritePath)
6 | # Call fraud detection over the service discovery to the original endpoint (i.e. account in Loan Issuance)
7 | # (Filter)
8 | # Create a router with circuit breaker with fallback on 404 to /resttemplate in Loan Issuance
9 | # TIP: You have to create a fallback route in the gateway that will redirect the call to Loan Issuance
10 | # in Consul + will set the path to /resttemplate
11 |
12 | # curl localhost:6543/check/account -H "X-Operation-Type: Fraud"
13 | spring:
14 | cloud:
15 | gateway:
16 | mvc:
17 | routes:
18 | - id: fraud
19 | uri: lb://loanissuance/
20 | predicates:
21 | - Header=X-Operation-Type, Fraud
22 | - Method=GET
23 | - Path=/check/account
24 | filters:
25 | - StripPrefix=1
26 | # TODO: Bug in the gateway
27 | - name: CircuitBreaker
28 | args:
29 | id: loanIssuanceCircuitBreaker
30 | fallbackUri: forward:/fallback
31 | statusCodes:
32 | - 404
33 | - id: loanissuance-fallback
34 | uri: lb://loanissuance/
35 | predicates:
36 | - Path=/fallback
37 | filters:
38 | - SetPath=/resttemplate
39 | application:
40 | name: gateway # required for service discovery
41 |
42 | server.port: 6543
43 |
--------------------------------------------------------------------------------
/week2/part4/gateway-mvc/src/test/java/com/example/gateway/GatewayApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.gateway;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class GatewayApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part4/gateway/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part4/gateway/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part4/gateway/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part4/gateway/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part4/gateway/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | gateway
13 | 0.0.1-SNAPSHOT
14 | Gateway
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.cloud
27 | spring-cloud-starter-circuitbreaker-reactor-resilience4j
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-gateway
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | ${spring-cloud.version}
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/week2/part4/gateway/src/main/java/com/example/gateway/GatewayApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.gateway;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.gateway.route.RouteLocator;
6 | import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
7 | import org.springframework.context.annotation.Bean;
8 |
9 | /*
10 | SCENARIOS:
11 |
12 | (PREDICATE)
13 | When a cookie called [spring] with value [cloud] is set
14 | Under gateway/httpbin/ endpoint
15 | Call https://httpbin.org/headers
16 | (Filter)
17 | StripPrefix 1
18 | Add a response header ([X-Spring-Cloud] with value [Workshops Response])
19 | Circuit breaker
20 | Set status 201
21 |
22 | curl -v localhost:6543/httpbin/headers --cookie "spring=cloud"
23 |
24 | */
25 | @SpringBootApplication
26 | public class GatewayApplication {
27 |
28 | public static void main(String[] args) {
29 | SpringApplication.run(GatewayApplication.class, args);
30 | }
31 |
32 | // @formatter:off
33 | @Bean
34 | public RouteLocator routes(RouteLocatorBuilder builder) {
35 | return builder.routes()
36 | .route("httpbin_route", r ->
37 | r.cookie("spring", "cloud")
38 | .and()
39 | .path("/httpbin/**")
40 | .filters(f ->
41 | f.stripPrefix(1)
42 | .circuitBreaker(c -> c.setName("httpBinCircuitBreaker"))
43 | .addResponseHeader("X-Spring-Cloud", "Workshops Response")
44 | .setStatus(201))
45 | .uri("http://localhost:12345")).build();
46 | }
47 | // @formatter:on
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/week2/part4/gateway/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | # Route only when header X-OperationType: Fraud
2 | # Route only for GET
3 | # Route when URL is gateway/check/account
4 | # StripPrefix 1
5 | # (LB filter, RewritePath)
6 | # Call fraud detection over the service discovery to the original endpoint (i.e. account in Loan Issuance)
7 | # (Filter)
8 | # Create a router with circuit breaker with fallback on 404 to /resttemplate in Loan Issuance
9 | # TIP: You have to create a fallback route in the gateway that will redirect the call to Loan Issuance
10 | # in Consul + will set the path to /resttemplate
11 |
12 | # curl localhost:6543/check/account -H "X-Operation-Type: Fraud"
13 | spring:
14 | cloud:
15 | gateway:
16 | routes:
17 | - id: fraud
18 | uri: lb://loanissuance/
19 | predicates:
20 | - Header=X-Operation-Type, Fraud
21 | - Method=GET
22 | - Path=/check/account
23 | filters:
24 | - StripPrefix=1
25 | - name: CircuitBreaker
26 | args:
27 | name: loanIssuanceCircuitBreaker
28 | fallbackUri: forward:/fallback
29 | statusCodes:
30 | - 404
31 | - id: loanissuance-fallback
32 | uri: lb://loanissuance/
33 | predicates:
34 | - Path=/fallback
35 | filters:
36 | - SetPath=/resttemplate
37 | application:
38 | name: gateway # required for service discovery
39 |
40 | server.port: 6543
41 |
--------------------------------------------------------------------------------
/week2/part4/gateway/src/test/java/com/example/gateway/GatewayApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.gateway;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class GatewayApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part4/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl -v localhost:6543/httpbin/headers --cookie 'spring=cloud'
2 | GET localhost:6543/httpbin/headers
3 | Cookie: spring=cloud
4 |
5 | asd
6 |
7 | ###
8 |
9 | # curl localhost:6543/check/account -H 'X-Operation-Type: Fraud'
10 | GET localhost:6543/check/account
11 | X-Operation-Type: Fraud
12 |
13 | ###
14 |
15 |
--------------------------------------------------------------------------------
/week2/part4/loan-issuance-gateway/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week2/part4/loan-issuance-gateway/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week2/part4/loan-issuance-gateway/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week2/part4/loan-issuance-gateway/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week2/part4/loan-issuance-gateway/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-gateway
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-loadbalancer
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-openfeign
40 |
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-circuitbreaker-resilience4j
46 |
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-starter-stream-rabbit
51 |
52 |
53 |
54 | org.springframework.cloud
55 | spring-cloud-starter-stream-kafka
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-starter-test
61 | test
62 |
63 |
64 |
65 |
66 |
67 | org.springframework.cloud
68 | spring-cloud-dependencies
69 | ${spring-cloud.version}
70 | pom
71 | import
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | org.springframework.boot
80 | spring-boot-maven-plugin
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/week2/part4/loan-issuance-gateway/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | spring.application.name=loanissuance
3 |
4 | # For functional beans
5 | spring.cloud.function.definition=fraudsFunction;fraudsSupplier
6 |
7 | spring.cloud.stream.default-binder=kafka
8 |
9 | spring.cloud.stream.poller.fixedDelay=3000
10 |
11 | # For Stream Bridge
12 | spring.cloud.stream.output-bindings=fraudsFromStreamBridge
13 | spring.cloud.stream.bindings.fraudsFromStreamBridge-out-0.destination=fraudsFunctionInput
14 | spring.cloud.stream.bindings.fraudsFunction-in-0.destination=fraudsFunctionInput
15 | spring.cloud.stream.bindings.fraudsFunction-out-0.destination=frauds
16 | spring.cloud.stream.bindings.fraudsSupplier-out-0.destination=frauds
17 |
--------------------------------------------------------------------------------
/week2/part4/loan-issuance-gateway/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class LoanIssuanceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week2/part4/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week2
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week2-part4
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 | loan-issuance-gateway
34 | gateway
35 | gateway-mvc
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/week2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week2
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | part1
33 | part2
34 | part3
35 | part4
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/week3/part1/.gitignore:
--------------------------------------------------------------------------------
1 | docker
2 |
--------------------------------------------------------------------------------
/week3/part1/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 |
4 | consul:
5 | image: progrium/consul
6 | extra_hosts: ['host.docker.internal:host-gateway']
7 | command: -server -bootstrap
8 | ports:
9 | - 8400:8400
10 | - 8500:8500
11 | - 8600:8600
12 |
13 | prometheus:
14 | image: prom/prometheus
15 | extra_hosts: ['host.docker.internal:host-gateway']
16 | command:
17 | - --enable-feature=exemplar-storage
18 | - --config.file=/etc/prometheus/prometheus.yml
19 | volumes:
20 | - ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
21 | ports:
22 | - "9090:9090"
23 |
24 | grafana:
25 | image: grafana/grafana
26 | extra_hosts: ['host.docker.internal:host-gateway']
27 | volumes:
28 | - ./docker/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
29 | - ./docker/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
30 | environment:
31 | - GF_AUTH_ANONYMOUS_ENABLED=true
32 | - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
33 | - GF_AUTH_DISABLE_LOGIN_FORM=true
34 | ports:
35 | - "3000:3000"
36 | # Grafana creds: admin:admin
37 |
38 |
--------------------------------------------------------------------------------
/week3/part1/docker/grafana/provisioning/datasources/datasource.yml:
--------------------------------------------------------------------------------
1 | apiVersion: 1
2 |
3 | datasources:
4 | - name: Prometheus
5 | type: prometheus
6 | access: proxy
7 | url: http://prometheus:9090
8 | editable: false
9 | jsonData:
10 | httpMethod: POST
11 | exemplarTraceIdDestinations:
12 | - name: trace_id
13 | datasourceUid: tempo
14 | - name: Tempo
15 | type: tempo
16 | access: proxy
17 | orgId: 1
18 | url: http://tempo:3200
19 | basicAuth: false
20 | isDefault: true
21 | version: 1
22 | editable: false
23 | apiVersion: 1
24 | uid: tempo
25 | jsonData:
26 | httpMethod: GET
27 | tracesToLogs:
28 | datasourceUid: 'loki'
29 | - name: Loki
30 | type: loki
31 | uid: loki
32 | access: proxy
33 | orgId: 1
34 | url: http://loki:3100
35 | basicAuth: false
36 | isDefault: false
37 | version: 1
38 | editable: false
39 | apiVersion: 1
40 | jsonData:
41 | derivedFields:
42 | - datasourceUid: tempo
43 | matcherRegex: \[.+,(.+?),
44 | name: TraceID
45 | url: $${__value.raw}
46 |
--------------------------------------------------------------------------------
/week3/part1/docker/prometheus/prometheus.yml:
--------------------------------------------------------------------------------
1 | global:
2 | scrape_interval: 2s
3 | evaluation_interval: 2s
4 |
5 | scrape_configs:
6 | - job_name: 'prometheus'
7 | static_configs:
8 | - targets: ['host.docker.internal:9090']
9 | - job_name: 'test-app'
10 | # scheme: 'https'
11 | metrics_path: '/actuator/prometheus'
12 | static_configs:
13 | - targets: [ 'host.docker.internal:9080','host.docker.internal:9081','host.docker.internal:9082','host.docker.internal:9083','host.docker.internal:9084','host.docker.internal:9085','host.docker.internal:9086' ]
14 |
--------------------------------------------------------------------------------
/week3/part1/docker_backup/grafana/provisioning/dashboards/dashboard.yml:
--------------------------------------------------------------------------------
1 | apiVersion: 1
2 |
3 | providers:
4 | - name: dashboards
5 | type: file
6 | disableDeletion: true
7 | editable: true
8 | options:
9 | path: /etc/grafana/provisioning/dashboards
10 | foldersFromFilesStructure: true
11 |
--------------------------------------------------------------------------------
/week3/part1/docker_backup/grafana/provisioning/datasources/datasource.yml:
--------------------------------------------------------------------------------
1 | apiVersion: 1
2 |
3 | datasources:
4 | - name: Prometheus
5 | type: prometheus
6 | access: proxy
7 | url: http://host.docker.internal:9090
8 | editable: false
9 | jsonData:
10 | httpMethod: POST
11 | exemplarTraceIdDestinations:
12 | - name: trace_id
13 | datasourceUid: tempo
14 | - name: Tempo
15 | type: tempo
16 | access: proxy
17 | orgId: 1
18 | url: http://tempo:3200
19 | basicAuth: false
20 | isDefault: true
21 | version: 1
22 | editable: false
23 | apiVersion: 1
24 | uid: tempo
25 | jsonData:
26 | httpMethod: GET
27 | tracesToLogs:
28 | datasourceUid: 'loki'
29 | - name: Loki
30 | type: loki
31 | uid: loki
32 | access: proxy
33 | orgId: 1
34 | url: http://loki:3100
35 | basicAuth: false
36 | isDefault: false
37 | version: 1
38 | editable: false
39 | apiVersion: 1
40 | jsonData:
41 | derivedFields:
42 | - datasourceUid: tempo
43 | matcherRegex: \[.+,(.+?),
44 | name: TraceID
45 | url: $${__value.raw}
46 |
--------------------------------------------------------------------------------
/week3/part1/docker_backup/prometheus/prometheus.yml:
--------------------------------------------------------------------------------
1 | global:
2 | scrape_interval: 2s
3 | evaluation_interval: 2s
4 |
5 | scrape_configs:
6 | - job_name: 'prometheus'
7 | static_configs:
8 | - targets: ['host.docker.internal:9090']
9 | - job_name: 'test-app'
10 | # scheme: 'https'
11 | metrics_path: '/actuator/prometheus'
12 | static_configs:
13 | - targets: [ 'host.docker.internal:9080','host.docker.internal:9081','host.docker.internal:9082','host.docker.internal:9083','host.docker.internal:9084','host.docker.internal:9085','host.docker.internal:9086' ]
14 |
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part1/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-micrometer
13 | 0.0.1-SNAPSHOT
14 | Fraud-Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | io.micrometer
31 | micrometer-registry-prometheus
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-consul-discovery
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-starter-test
41 | test
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-dependencies
50 | ${spring-cloud.version}
51 | pom
52 | import
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-maven-plugin
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 | import java.util.Random;
6 | import java.util.concurrent.atomic.AtomicInteger;
7 |
8 | import io.micrometer.core.instrument.Counter;
9 | import io.micrometer.core.instrument.MeterRegistry;
10 | import io.micrometer.core.instrument.Timer;
11 |
12 | import org.springframework.boot.SpringApplication;
13 | import org.springframework.boot.autoconfigure.SpringBootApplication;
14 | import org.springframework.scheduling.annotation.EnableScheduling;
15 | import org.springframework.scheduling.annotation.Scheduled;
16 | import org.springframework.web.bind.annotation.GetMapping;
17 | import org.springframework.web.bind.annotation.RestController;
18 |
19 | @SpringBootApplication
20 | @EnableScheduling
21 | public class FraudDetectionApplication {
22 |
23 | public static void main(String[] args) {
24 | SpringApplication.run(FraudDetectionApplication.class, args);
25 | }
26 |
27 | }
28 |
29 | @RestController
30 | class FraudDetectionController {
31 |
32 | private final AtomicInteger gauge;
33 | private final Counter counter;
34 | private final Timer timer;
35 |
36 | FraudDetectionController(MeterRegistry meterRegistry) {
37 | this.gauge = meterRegistry.gauge("frauds_current", new AtomicInteger());
38 | this.counter = meterRegistry.counter("frauds_counter");
39 | this.timer = meterRegistry.timer("frauds_time");
40 | }
41 |
42 | @GetMapping("/frauds")
43 | List frauds() {
44 | return this.timer.record(() -> {
45 | System.out.println("\n\nGot fraud request\n\n");
46 | this.counter.increment();
47 | return Arrays.asList("josh", "marcin");
48 | });
49 | }
50 |
51 | @Scheduled(fixedRate = 1L)
52 | void changeGaugeValue() {
53 | this.gauge.set(new Random().nextInt(100) + 200);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 |
4 | management.endpoints.web.exposure.include=health,metrics,prometheus
5 |
--------------------------------------------------------------------------------
/week3/part1/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Random;
4 | import java.util.concurrent.atomic.AtomicInteger;
5 | import java.util.stream.Collectors;
6 | import java.util.stream.StreamSupport;
7 |
8 | import io.micrometer.core.instrument.Counter;
9 | import io.micrometer.core.instrument.DistributionSummary;
10 | import io.micrometer.core.instrument.LongTaskTimer;
11 | import io.micrometer.core.instrument.Measurement;
12 | import io.micrometer.core.instrument.MeterRegistry;
13 | import io.micrometer.core.instrument.Timer;
14 | import org.junit.jupiter.api.Test;
15 |
16 | import org.springframework.beans.factory.annotation.Autowired;
17 | import org.springframework.boot.test.context.SpringBootTest;
18 | import org.springframework.scheduling.annotation.EnableScheduling;
19 | import org.springframework.scheduling.annotation.Scheduled;
20 |
21 | @SpringBootTest
22 | class FraudDetectionApplicationTests {
23 |
24 | @Autowired MeterRegistry meterRegistry;
25 |
26 | @Test
27 | void contextLoads() {
28 | new TimerDemo(meterRegistry).timer();
29 | new CounterDemo(meterRegistry).counter();
30 | new GaugeDemo(meterRegistry).gauge();
31 |
32 | System.out.println(meterRegistry.getMeters().stream().filter(meter -> meter.getId().getName().contains("example")).map(meter -> "Meter <" + meter.getId().getName() + "> with type <" + meter.getId().getType() + "> has measurements \n\t" + StreamSupport.stream(meter.measure().spliterator(), false).map(Measurement::toString).collect(Collectors.joining("\n\t"))).collect(Collectors.joining("\n")));
33 | }
34 |
35 | }
36 |
37 | class TimerDemo {
38 |
39 | private final MeterRegistry meterRegistry;
40 |
41 | TimerDemo(MeterRegistry meterRegistry) {
42 | this.meterRegistry = meterRegistry;
43 | }
44 |
45 | void timer() {
46 | Timer.Sample sample = Timer.start(meterRegistry);
47 | // sth to measure
48 | sample.stop(Timer.builder("timer.example")
49 | .tag("region", "west")
50 | .register(meterRegistry));
51 | }
52 | }
53 |
54 | class CounterDemo {
55 |
56 | private final Counter counter;
57 |
58 | CounterDemo(MeterRegistry meterRegistry) {
59 | this.counter = meterRegistry
60 | .counter("counter.example");
61 | }
62 |
63 | void counter() {
64 | counter.increment();
65 | }
66 | }
67 |
68 | class GaugeDemo {
69 |
70 | private final AtomicInteger gauge;
71 |
72 | GaugeDemo(MeterRegistry meterRegistry) {
73 | this.gauge = meterRegistry
74 | .gauge("gauge.example", new AtomicInteger());
75 | }
76 |
77 | @Scheduled(fixedRate = 1L)
78 | void gauge() {
79 | this.gauge.set(new Random().nextInt());
80 | }
81 |
82 | @EnableScheduling
83 | static class Config {
84 |
85 | }
86 | }
87 |
88 |
--------------------------------------------------------------------------------
/week3/part1/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9080/frauds
2 | GET localhost:9080/frauds
3 |
4 | ###
5 |
6 | # curl localhost:9080/actuator/metrics/frauds_counter
7 | GET localhost:9080/actuator/metrics/frauds_counter
8 |
9 | ###
10 |
11 | # curl localhost:9080/actuator/metrics/frauds_current
12 | GET localhost:9080/actuator/metrics/frauds_current
13 |
14 | ###
15 |
16 | # curl localhost:9080/actuator/metrics/frauds_time
17 | GET localhost:9080/actuator/metrics/frauds_time
18 |
19 | ###
20 |
21 | # curl localhost:9080/actuator/prometheus
22 | GET localhost:9080/actuator/prometheus
23 |
24 | ###
25 |
26 |
--------------------------------------------------------------------------------
/week3/part1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week3
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week3-part1
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/week3/part1/scripts/replace_ip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 |
5 | root="$( pwd )"
6 | echo "Root dir [${root}]"
7 |
8 | my_ip="$( "${root}"/scripts/whats_my_ip.sh )"
9 |
10 | echo "Replacing files with your ip [${my_ip}]"
11 |
12 | rm -rf "${root}"/docker/
13 | mkdir -p "${root}"/docker/grafana/provisioning/datasources/
14 | cp "${root}"/docker_backup/grafana/provisioning/datasources/datasource.yml "${root}"/docker/grafana/provisioning/datasources/datasource.yml
15 | sed -i -e "s/host.docker.internal/$my_ip/g" "${root}"/docker/grafana/provisioning/datasources/datasource.yml
16 | mkdir -p "${root}"/docker/prometheus/
17 | cp "${root}"/docker_backup/prometheus/prometheus.yml "${root}"/docker/prometheus/prometheus.yml
18 | sed -i -e "s/host.docker.internal/$my_ip/g" "${root}"/docker/prometheus/prometheus.yml
19 |
--------------------------------------------------------------------------------
/week3/part1/scripts/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 |
5 | rm -rf docker
6 | cp -rf docker_backup docker
7 |
8 | echo "Sets up IPs for datasources"
9 | ./scripts/replace_ip.sh
10 |
--------------------------------------------------------------------------------
/week3/part1/scripts/whats_my_ip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 |
5 | case "`uname`" in
6 | Darwin* )
7 | echo "host.docker.internal"
8 | ;;
9 | * )
10 | isIfConfigPResent="$( ifconfig &> /dev/null || echo 'no' )"
11 | if [[ "${isIfConfigPResent}" == "no" ]]; then
12 | hostname -I | cut -d' ' -f1
13 | else
14 | ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1
15 | fi
16 | ;;
17 | esac
18 |
--------------------------------------------------------------------------------
/week3/part2/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | consul:
4 | image: progrium/consul
5 | extra_hosts: ['host.docker.internal:host-gateway']
6 | command: -server -bootstrap
7 | ports:
8 | - 8400:8400
9 | - 8500:8500
10 | - 8600:8600
11 | zipkin:
12 | image: openzipkin/zipkin
13 | extra_hosts: ['host.docker.internal:host-gateway']
14 | ports:
15 | - 9411:9411
16 |
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part2/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-tracing
13 | 0.0.1-SNAPSHOT
14 | Fraud Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-consul-discovery
32 |
33 |
34 | io.micrometer
35 | micrometer-tracing-bridge-brave
36 |
37 |
38 | io.zipkin.reporter2
39 | zipkin-reporter-brave
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-dependencies
53 | ${spring-cloud.version}
54 | pom
55 | import
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-maven-plugin
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import io.micrometer.tracing.Tracer;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 | import org.springframework.boot.SpringApplication;
11 | import org.springframework.boot.autoconfigure.SpringBootApplication;
12 | import org.springframework.web.bind.annotation.GetMapping;
13 | import org.springframework.web.bind.annotation.RestController;
14 |
15 | @SpringBootApplication
16 | public class FraudDetectionApplication {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(FraudDetectionApplication.class, args);
20 | }
21 |
22 | }
23 |
24 | @RestController
25 | class FraudDetectionController {
26 |
27 | private static final Logger log =
28 | LoggerFactory.getLogger(FraudDetectionController.class);
29 |
30 | @GetMapping("/frauds")
31 | List frauds() {
32 | log.info("\n\nGot fraud request\n\n");
33 | return Arrays.asList("josh", "marcin");
34 | }
35 | }
36 |
37 | @RestController
38 | class BaggageController {
39 |
40 | private static final Logger log =
41 | LoggerFactory.getLogger(BaggageController.class);
42 |
43 | private final Tracer tracer;
44 |
45 | BaggageController(Tracer tracer) {
46 | this.tracer = tracer;
47 | }
48 |
49 | @GetMapping("/baggage")
50 | String baggage() {
51 | String mybaggage = tracer.getBaggage("mybaggage").get();
52 | tracer.currentSpan().tag("mybaggage-tag", mybaggage);
53 | log.info("\n\nGot baggage request, baggage equals {}\n\n", mybaggage);
54 | return mybaggage;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 |
4 | logging.file.name=${spring.application.name}.log
5 |
6 | management.tracing.sampling.probability=1.0
7 | logging.pattern.correlation=[${spring.application.name:},%X{traceId:-},%X{spanId:-}]
8 | logging.include-application-name=false
9 | management.tracing.baggage.remote-fields=mybaggage
10 |
--------------------------------------------------------------------------------
/week3/part2/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class FraudDetectionApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week3/part2/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9081/resttemplate
2 | GET localhost:9081/resttemplate
3 |
4 | ###
5 |
6 | # curl localhost:9081/actuator/metrics/my.observation
7 | GET localhost:9081/actuator/metrics/my.observation
8 |
9 | ###
10 |
11 | # curl localhost:9081/actuator/metrics/method.observed
12 | GET localhost:9081/actuator/metrics/method.observed
13 |
14 | ###
15 |
16 | # curl localhost:9081/baggage
17 | GET localhost:9081/baggage
18 |
19 | ###
20 |
--------------------------------------------------------------------------------
/week3/part2/loanissuance/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part2/loanissuance/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part2/loanissuance/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part2/loanissuance/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part2/loanissuance/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-tracing
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-aop
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-consul-discovery
36 |
37 |
38 | org.springframework.cloud
39 | spring-cloud-starter-loadbalancer
40 |
41 |
42 | io.micrometer
43 | micrometer-tracing-bridge-brave
44 |
45 |
46 | io.zipkin.reporter2
47 | zipkin-reporter-brave
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-starter-test
53 | test
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.cloud
60 | spring-cloud-dependencies
61 | ${spring-cloud.version}
62 | pom
63 | import
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.springframework.boot
72 | spring-boot-maven-plugin
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/week3/part2/loanissuance/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 | management.endpoints.web.exposure.include=*
3 |
4 | spring.application.name=loanissuance
5 |
6 | logging.file.name=${spring.application.name}.log
7 |
8 | management.tracing.sampling.probability=1.0
9 | logging.pattern.correlation=[${spring.application.name:},%X{traceId:-},%X{spanId:-}]
10 | logging.include-application-name=false
11 | management.tracing.baggage.remote-fields=mybaggage
12 |
--------------------------------------------------------------------------------
/week3/part2/loanissuance/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.context.annotation.Primary;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | @SpringBootTest
12 | class LoanIssuanceApplicationTests {
13 |
14 | @Test
15 | void contextLoads() {
16 | }
17 |
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/week3/part2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week3
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week3-part2
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 | loanissuance
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/week3/part3/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.8"
2 | services:
3 | consul:
4 | image: progrium/consul
5 | extra_hosts: ['host.docker.internal:host-gateway']
6 | command: -server -bootstrap
7 | ports:
8 | - 8400:8400
9 | - 8500:8500
10 | - 8600:8600
11 | zipkin:
12 | image: openzipkin/zipkin
13 | extra_hosts: ['host.docker.internal:host-gateway']
14 | ports:
15 | - 9411:9411
16 |
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part3/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-chaos
13 | 0.0.1-SNAPSHOT
14 | Fraud Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 | 3.1.0
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-actuator
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-web
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-aop
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-starter-consul-discovery
37 |
38 |
39 | io.micrometer
40 | micrometer-tracing-bridge-brave
41 |
42 |
43 | io.zipkin.reporter2
44 | zipkin-reporter-brave
45 |
46 |
47 | de.codecentric
48 | chaos-monkey-spring-boot
49 | ${chaos-monkey-spring-boot.version}
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-data-jpa
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-starter-circuitbreaker-resilience4j
58 |
59 |
60 |
61 | com.h2database
62 | h2
63 | runtime
64 |
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-starter-test
69 | test
70 |
71 |
72 |
73 |
74 |
75 | org.springframework.cloud
76 | spring-cloud-dependencies
77 | ${spring-cloud.version}
78 | pom
79 | import
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | org.springframework.boot
88 | spring-boot-maven-plugin
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 | management.tracing.sampling.probability=1.0
4 | logging.pattern.correlation=[${spring.application.name:},%X{traceId:-},%X{spanId:-}]
5 |
6 | spring.jpa.defer-datasource-initialization=true
7 |
8 | # Chaos
9 | management.endpoint.chaosmonkey.enabled=true
10 | management.endpoints.web.exposure.include=*
11 | spring.profiles.active=chaos-monkey
12 | chaos.monkey.enabled=true
13 |
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO frauds (id, name) VALUES (1, 'josh');
2 | INSERT INTO frauds (id, name) VALUES (2, 'marcin');
3 |
--------------------------------------------------------------------------------
/week3/part3/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class FraudDetectionApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week3/part3/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9081/resttemplate
2 | GET localhost:9081/resttemplate
3 |
4 |
5 | ###
6 |
7 | # Enable repository in fraud detection
8 | POST localhost:9080/actuator/chaosmonkey/watchers
9 | Content-Type: application/json
10 |
11 | {
12 | "controller": false,
13 | "restController": false,
14 | "service": false,
15 | "repository": true,
16 | "component": false
17 | }
18 |
19 | ###
20 |
21 | # Enable exception in fraud detection
22 | POST localhost:9080/actuator/chaosmonkey/assaults
23 | Content-Type: application/json
24 |
25 | {
26 | "level": 1,
27 | "latencyActive": false,
28 | "exceptionsActive": true,
29 | "killApplicationActive": false
30 | }
31 |
32 | ###
33 |
34 | # curl localhost:9081/resttemplate
35 | GET localhost:9081/resttemplate
36 |
37 |
38 | ###
39 |
40 | # Disable watchers for fraud detection
41 | POST localhost:9080/actuator/chaosmonkey/watchers
42 | Content-Type: application/json
43 |
44 | {
45 | "controller": false,
46 | "restController": false,
47 | "service": false,
48 | "repository": false,
49 | "component": false
50 | }
51 |
52 |
53 | ###
54 |
55 | # Enable service in loan issuance
56 | POST localhost:9081/actuator/chaosmonkey/watchers
57 | Content-Type: application/json
58 |
59 | {
60 | "controller": false,
61 | "restController": false,
62 | "service": true,
63 | "repository": false,
64 | "component": false
65 | }
66 |
67 | ###
68 |
69 | # Enable exception in loan issuance
70 | POST localhost:9081/actuator/chaosmonkey/assaults
71 | Content-Type: application/json
72 |
73 | {
74 | "level": 1,
75 | "latencyActive": false,
76 | "exceptionsActive": true,
77 | "killApplicationActive": false
78 | }
79 |
80 | ###
81 |
82 | # curl localhost:9081/resttemplate
83 | GET localhost:9081/resttemplate
84 |
85 |
86 | ###
87 |
88 | # Disable watchers
89 | POST localhost:9081/actuator/chaosmonkey/watchers
90 | Content-Type: application/json
91 |
92 | {
93 | "controller": false,
94 | "restController": false,
95 | "service": false,
96 | "repository": false,
97 | "component": false
98 | }
99 |
100 |
--------------------------------------------------------------------------------
/week3/part3/loanissuance/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part3/loanissuance/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part3/loanissuance/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part3/loanissuance/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part3/loanissuance/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | loanissuance-chaos
13 | 0.0.1-SNAPSHOT
14 | Loan Issuance
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 | 3.1.0
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-actuator
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-web
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-aop
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-starter-consul-discovery
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-loadbalancer
41 |
42 |
43 | io.micrometer
44 | micrometer-tracing-bridge-brave
45 |
46 |
47 | io.zipkin.reporter2
48 | zipkin-reporter-brave
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-starter-circuitbreaker-resilience4j
53 |
54 |
55 | de.codecentric
56 | chaos-monkey-spring-boot
57 | ${chaos-monkey-spring-boot.version}
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-starter-test
63 | test
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.cloud
70 | spring-cloud-dependencies
71 | ${spring-cloud.version}
72 | pom
73 | import
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | org.springframework.boot
82 | spring-boot-maven-plugin
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/week3/part3/loanissuance/src/main/java/com/example/loanissuance/LoanIssuanceApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import java.util.Collections;
4 | import java.util.List;
5 |
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | import org.springframework.boot.SpringApplication;
10 | import org.springframework.boot.autoconfigure.SpringBootApplication;
11 | import org.springframework.boot.web.client.RestTemplateBuilder;
12 | import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory;
13 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
14 | import org.springframework.context.annotation.Bean;
15 | import org.springframework.context.annotation.Configuration;
16 | import org.springframework.stereotype.Service;
17 | import org.springframework.web.bind.annotation.GetMapping;
18 | import org.springframework.web.bind.annotation.RestController;
19 | import org.springframework.web.client.RestTemplate;
20 |
21 | @SpringBootApplication
22 | public class LoanIssuanceApplication {
23 |
24 | public static void main(String[] args) {
25 | SpringApplication.run(LoanIssuanceApplication.class, args);
26 | }
27 |
28 | }
29 |
30 | @Configuration(proxyBeanMethods = false)
31 | class Config {
32 |
33 | @Bean
34 | @LoadBalanced
35 | RestTemplate restTemplate(RestTemplateBuilder builder) {
36 | return builder.build();
37 | }
38 |
39 | }
40 |
41 | @RestController
42 | class LoanIssuanceController {
43 |
44 | private static final Logger log = LoggerFactory.getLogger(LoanIssuanceController.class);
45 |
46 | private final FraudDetectionCallingService fraudDetectionCallingService;
47 |
48 | private final CircuitBreakerFactory factory;
49 |
50 | LoanIssuanceController(FraudDetectionCallingService fraudDetectionCallingService, CircuitBreakerFactory factory) {
51 | this.fraudDetectionCallingService = fraudDetectionCallingService;
52 | this.factory = factory;
53 | }
54 |
55 | @GetMapping("/resttemplate")
56 | @SuppressWarnings("unchecked")
57 | List restTemplateFrauds() {
58 | log.info("\n\nGot rest template request\n\n");
59 | return this.factory.create("rest-template").run(this.fraudDetectionCallingService::restTemplateFrauds, throwable -> Collections.emptyList());
60 | }
61 | }
62 |
63 | @Service
64 | class FraudDetectionCallingService {
65 |
66 | private final RestTemplate restTemplate;
67 |
68 | FraudDetectionCallingService(@LoadBalanced RestTemplate restTemplate) {
69 | this.restTemplate = restTemplate;
70 | }
71 |
72 | @SuppressWarnings("unchecked")
73 | List restTemplateFrauds() {
74 | return this.restTemplate.getForObject("http://frauddetection/frauds", List.class);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/week3/part3/loanissuance/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9081
2 |
3 | spring.application.name=loanissuance
4 | management.tracing.sampling.probability=1.0
5 | logging.pattern.correlation=[${spring.application.name:},%X{traceId:-},%X{spanId:-}]
6 |
7 | # Chaos
8 | management.endpoint.chaosmonkey.enabled=true
9 | management.endpoints.web.exposure.include=*
10 | spring.profiles.active=chaos-monkey
11 | chaos.monkey.enabled=true
12 |
--------------------------------------------------------------------------------
/week3/part3/loanissuance/src/test/java/com/example/loanissuance/LoanIssuanceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.loanissuance;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.context.annotation.Primary;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | @SpringBootTest
12 | class LoanIssuanceApplicationTests {
13 |
14 | @Test
15 | void contextLoads() {
16 | }
17 |
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/week3/part3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week3
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week3-part3
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 | loanissuance
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/week3/part3/scripts/disableAllWatchers.json:
--------------------------------------------------------------------------------
1 | {
2 | "controller": false,
3 | "restController": false,
4 | "service": false,
5 | "repository": false,
6 | "component": false
7 | }
8 |
--------------------------------------------------------------------------------
/week3/part3/scripts/disableAttacks.json:
--------------------------------------------------------------------------------
1 | {
2 | "latencyActive": false,
3 | "exceptionsActive": false,
4 | "killApplicationActive": false
5 | }
6 |
--------------------------------------------------------------------------------
/week3/part3/scripts/disableAttacks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o errtrace
5 | set -o nounset
6 | set -o pipefail
7 |
8 | port="${1}"
9 | curl -X POST -H "Content-Type: application/json" -d @disableAllWatchers.json "http://localhost:${port}/actuator/chaosmonkey/watchers"
10 | curl -X POST -H "Content-Type: application/json" -d @disableAttacks.json "http://localhost:${port}/actuator/chaosmonkey/assaults"
11 |
--------------------------------------------------------------------------------
/week3/part3/scripts/enableExceptionAssault.json:
--------------------------------------------------------------------------------
1 | {
2 | "level": 1,
3 | "latencyActive": false,
4 | "exceptionsActive": true,
5 | "killApplicationActive": false
6 | }
7 |
--------------------------------------------------------------------------------
/week3/part3/scripts/enableRepositoryExceptionAssault.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o errtrace
5 | set -o nounset
6 | set -o pipefail
7 |
8 | port="${1}"
9 | curl -X POST -H "Content-Type: application/json" -d @enableRepositoryWatcher.json "http://localhost:${port}/actuator/chaosmonkey/watchers"
10 | curl -X POST -H "Content-Type: application/json" -d @enableExceptionAssault.json "http://localhost:${port}/actuator/chaosmonkey/assaults"
11 |
--------------------------------------------------------------------------------
/week3/part3/scripts/enableRepositoryWatcher.json:
--------------------------------------------------------------------------------
1 | {
2 | "controller": false,
3 | "restController": false,
4 | "service": false,
5 | "repository": true,
6 | "component": false
7 | }
8 |
--------------------------------------------------------------------------------
/week3/part3/scripts/enableServiceExceptionAssault.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o errtrace
5 | set -o nounset
6 | set -o pipefail
7 |
8 | port="${1}"
9 | curl -X POST -H "Content-Type: application/json" -d @enableServiceWatcher.json "http://localhost:${port}/actuator/chaosmonkey/watchers"
10 | curl -X POST -H "Content-Type: application/json" -d @enableExceptionAssault.json "http://localhost:${port}/actuator/chaosmonkey/assaults"
11 |
--------------------------------------------------------------------------------
/week3/part3/scripts/enableServiceWatcher.json:
--------------------------------------------------------------------------------
1 | {
2 | "controller": false,
3 | "restController": false,
4 | "service": true,
5 | "repository": false,
6 | "component": false
7 | }
8 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part4/fraud-detection/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | frauddetection-feature-toggle
13 | 0.0.1-SNAPSHOT
14 | Fraud-Detection
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-actuator
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | org.springframework.cloud
32 | spring-cloud-starter-config
33 |
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-test
38 | test
39 |
40 |
41 |
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-dependencies
47 | ${spring-cloud.version}
48 | pom
49 | import
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-maven-plugin
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/java/com/example/frauddetection/EmptyFraudService.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Collections;
4 | import java.util.List;
5 |
6 | import org.springframework.stereotype.Service;
7 |
8 | @Service
9 | public class EmptyFraudService implements FraudCheckingService {
10 |
11 | @Override
12 | public List frauds() {
13 | return Collections.emptyList();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/java/com/example/frauddetection/FraudCheckingService.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.List;
4 |
5 | public interface FraudCheckingService {
6 |
7 | List frauds();
8 | }
9 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/java/com/example/frauddetection/FraudDetectionApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.List;
4 |
5 | import com.example.frauddetection.toggles.FeatureProxyFactoryBean;
6 |
7 | import org.springframework.boot.SpringApplication;
8 | import org.springframework.boot.autoconfigure.SpringBootApplication;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.context.annotation.Configuration;
11 | import org.springframework.context.annotation.Primary;
12 | import org.springframework.web.bind.annotation.GetMapping;
13 | import org.springframework.web.bind.annotation.RestController;
14 |
15 | @SpringBootApplication
16 | public class FraudDetectionApplication {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(FraudDetectionApplication.class, args);
20 | }
21 |
22 | }
23 |
24 | @RestController
25 | class FraudDetectionController {
26 |
27 | private final FraudCheckingService fraudCheckingService;
28 |
29 | FraudDetectionController(FraudCheckingService fraudCheckingService) {
30 | this.fraudCheckingService = fraudCheckingService;
31 | }
32 |
33 | @GetMapping("/frauds")
34 | List frauds() {
35 | return this.fraudCheckingService.frauds();
36 | }
37 | }
38 |
39 | @Configuration(proxyBeanMethods = false)
40 | class FeatureToggleConfiguration {
41 |
42 | @Bean
43 | @Primary
44 | FeatureProxyFactoryBean fraudCheckingProxy(StaticFraudService staticFraudService,
45 | EmptyFraudService emptyFraudService) {
46 | FeatureProxyFactoryBean bean = new FeatureProxyFactoryBean();
47 | bean.setActive(staticFraudService);
48 | bean.setInactive(emptyFraudService);
49 | bean.setFeature(MyFeatures.STATIC_FRAUD_CHECK_LIST);
50 | bean.setProxyType(FraudCheckingService.class);
51 | return bean;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/java/com/example/frauddetection/MyFeatures.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | public enum MyFeatures {
4 |
5 | STATIC_FRAUD_CHECK_LIST,
6 |
7 | PERFORMANCE_FEATURE_1,
8 |
9 | PERFORMANCE_FEATURE_2,
10 |
11 | YET_ANOTHER_FEATURE;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/java/com/example/frauddetection/StaticFraudService.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import org.springframework.stereotype.Service;
7 |
8 | @Service
9 | public class StaticFraudService implements FraudCheckingService {
10 |
11 | @Override
12 | public List frauds() {
13 | return Arrays.asList("josh", "marcin");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/java/com/example/frauddetection/toggles/FeatureProxyInvocationHandler.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection.toggles;
2 |
3 | import java.lang.reflect.InvocationHandler;
4 | import java.lang.reflect.InvocationTargetException;
5 | import java.lang.reflect.Method;
6 |
7 | import org.springframework.core.env.Environment;
8 |
9 | /**
10 | * Based on Togglz
11 | *
12 | * @author Christian Kaltepoth
13 | */
14 | public class FeatureProxyInvocationHandler implements InvocationHandler {
15 |
16 | // Basing on https://www.togglz.org/documentation/spring-boot-starter.html
17 | private static final String PROPERTY_PATTERN = "toggles.features.%s.enabled";
18 |
19 | private final Enum feature;
20 |
21 | private final Object active;
22 |
23 | private final Object inactive;
24 |
25 | private final Environment environment;
26 |
27 | public FeatureProxyInvocationHandler(Enum feature, Object active, Object inactive, Environment environment) {
28 | this.feature = feature;
29 | this.active = active;
30 | this.inactive = inactive;
31 | this.environment = environment;
32 | }
33 |
34 | @Override
35 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
36 | Object target = isActive() ? active : inactive;
37 | try {
38 | return method.invoke(target, args);
39 | }
40 | catch (InvocationTargetException ex) {
41 | throw ex.getCause();
42 | }
43 |
44 | }
45 |
46 | private boolean isActive() {
47 | return this.environment.getProperty(String.format(PROPERTY_PATTERN, feature.name()), Boolean.class, false);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=9080
2 | spring.application.name=frauddetection
3 |
4 | management.endpoints.web.exposure.include=*
5 | spring.config.import=optional:configserver:
6 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/test/java/com/example/frauddetection/FraudDetectionApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.frauddetection;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.ActiveProfiles;
7 |
8 | @SpringBootTest
9 | @ActiveProfiles("test")
10 | class FraudDetectionApplicationTests {
11 |
12 | @Test
13 | void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/week3/part4/fraud-detection/src/test/resources/application-test.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.url=jdbc:h2:mem:testdb
2 | spring.datasource.driverClassName=org.h2.Driver
3 | spring.datasource.username=sa
4 | spring.datasource.password=password
5 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
6 |
--------------------------------------------------------------------------------
/week3/part4/http/assignment.http:
--------------------------------------------------------------------------------
1 | # curl localhost:9080/frauds
2 | GET localhost:9080/frauds
3 |
4 | ###
5 |
6 | POST localhost:9080/actuator/refresh
7 |
8 | ###
9 |
10 | ## curl -d '{"enabled":"true"}' -H "Content-Type: application/json" -POST http://localhost:9080/actuator/togglz/STATIC_FRAUD_CHECK_LIST
11 | #POST http://localhost:9080/actuator/togglz/STATIC_FRAUD_CHECK_LIST
12 | #Content-Type: application/json
13 | #
14 | #{
15 | # "enabled":"true"
16 | #}
17 |
--------------------------------------------------------------------------------
/week3/part4/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring-week3
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week3-part4
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | fraud-detection
33 | spring-cloud-config-server
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcingrzejszczak/oreilly_java_microservices_with_spring_samples/64464fc18b82641810fbb7c7779ddd829e551895/week3/part4/spring-cloud-config-server/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.0
9 |
10 |
11 | com.example
12 | config-server
13 | 0.0.1-SNAPSHOT
14 | feature-toggle-config-server
15 | Demo project for Spring Boot
16 |
17 | 17
18 | 2024.0.0
19 |
20 |
21 |
22 | org.springframework.cloud
23 | spring-cloud-config-server
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-test
29 | test
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-dependencies
37 | ${spring-cloud.version}
38 | pom
39 | import
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @SpringBootApplication
8 | @EnableConfigServer
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 |
15 | }
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | config:
4 | server:
5 | git:
6 | # [Git] Use your fork
7 | uri: https://github.com/marcingrzejszczak/config-server-properties
8 |
9 | # [Config server] default port
10 | server.port: 8888
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/week3/part4/spring-cloud-config-server/src/test/java/com/example/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/week3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.example
9 | oreilly-java-microservices-with-spring
10 | 1.0.0-SNAPSHOT
11 | ..
12 |
13 |
14 | oreilly-java-microservices-with-spring-week3
15 | pom
16 |
17 | ${project.artifactId}
18 | ${project.artifactId}
19 |
20 |
21 |
22 |
23 | maven-deploy-plugin
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 | part1
33 | part2
34 | part3
35 | part4
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------