├── cicd ├── tools │ └── sonar-project.properties ├── readme.md ├── apps │ └── sample-spring-kotlin │ │ └── deployment.yaml └── pipelines │ └── tekton-maven-version.yaml ├── mesh-with-db ├── readme.md ├── quarkus-person-app │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── quarkus │ │ │ │ └── person │ │ │ │ ├── model │ │ │ │ ├── Gender.java │ │ │ │ └── Person.java │ │ │ │ ├── repository │ │ │ │ └── PersonRepository.java │ │ │ │ ├── QuarkusApplication.java │ │ │ │ └── resource │ │ │ │ └── PersonResource.java │ │ │ └── resources │ │ │ └── application.properties │ ├── .gitignore │ └── README.md ├── quarkus-insurance-app │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── quarkus │ │ │ │ └── insurance │ │ │ │ ├── client │ │ │ │ ├── model │ │ │ │ │ ├── Gender.java │ │ │ │ │ └── Person.java │ │ │ │ ├── PersonService.java │ │ │ │ └── RequestHeaderFactory.java │ │ │ │ ├── model │ │ │ │ ├── InsuranceType.java │ │ │ │ ├── InsuranceDetails.java │ │ │ │ └── Insurance.java │ │ │ │ ├── repository │ │ │ │ └── InsuranceRepository.java │ │ │ │ └── QuarkusApplication.java │ │ │ ├── resources │ │ │ ├── db │ │ │ │ └── changeLog.sql │ │ │ └── application.properties │ │ │ └── kubernetes │ │ │ └── openshift.yml │ └── .gitignore ├── k8s │ ├── mesh │ │ ├── service.yaml │ │ ├── auth.yaml │ │ ├── gateway.yaml │ │ ├── mesh-insurance.yaml │ │ ├── fuse.yaml │ │ └── mesh-person.yaml │ └── traffic │ │ └── urls.txt ├── k6 │ └── load-tests-getall.js └── pom.xml ├── event-driven ├── data │ └── kafkacat-data.txt ├── consumer │ ├── skaffold.yaml │ ├── k8s │ │ └── deployment.yaml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── eventdriven │ │ │ ├── message │ │ │ └── CallmeEvent.java │ │ │ └── ConsumerAApp.java │ └── pom.xml ├── producer │ ├── skaffold.yaml │ ├── k8s │ │ └── deployment.yaml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ └── message │ │ │ │ ├── CallmeEvent.java │ │ │ │ └── LargeEvent.java │ │ │ └── resources │ │ │ └── application.properties │ └── pom.xml ├── shipment-service │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ └── shipment │ │ │ │ ├── exception │ │ │ │ └── NotEnoughProductsException.java │ │ │ │ ├── repository │ │ │ │ └── ProductRepository.java │ │ │ │ ├── message │ │ │ │ ├── OrderCommand.java │ │ │ │ ├── ConfirmCommand.java │ │ │ │ ├── AbstractOrderCommand.java │ │ │ │ ├── OrderCommandDelayed.java │ │ │ │ └── OrderEvent.java │ │ │ │ ├── domain │ │ │ │ └── Product.java │ │ │ │ ├── service │ │ │ │ └── ShipmentService.java │ │ │ │ └── ShipmentServiceApp.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml ├── order-service │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ └── order │ │ │ │ ├── repository │ │ │ │ └── OrderCommandRepository.java │ │ │ │ ├── message │ │ │ │ ├── ConfirmCommand.java │ │ │ │ ├── RollbackCommand.java │ │ │ │ ├── OrderCommand.java │ │ │ │ ├── AbstractOrderCommand.java │ │ │ │ └── OrderEvent.java │ │ │ │ └── OrderServiceApp.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml ├── event-gateway │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ └── gateway │ │ │ │ ├── message │ │ │ │ ├── OrderCommand.java │ │ │ │ ├── OrderQueryResult.java │ │ │ │ ├── AbstractOrderCommand.java │ │ │ │ └── OrderQuery.java │ │ │ │ ├── EventGatewayApp.java │ │ │ │ └── controller │ │ │ │ └── OrderController.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml ├── order-query-service │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ └── order │ │ │ │ ├── message │ │ │ │ ├── OrderCommand.java │ │ │ │ ├── ConfirmCommand.java │ │ │ │ ├── OrderQueryResult.java │ │ │ │ ├── OrderQuery.java │ │ │ │ └── AbstractOrderCommand.java │ │ │ │ └── repository │ │ │ │ └── OrderRepository.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml ├── payment-service │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ └── payment │ │ │ │ ├── message │ │ │ │ ├── ConfirmCommand.java │ │ │ │ ├── AbstractOrderCommand.java │ │ │ │ ├── OrderEvent.java │ │ │ │ └── OrderCommand.java │ │ │ │ ├── repository │ │ │ │ └── AccountRepository.java │ │ │ │ ├── PaymentServiceApp.java │ │ │ │ ├── domain │ │ │ │ └── Account.java │ │ │ │ └── service │ │ │ │ └── PaymentService.java │ │ │ └── resources │ │ │ └── application.yml │ └── pom.xml ├── streams │ ├── consumer-streams │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── eventdriven │ │ │ │ ├── domain │ │ │ │ ├── Customer.java │ │ │ │ ├── Order.java │ │ │ │ └── CustomerOrder.java │ │ │ │ └── controller │ │ │ │ └── OrderController.java │ │ └── pom.xml │ ├── producer-streams │ │ ├── src │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── pl │ │ │ │ │ └── redhat │ │ │ │ │ └── samples │ │ │ │ │ └── eventdriven │ │ │ │ │ └── streams │ │ │ │ │ └── producer │ │ │ │ │ └── message │ │ │ │ │ ├── Customer.java │ │ │ │ │ └── Order.java │ │ │ │ └── resources │ │ │ │ └── application.yml │ │ └── pom.xml │ └── pom.xml └── pom.xml ├── micro-view ├── employee │ ├── skaffold.yaml │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── employee │ │ │ ├── EmployeeApp.java │ │ │ └── repository │ │ │ └── EmployeeRepository.java │ ├── k8s │ │ └── deployment.yaml │ └── pom.xml ├── department │ ├── skaffold.yaml │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── department │ │ │ ├── repository │ │ │ └── DepartmentRepository.java │ │ │ ├── DepartmentApp.java │ │ │ └── model │ │ │ ├── Employee.java │ │ │ └── Department.java │ ├── k8s │ │ └── deployment.yaml │ └── pom.xml ├── organization │ ├── skaffold.yaml │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.yml │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── organization │ │ │ ├── repository │ │ │ └── OrganizationRepository.java │ │ │ ├── OrganizationApp.java │ │ │ └── model │ │ │ ├── Department.java │ │ │ ├── Employee.java │ │ │ └── Organization.java │ ├── k8s │ │ └── deployment.yaml │ └── pom.xml └── pom.xml ├── messaging ├── simple-producer │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── messaging │ │ │ └── simple │ │ │ ├── SimpleProducer.java │ │ │ ├── producer │ │ │ └── ProducerController.java │ │ │ └── message │ │ │ └── SimpleMessage.java │ ├── skaffold.yaml │ └── k8s │ │ └── deployment.yaml ├── simple-consumer │ ├── skaffold.yaml │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── messaging │ │ │ └── simple │ │ │ ├── config │ │ │ └── AmqpConfig.java │ │ │ ├── SimpleConsumer.java │ │ │ ├── consumer │ │ │ └── Listener.java │ │ │ └── message │ │ │ └── SimpleMessage.java │ └── k8s │ │ └── deployment.yaml ├── simple-counter │ ├── skaffold.yaml │ ├── k8s │ │ └── deployment.yaml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── messaging │ │ │ └── counter │ │ │ └── CounterApp.java │ └── pom.xml ├── k8s │ ├── kind-config.yaml │ └── broker-kind.yaml └── pom.xml ├── micro-springboot ├── person-service │ ├── skaffold.yaml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── person │ │ │ │ ├── domain │ │ │ │ ├── Gender.java │ │ │ │ └── Person.java │ │ │ │ ├── repository │ │ │ │ ├── PersonRepository.java │ │ │ │ └── PersonViewRepository.java │ │ │ │ ├── view │ │ │ │ └── PersonView.java │ │ │ │ └── PersonApplication.java │ │ │ └── resources │ │ │ └── application.yml │ └── k8s │ │ └── deployment.yaml ├── insurance-service │ └── src │ │ └── main │ │ ├── java │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── insurance │ │ │ ├── client │ │ │ ├── message │ │ │ │ ├── Gender.java │ │ │ │ └── Person.java │ │ │ └── PersonClient.java │ │ │ ├── domain │ │ │ ├── InsuranceType.java │ │ │ ├── InsuranceDetails.java │ │ │ ├── InsuranceView.java │ │ │ └── Insurance.java │ │ │ ├── repository │ │ │ ├── InsuranceRepository.java │ │ │ └── InsuranceViewRepository.java │ │ │ └── InsuranceApplication.java │ │ └── resources │ │ ├── import.sql │ │ └── application.yml └── pom.xml ├── camel-spring ├── person-demo │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── pl │ │ │ │ └── redhat │ │ │ │ └── samples │ │ │ │ └── camel │ │ │ │ └── person │ │ │ │ ├── domain │ │ │ │ ├── Gender.java │ │ │ │ └── Person.java │ │ │ │ ├── PersonDemo.java │ │ │ │ ├── repository │ │ │ │ └── PersonRepository.java │ │ │ │ ├── service │ │ │ │ └── PersonService.java │ │ │ │ └── route │ │ │ │ └── PersonRouteBuilder.java │ │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── application-dev.yml │ │ │ └── db │ │ │ └── changeLog.sql │ └── readme.md └── pom.xml ├── basic-with-db ├── person-app │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── pl │ │ │ │ │ └── redhat │ │ │ │ │ └── samples │ │ │ │ │ └── quarkus │ │ │ │ │ └── person │ │ │ │ │ ├── model │ │ │ │ │ ├── Gender.java │ │ │ │ │ └── Person.java │ │ │ │ │ ├── PersonApplication.java │ │ │ │ │ ├── repository │ │ │ │ │ └── PersonRepository.java │ │ │ │ │ ├── startup │ │ │ │ │ └── StartupListener.java │ │ │ │ │ └── resource │ │ │ │ │ └── PersonResource.java │ │ │ └── resources │ │ │ │ └── db │ │ │ │ └── changeLog.sql │ │ └── test │ │ │ └── java │ │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── quarkus │ │ │ └── person │ │ │ └── PersonRepositoryTests.java │ └── .s2i │ │ └── environment ├── insurance-app │ └── src │ │ └── main │ │ ├── java │ │ └── pl │ │ │ └── redhat │ │ │ └── samples │ │ │ └── quarkus │ │ │ └── insurance │ │ │ ├── client │ │ │ ├── message │ │ │ │ ├── Gender.java │ │ │ │ └── Person.java │ │ │ └── PersonService.java │ │ │ ├── model │ │ │ ├── InsuranceType.java │ │ │ ├── Insurance.java │ │ │ └── InsuranceDetails.java │ │ │ ├── repository │ │ │ └── InsuranceRepository.java │ │ │ ├── PersonApplication.java │ │ │ └── resource │ │ │ └── InsuranceResource.java │ │ └── resources │ │ └── db │ │ └── changeLog.sql ├── k6 │ └── load-tests-add.js └── pom.xml ├── renovate.json ├── cpu-killer ├── k6 │ └── load-test.js └── src │ ├── test │ └── k6 │ │ └── load-tests.js │ └── main │ ├── java │ └── pl │ │ └── redhat │ │ └── samples │ │ └── cpukiller │ │ ├── message │ │ └── PingEvent.java │ │ └── CpuKillerApp.java │ ├── resources │ └── application.properties │ └── kubernetes │ └── k6.yml ├── .circleci └── config.yml └── deployment.yaml /cicd/tools/sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.organization=piomin -------------------------------------------------------------------------------- /mesh-with-db/readme.md: -------------------------------------------------------------------------------- 1 | siege -f k8s/traffic/urls.txt -i -v -r 200 -c 10 --no-parser -------------------------------------------------------------------------------- /event-driven/data/kafkacat-data.txt: -------------------------------------------------------------------------------- 1 | 1:NEW 2 | 2:NEW 3 | 3:NEW 4 | 1:PROCESSING 5 | 2:PROCESSING 6 | 1:FINISHED -------------------------------------------------------------------------------- /micro-view/employee/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v1 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/employee 6 | jib: {} -------------------------------------------------------------------------------- /micro-view/department/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v1 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/department 6 | jib: {} -------------------------------------------------------------------------------- /micro-view/organization/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v1 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/organization 6 | jib: {} -------------------------------------------------------------------------------- /event-driven/consumer/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v2beta22 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/consumer 6 | jib: {} 7 | -------------------------------------------------------------------------------- /event-driven/producer/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v2beta22 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/producer 6 | jib: {} 7 | -------------------------------------------------------------------------------- /messaging/simple-producer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = simple-producer 2 | 3 | amqphub.amqp10jms.remoteUrl = ${ARTEMIS_URL} -------------------------------------------------------------------------------- /messaging/simple-consumer/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v1 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/simple-consumer 6 | jib: {} 7 | -------------------------------------------------------------------------------- /messaging/simple-counter/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v1 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/simple-counter 6 | jib: {} 7 | -------------------------------------------------------------------------------- /messaging/simple-producer/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v1 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/simple-producer 6 | jib: {} 7 | -------------------------------------------------------------------------------- /micro-springboot/person-service/skaffold.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: skaffold/v2beta22 2 | kind: Config 3 | build: 4 | artifacts: 5 | - image: piomin/person 6 | jib: {} 7 | -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/java/pl/redhat/samples/person/domain/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.person.domain; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/java/pl/redhat/samples/camel/person/domain/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.camel.person.domain; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/java/pl/redhat/samples/quarkus/person/model/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.model; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/src/main/java/pl/redhat/samples/quarkus/person/model/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.model; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/client/message/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.client.message; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/message/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client.message; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/model/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client.model; 2 | 3 | public enum Gender { 4 | MALE, FEMALE; 5 | } 6 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/domain/InsuranceType.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.domain; 2 | 3 | public enum InsuranceType { 4 | MEDICAL, LIFE, PENSION, ACCIDENT; 5 | } 6 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/model/InsuranceType.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.model; 2 | 3 | public enum InsuranceType { 4 | MEDICAL, LIFE, PENSION, ACCIDENT; 5 | } 6 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/model/InsuranceType.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.model; 2 | 3 | public enum InsuranceType { 4 | MEDICAL, LIFE, PENSION, ACCIDENT; 5 | } 6 | -------------------------------------------------------------------------------- /messaging/simple-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = simple-consumer 2 | 3 | amqphub.amqp10jms.remoteUrl = ${ARTEMIS_URL} 4 | 5 | #amqphub.amqp10jms.pool.enabled = true 6 | #amqphub.amqp10jms.concurrency = 1-15 -------------------------------------------------------------------------------- /micro-view/employee/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: employee 4 | datasource: 5 | url: jdbc:postgresql://employee-db:5432/${DATABASE_NAME} 6 | username: ${DATABASE_USER} 7 | password: ${DATABASE_PASSWORD} -------------------------------------------------------------------------------- /micro-view/department/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: department 4 | datasource: 5 | url: jdbc:postgresql://department-db:5432/${DATABASE_NAME} 6 | username: ${DATABASE_USER} 7 | password: ${DATABASE_PASSWORD} -------------------------------------------------------------------------------- /basic-with-db/person-app/.s2i/environment: -------------------------------------------------------------------------------- 1 | MAVEN_S2I_ARTIFACT_DIRS=target 2 | S2I_SOURCE_DEPLOYMENTS_FILTER=*-runner.jar app lib quarkus quarkus-run.jar 3 | JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 4 | AB_JOLOKIA_OFF=true 5 | JAVA_APP_JAR=/deployments/quarkus-run.jar 6 | -------------------------------------------------------------------------------- /micro-view/organization/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: organization 4 | datasource: 5 | url: jdbc:postgresql://organization-db:5432/${DATABASE_NAME} 6 | username: ${DATABASE_USER} 7 | password: ${DATABASE_PASSWORD} -------------------------------------------------------------------------------- /mesh-with-db/k8s/mesh/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: quarkus-person-app 5 | labels: 6 | app: quarkus-person-app 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | app: quarkus-person-app 11 | ports: 12 | - port: 8080 13 | name: http 14 | -------------------------------------------------------------------------------- /mesh-with-db/k6/load-tests-getall.js: -------------------------------------------------------------------------------- 1 | import http from 'k6/http'; 2 | import { check } from 'k6'; 3 | 4 | export default function () { 5 | const res = http.get(`${__ENV.PERSONS_URI}/person/persons`); 6 | check(res, { 7 | 'is status 200': (res) => res.status === 200, 8 | 'body size is > 0': (r) => r.body.length > 0, 9 | }); 10 | } -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base",":dependencyDashboard" 5 | ], 6 | "packageRules": [ 7 | { 8 | "matchUpdateTypes": ["minor", "patch", "pin", "digest"], 9 | "automerge": true 10 | } 11 | ], 12 | "prCreation": "not-pending" 13 | } -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/java/pl/redhat/samples/person/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.person.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.person.domain.Person; 5 | 6 | public interface PersonRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/exception/NotEnoughProductsException.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.exception; 2 | 3 | public class NotEnoughProductsException extends RuntimeException { 4 | 5 | public NotEnoughProductsException() { 6 | super("Not enough products"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /cicd/readme.md: -------------------------------------------------------------------------------- 1 | Adding privileged to the `pipeline` `ServiceAccount` is required for some tasks. 2 | ```shell 3 | oc adm policy add-scc-to-user privileged -z pipeline -n piotr-cicd 4 | ``` 5 | 6 | For `sonarqube-scanner` task and SonarCloud we need to add `sonar.properties`. 7 | ```shell 8 | oc create configmap sonar-properties --from-file="sonar-project.properties" 9 | ``` -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/repository/InsuranceRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.insurance.domain.Insurance; 5 | 6 | public interface InsuranceRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /mesh-with-db/k8s/mesh/auth.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: security.istio.io/v1beta1 2 | kind: AuthorizationPolicy 3 | metadata: 4 | name: allow-v1-only 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: quarkus-person-app 9 | app.kubernetes.io/version: v2 10 | action: ALLOW 11 | rules: 12 | - to: 13 | - operation: 14 | methods: 15 | - POST -------------------------------------------------------------------------------- /micro-view/organization/src/main/java/pl/redhat/samples/organization/repository/OrganizationRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.organization.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.organization.model.Organization; 5 | 6 | public interface OrganizationRepository extends CrudRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.eventdriven.shipment.domain.Product; 5 | 6 | public interface ProductRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/repository/OrderCommandRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.eventdriven.order.message.OrderCommand; 5 | 6 | public interface OrderCommandRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/java/pl/redhat/samples/eventdriven/gateway/message/OrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.gateway.message; 2 | 3 | public class OrderCommand extends AbstractOrderCommand { 4 | 5 | private String id; 6 | 7 | public String getId() { 8 | return id; 9 | } 10 | 11 | public void setId(String id) { 12 | this.id = id; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/java/pl/redhat/samples/eventdriven/order/message/OrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | public class OrderCommand extends AbstractOrderCommand { 4 | 5 | private String id; 6 | 7 | public String getId() { 8 | return id; 9 | } 10 | 11 | public void setId(String id) { 12 | this.id = id; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/message/OrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.message; 2 | 3 | public class OrderCommand extends AbstractOrderCommand { 4 | 5 | private String id; 6 | 7 | public String getId() { 8 | return id; 9 | } 10 | 11 | public void setId(String id) { 12 | this.id = id; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /micro-view/employee/src/main/java/pl/redhat/samples/employee/EmployeeApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.employee; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class EmployeeApp { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(EmployeeApp.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/message/ConfirmCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | public class ConfirmCommand extends AbstractOrderCommand { 4 | 5 | private String orderId; 6 | 7 | public String getOrderId() { 8 | return orderId; 9 | } 10 | 11 | public void setOrderId(String orderId) { 12 | this.orderId = orderId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/java/pl/redhat/samples/camel/person/PersonDemo.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.camel.person; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PersonDemo { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PersonDemo.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/java/pl/redhat/samples/eventdriven/order/message/ConfirmCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | public class ConfirmCommand extends AbstractOrderCommand { 4 | 5 | private String orderId; 6 | 7 | public String getOrderId() { 8 | return orderId; 9 | } 10 | 11 | public void setOrderId(String orderId) { 12 | this.orderId = orderId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/message/ConfirmCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.message; 2 | 3 | public class ConfirmCommand extends AbstractOrderCommand { 4 | 5 | private String orderId; 6 | 7 | public String getOrderId() { 8 | return orderId; 9 | } 10 | 11 | public void setOrderId(String orderId) { 12 | this.orderId = orderId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/message/ConfirmCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.message; 2 | 3 | public class ConfirmCommand extends AbstractOrderCommand { 4 | 5 | private String orderId; 6 | 7 | public String getOrderId() { 8 | return orderId; 9 | } 10 | 11 | public void setOrderId(String orderId) { 12 | this.orderId = orderId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/src/main/java/pl/redhat/samples/quarkus/person/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.repository; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheRepository; 4 | import pl.redhat.samples.quarkus.person.model.Person; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | 8 | @ApplicationScoped 9 | public class PersonRepository implements PanacheRepository { 10 | } 11 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/repository/InsuranceRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.repository; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheRepository; 4 | import pl.redhat.samples.quarkus.insurance.model.Insurance; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | 8 | @ApplicationScoped 9 | public class InsuranceRepository implements PanacheRepository { 10 | } 11 | -------------------------------------------------------------------------------- /mesh-with-db/k8s/mesh/gateway.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: microservices-gateway 5 | spec: 6 | selector: 7 | istio: ingressgateway 8 | servers: 9 | - port: 10 | number: 80 11 | name: http 12 | protocol: HTTP 13 | hosts: 14 | - quarkus-insurance-app.apps.cluster-5935.5935.sandbox474.opentlc.com 15 | - quarkus-person-app.apps.cluster-5935.5935.sandbox474.opentlc.com -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/repository/InsuranceRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.repository; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheRepository; 4 | import pl.redhat.samples.quarkus.insurance.model.Insurance; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | 8 | @ApplicationScoped 9 | public class InsuranceRepository implements PanacheRepository { 10 | } 11 | -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/java/pl/redhat/samples/eventdriven/order/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.eventdriven.order.domain.Order; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderRepository extends CrudRepository { 9 | 10 | List findByCustomerId(Integer customerId); 11 | } 12 | -------------------------------------------------------------------------------- /micro-view/department/src/main/java/pl/redhat/samples/department/repository/DepartmentRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.department.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.department.model.Department; 5 | 6 | import java.util.List; 7 | 8 | public interface DepartmentRepository extends CrudRepository { 9 | 10 | List findByOrganizationId(String organizationId); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/java/pl/redhat/samples/quarkus/person/PersonApplication.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person; 2 | 3 | import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; 4 | import org.eclipse.microprofile.openapi.annotations.info.Info; 5 | 6 | import jakarta.ws.rs.core.Application; 7 | 8 | @OpenAPIDefinition(info = @Info(title = "Quarkus Person Application", version = "1.0")) 9 | public class PersonApplication extends Application { 10 | } 11 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/domain/InsuranceDetails.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.domain; 2 | 3 | import pl.redhat.samples.insurance.client.message.Person; 4 | 5 | public class InsuranceDetails extends Insurance { 6 | private Person person; 7 | 8 | public Person getPerson() { 9 | return person; 10 | } 11 | 12 | public void setPerson(Person person) { 13 | this.person = person; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/repository/AccountRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.eventdriven.payment.domain.Account; 5 | 6 | import java.util.List; 7 | 8 | public interface AccountRepository extends CrudRepository { 9 | 10 | List findByCustomerId(Integer customerId); 11 | } 12 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/PersonApplication.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance; 2 | 3 | import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; 4 | import org.eclipse.microprofile.openapi.annotations.info.Info; 5 | 6 | import jakarta.ws.rs.core.Application; 7 | 8 | @OpenAPIDefinition(info = @Info(title = "Quarkus Insurance Application", version = "1.0")) 9 | public class PersonApplication extends Application { 10 | } 11 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/src/main/java/pl/redhat/samples/quarkus/person/QuarkusApplication.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person; 2 | 3 | import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; 4 | import org.eclipse.microprofile.openapi.annotations.info.Info; 5 | 6 | import jakarta.ws.rs.core.Application; 7 | 8 | @OpenAPIDefinition(info = @Info(title = "Quarkus Person Application", version = "1.0")) 9 | public class QuarkusApplication extends Application { 10 | } 11 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/QuarkusApplication.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance; 2 | 3 | import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; 4 | import org.eclipse.microprofile.openapi.annotations.info.Info; 5 | 6 | import jakarta.ws.rs.core.Application; 7 | 8 | @OpenAPIDefinition(info = @Info(title = "Quarkus Insurance Application", version = "1.0")) 9 | public class QuarkusApplication extends Application { 10 | } 11 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/model/InsuranceDetails.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.model; 2 | 3 | import pl.redhat.samples.quarkus.insurance.client.model.Person; 4 | 5 | public class InsuranceDetails extends Insurance { 6 | private Person person; 7 | 8 | public Person getPerson() { 9 | return person; 10 | } 11 | 12 | public void setPerson(Person person) { 13 | this.person = person; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/repository/InsuranceViewRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.repository; 2 | 3 | import com.blazebit.persistence.spring.data.repository.EntityViewRepository; 4 | import org.springframework.transaction.annotation.Transactional; 5 | import pl.redhat.samples.insurance.domain.InsuranceView; 6 | 7 | @Transactional(readOnly = true) 8 | public interface InsuranceViewRepository extends EntityViewRepository { 9 | } 10 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/domain/InsuranceView.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.domain; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | 6 | import java.util.Date; 7 | 8 | @EntityView(Insurance.class) 9 | public interface InsuranceView { 10 | @IdMapping 11 | Integer getId(); 12 | Integer getPersonId(); 13 | InsuranceType getType(); 14 | int getAmount(); 15 | Date getExpiry(); 16 | } 17 | -------------------------------------------------------------------------------- /micro-view/employee/src/main/java/pl/redhat/samples/employee/repository/EmployeeRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.employee.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import pl.redhat.samples.employee.model.Employee; 5 | 6 | import java.util.List; 7 | 8 | public interface EmployeeRepository extends CrudRepository { 9 | 10 | List findByDepartmentId(String departmentId); 11 | List findByOrganizationId(String organizationId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: person-service 4 | datasource: 5 | url: jdbc:oracle:thin:@ccbdb.oracle:1521/ORCLPDB1 6 | username: camel 7 | password: qw21QW@! 8 | 9 | spring.liquibase.change-log: classpath:db/changeLog.sql 10 | 11 | management: 12 | endpoints: 13 | web: 14 | exposure: 15 | include: "*" 16 | endpoint.health: 17 | show-details: always 18 | 19 | hawtio.authenticationEnabled: false 20 | camel.springboot.jmx-enabled: true -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: person-service 4 | datasource: 5 | url: jdbc:oracle:thin:@localhost:1521/XE 6 | username: system 7 | password: 84e2279989b2f349 8 | 9 | spring.liquibase.change-log: classpath:db/changeLog.sql 10 | 11 | management: 12 | endpoints: 13 | web: 14 | exposure: 15 | include: "*" 16 | endpoint.health: 17 | show-details: always 18 | 19 | hawtio.authenticationEnabled: false 20 | camel.springboot.jmx-enabled: true -------------------------------------------------------------------------------- /mesh-with-db/k8s/mesh/mesh-insurance.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1beta1 2 | kind: VirtualService 3 | metadata: 4 | name: quarkus-insurance-app-vs 5 | spec: 6 | hosts: 7 | - quarkus-insurance-app.apps.cluster-5935.5935.sandbox474.opentlc.com 8 | gateways: 9 | - microservices-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: "/insurance" 14 | rewrite: 15 | uri: " " 16 | route: 17 | - destination: 18 | host: quarkus-insurance-app 19 | weight: 100 -------------------------------------------------------------------------------- /messaging/simple-producer/src/main/java/pl/redhat/samples/messaging/simple/SimpleProducer.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.jms.annotation.EnableJms; 6 | 7 | @SpringBootApplication 8 | @EnableJms 9 | public class SimpleProducer { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SimpleProducer.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/java/pl/redhat/samples/person/repository/PersonViewRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.person.repository; 2 | 3 | import com.blazebit.persistence.spring.data.repository.EntityViewRepository; 4 | import org.springframework.transaction.annotation.Transactional; 5 | import pl.redhat.samples.person.view.PersonView; 6 | 7 | @Transactional(readOnly = true) 8 | public interface PersonViewRepository extends EntityViewRepository { 9 | PersonView findByAgeGreaterThan(int age); 10 | } 11 | -------------------------------------------------------------------------------- /messaging/k8s/kind-config.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | - role: worker 6 | kubeadmConfigPatches: 7 | - | 8 | kind: JoinConfiguration 9 | nodeRegistration: 10 | kubeletExtraArgs: 11 | node-labels: "ingress-ready=true" 12 | extraPortMappings: 13 | - containerPort: 80 14 | hostPort: 80 15 | protocol: TCP 16 | - containerPort: 443 17 | hostPort: 443 18 | protocol: TCP 19 | - role: worker 20 | - role: worker 21 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | 8 | # Eclipse 9 | .project 10 | .classpath 11 | .settings/ 12 | bin/ 13 | 14 | # IntelliJ 15 | .idea 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # NetBeans 21 | nb-configuration.xml 22 | 23 | # Visual Studio Code 24 | .vscode 25 | .factorypath 26 | 27 | # OSX 28 | .DS_Store 29 | 30 | # Vim 31 | *.swp 32 | *.swo 33 | 34 | # patch 35 | *.orig 36 | *.rej 37 | 38 | # Local environment 39 | .env 40 | -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/java/pl/redhat/samples/quarkus/person/model/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntityBase; 4 | 5 | import jakarta.persistence.*; 6 | 7 | @Entity 8 | public class Person extends PanacheEntityBase { 9 | @Id 10 | @GeneratedValue(strategy = GenerationType.IDENTITY) 11 | public Long id; 12 | public String name; 13 | public int age; 14 | @Enumerated(EnumType.STRING) 15 | public Gender gender; 16 | public Integer externalId; 17 | } 18 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/resources/import.sql: -------------------------------------------------------------------------------- 1 | insert into insurance(personId, type, amount) values(1, 'MEDICAL', 1000); 2 | insert into insurance(personId, type, amount) values(2, 'MEDICAL', 800); 3 | insert into insurance(personId, type, amount) values(3, 'LIFE', 30000); 4 | insert into insurance(personId, type, amount) values(4, 'LIFE', 20000); 5 | insert into insurance(personId, type, amount) values(5, 'MEDICAL', 1500); 6 | insert into insurance(personId, type, amount) values(6, 'LIFE', 50000); 7 | insert into insurance(personId, type, amount) values(7, 'LIFE', 50000); -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | 8 | # Eclipse 9 | .project 10 | .classpath 11 | .settings/ 12 | bin/ 13 | 14 | # IntelliJ 15 | .idea 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # NetBeans 21 | nb-configuration.xml 22 | 23 | # Visual Studio Code 24 | .vscode 25 | .factorypath 26 | 27 | # OSX 28 | .DS_Store 29 | 30 | # Vim 31 | *.swp 32 | *.swo 33 | 34 | # patch 35 | *.orig 36 | *.rej 37 | 38 | # Local environment 39 | .env 40 | 41 | .odo/odo-file-index.json -------------------------------------------------------------------------------- /basic-with-db/k6/load-tests-add.js: -------------------------------------------------------------------------------- 1 | import http from 'k6/http'; 2 | import { check } from 'k6'; 3 | 4 | export default function () { 5 | 6 | const payload = JSON.stringify({ 7 | name: 'aaa bbb', 8 | age: 50, 9 | gender: 'MALE' 10 | }); 11 | 12 | const params = { 13 | headers: { 14 | 'Content-Type': 'application/json', 15 | }, 16 | }; 17 | 18 | const res = http.post(`http://${__ENV.PERSONS_URI}/persons`, payload, params); 19 | 20 | check(res, { 21 | 'is status 200': (res) => res.status === 200, 22 | 'body size is > 0': (r) => r.body.length > 0, 23 | }); 24 | } -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/model/Insurance.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntityBase; 4 | 5 | import jakarta.persistence.*; 6 | import java.util.Date; 7 | 8 | @Entity 9 | public class Insurance extends PanacheEntityBase { 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | public Long id; 13 | public Long personId; 14 | @Enumerated(EnumType.STRING) 15 | public InsuranceType type; 16 | public int amount; 17 | public Date expiry; 18 | } 19 | -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/java/pl/redhat/samples/person/view/PersonView.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.person.view; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | import com.blazebit.persistence.view.Mapping; 6 | import pl.redhat.samples.person.domain.Person; 7 | 8 | @EntityView(Person.class) 9 | public interface PersonView { 10 | 11 | @IdMapping 12 | Integer getId(); 13 | void setId(Integer id); 14 | 15 | @Mapping("CONCAT(firstName,' ',lastName)") 16 | String getName(); 17 | void setName(String name); 18 | } 19 | -------------------------------------------------------------------------------- /event-driven/producer/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: producer 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: producer 9 | ports: 10 | - port: 8080 11 | --- 12 | apiVersion: apps/v1 13 | kind: Deployment 14 | metadata: 15 | name: producer 16 | spec: 17 | selector: 18 | matchLabels: 19 | app: producer 20 | template: 21 | metadata: 22 | labels: 23 | app: producer 24 | spec: 25 | containers: 26 | - name: producer 27 | image: piomin/producer 28 | ports: 29 | - containerPort: 8080 -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/java/pl/redhat/samples/camel/person/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.camel.person.repository; 2 | 3 | import org.springframework.data.jpa.repository.query.Procedure; 4 | import org.springframework.data.repository.CrudRepository; 5 | import org.springframework.data.repository.query.Param; 6 | import pl.redhat.samples.camel.person.domain.Person; 7 | 8 | public interface PersonRepository extends CrudRepository { 9 | 10 | @Procedure(procedureName = "COUNT_OLDER_THAN_4", outputParameterName = "COUNT_OUT") 11 | int countOlderThen(@Param("age_in") int ageIn); 12 | } 13 | -------------------------------------------------------------------------------- /messaging/simple-consumer/src/main/java/pl/redhat/samples/messaging/simple/config/AmqpConfig.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | @Configuration 6 | public class AmqpConfig { 7 | 8 | // @PostConstruct 9 | // public void init() { 10 | // RestTemplate t = new RestTemplateBuilder().build(); 11 | // int x = t.getForObject("http://simple-counter:8080/counter", Integer.class); 12 | // System.setProperty("amqphub.amqp10jms.remoteUrl", 13 | // "amqp://ex-aao-my-acceptor-" + x + "-svc:5672"); 14 | // } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cpu-killer/k6/load-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | Writer, 3 | SchemaRegistry, 4 | SCHEMA_TYPE_JSON, 5 | } from "k6/x/kafka"; 6 | const writer = new Writer({ 7 | brokers: ["my-cluster-kafka-bootstrap.kafka:9092"], 8 | topic: "events", 9 | }); 10 | const schemaRegistry = new SchemaRegistry(); 11 | export default function () { 12 | writer.produce({ 13 | messages: [ 14 | { 15 | value: schemaRegistry.serialize({ 16 | data: { 17 | id: 1 18 | }, 19 | schemaType: SCHEMA_TYPE_JSON, 20 | }), 21 | }, 22 | ], 23 | }); 24 | } 25 | 26 | export function teardown(data) { 27 | writer.close(); 28 | } -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/message/RollbackCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | public class RollbackCommand extends AbstractOrderCommand { 4 | 5 | private String orderId; 6 | private String source; 7 | 8 | public String getOrderId() { 9 | return orderId; 10 | } 11 | 12 | public void setOrderId(String orderId) { 13 | this.orderId = orderId; 14 | } 15 | 16 | public String getSource() { 17 | return source; 18 | } 19 | 20 | public void setSource(String source) { 21 | this.source = source; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpu-killer/src/test/k6/load-tests.js: -------------------------------------------------------------------------------- 1 | import { 2 | Writer, 3 | SchemaRegistry, 4 | SCHEMA_TYPE_JSON, 5 | } from "k6/x/kafka"; 6 | 7 | const writer = new Writer({ 8 | brokers: ["localhost:55001"], 9 | topic: "events", 10 | }); 11 | 12 | const schemaRegistry = new SchemaRegistry(); 13 | 14 | export default function () { 15 | writer.produce({ 16 | messages: [ 17 | { 18 | value: schemaRegistry.serialize({ 19 | data: { 20 | id: 1 21 | }, 22 | schemaType: SCHEMA_TYPE_JSON, 23 | }), 24 | }, 25 | ], 26 | }); 27 | } 28 | 29 | export function teardown(data) { 30 | writer.close(); 31 | } -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/PersonService.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client; 2 | 3 | import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; 4 | import pl.redhat.samples.quarkus.insurance.client.message.Person; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | import jakarta.ws.rs.GET; 8 | import jakarta.ws.rs.Path; 9 | import jakarta.ws.rs.PathParam; 10 | 11 | @Path("/persons") 12 | @ApplicationScoped 13 | @RegisterRestClient(configKey = "person") 14 | public interface PersonService { 15 | 16 | @GET 17 | @Path("/{id}") 18 | Person getPersonById(@PathParam("id") Long id); 19 | } 20 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/resources/db/changeLog.sql: -------------------------------------------------------------------------------- 1 | --liquibase formatted sql 2 | 3 | --changeset piomin:1 4 | create table insurance ( 5 | id serial primary key, 6 | personId int, 7 | type varchar(255), 8 | amount int, 9 | expiry date 10 | ); 11 | insert into insurance(personId, type, amount) values(1, 'MEDICAL', 1000); 12 | insert into insurance(personId, type, amount) values(2, 'MEDICAL', 800); 13 | insert into insurance(personId, type, amount) values(3, 'LIFE', 30000); 14 | insert into insurance(personId, type, amount) values(4, 'LIFE', 20000); 15 | insert into insurance(personId, type, amount) values(5, 'MEDICAL', 1500); 16 | insert into insurance(personId, type, amount) values(6, 'LIFE', 50000); -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/java/pl/redhat/samples/quarkus/person/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.repository; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheRepository; 4 | import pl.redhat.samples.quarkus.person.model.Person; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | import java.util.List; 8 | 9 | @ApplicationScoped 10 | public class PersonRepository implements PanacheRepository { 11 | 12 | public List findByName(String name) { 13 | return find("name", name).list(); 14 | } 15 | 16 | public List findByAgeGreaterThan(int age) { 17 | return find("age > ?1", age).list(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/resources/db/changeLog.sql: -------------------------------------------------------------------------------- 1 | --liquibase formatted sql 2 | 3 | --changeset piomin:1 4 | create table insurance ( 5 | id serial primary key, 6 | personId int, 7 | type varchar(255), 8 | amount int, 9 | expiry date 10 | ); 11 | insert into insurance(personId, type, amount) values(1, 'MEDICAL', 1000); 12 | insert into insurance(personId, type, amount) values(2, 'MEDICAL', 800); 13 | insert into insurance(personId, type, amount) values(3, 'LIFE', 30000); 14 | insert into insurance(personId, type, amount) values(4, 'LIFE', 20000); 15 | insert into insurance(personId, type, amount) values(5, 'MEDICAL', 1500); 16 | insert into insurance(personId, type, amount) values(6, 'LIFE', 50000); -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/message/OrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | 6 | @Entity 7 | public class OrderCommand extends AbstractOrderCommand { 8 | 9 | @Id 10 | private String id; 11 | private String status; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | 21 | public String getStatus() { 22 | return status; 23 | } 24 | 25 | public void setStatus(String status) { 26 | this.status = status; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /event-driven/streams/consumer-streams/src/main/java/pl/redhat/samples/eventdriven/domain/Customer.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.domain; 2 | 3 | public class Customer { 4 | 5 | private Integer id; 6 | private String name; 7 | 8 | public Customer() { 9 | } 10 | 11 | public Customer(Integer id, String name) { 12 | this.id = id; 13 | this.name = name; 14 | } 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/PersonService.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client; 2 | 3 | import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders; 4 | import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; 5 | import pl.redhat.samples.quarkus.insurance.client.model.Person; 6 | 7 | import jakarta.ws.rs.GET; 8 | import jakarta.ws.rs.Path; 9 | import jakarta.ws.rs.PathParam; 10 | 11 | @Path("/persons") 12 | @RegisterRestClient 13 | @RegisterClientHeaders(RequestHeaderFactory.class) 14 | public interface PersonService { 15 | 16 | @GET 17 | @Path("/{id}") 18 | Person getPersonById(@PathParam("id") Long id); 19 | } 20 | -------------------------------------------------------------------------------- /micro-view/department/src/main/java/pl/redhat/samples/department/DepartmentApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.department; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.client.RestTemplateBuilder; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @SpringBootApplication 10 | public class DepartmentApp { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(DepartmentApp.class, args); 14 | } 15 | 16 | @Bean 17 | RestTemplate restTemplate() { 18 | return new RestTemplateBuilder().build(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /messaging/k8s/broker-kind.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: broker.amq.io/v1beta1 2 | kind: ActiveMQArtemis 3 | metadata: 4 | name: ex-aao 5 | spec: 6 | deploymentPlan: 7 | size: 3 8 | image: placeholder 9 | messageMigration: true 10 | resources: 11 | limits: 12 | cpu: "500m" 13 | memory: "1024Mi" 14 | requests: 15 | cpu: "250m" 16 | memory: "512Mi" 17 | acceptors: 18 | - name: amqp 19 | protocols: amqp 20 | port: 5672 21 | connectionsAllowed: 5 22 | console: 23 | expose: true 24 | --- 25 | apiVersion: broker.amq.io/v1beta1 26 | kind: ActiveMQArtemisAddress 27 | metadata: 28 | name: address-1 29 | spec: 30 | addressName: address-1 31 | queueName: test-1 32 | routingType: anycast -------------------------------------------------------------------------------- /messaging/simple-counter/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-counter 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: simple-counter 9 | ports: 10 | - port: 8080 11 | 12 | --- 13 | apiVersion: apps/v1 14 | kind: Deployment 15 | metadata: 16 | name: simple-counter 17 | spec: 18 | replicas: 1 19 | selector: 20 | matchLabels: 21 | app: simple-counter 22 | template: 23 | metadata: 24 | labels: 25 | app: simple-counter 26 | spec: 27 | containers: 28 | - name: simple-counter 29 | image: piomin/simple-counter 30 | ports: 31 | - containerPort: 8080 32 | env: 33 | - name: DIVIDER 34 | value: '3' 35 | -------------------------------------------------------------------------------- /micro-view/organization/src/main/java/pl/redhat/samples/organization/OrganizationApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.organization; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.client.RestTemplateBuilder; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @SpringBootApplication 10 | public class OrganizationApp { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(OrganizationApp.class, args); 14 | } 15 | 16 | @Bean 17 | RestTemplate restTemplate() { 18 | return new RestTemplateBuilder().build(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cicd/apps/sample-spring-kotlin/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: sample-spring-kotlin 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: sample-spring-kotlin 9 | ports: 10 | - port: 8080 11 | --- 12 | apiVersion: apps/v1 13 | kind: Deployment 14 | metadata: 15 | name: sample-spring-kotlin 16 | spec: 17 | replicas: 2 18 | selector: 19 | matchLabels: 20 | app: sample-spring-kotlin 21 | template: 22 | metadata: 23 | labels: 24 | app: sample-spring-kotlin 25 | spec: 26 | containers: 27 | - name: sample-spring-kotlin 28 | image: image-registry.openshift-image-registry.svc:5000/piotr-cicd/sample-spring-kotlin:1.4.0 29 | ports: 30 | - containerPort: 8080 31 | -------------------------------------------------------------------------------- /event-driven/streams/producer-streams/src/main/java/pl/redhat/samples/eventdriven/streams/producer/message/Customer.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.streams.producer.message; 2 | 3 | public class Customer { 4 | 5 | private Integer id; 6 | private String name; 7 | 8 | public Customer() { 9 | } 10 | 11 | public Customer(Integer id, String name) { 12 | this.id = id; 13 | this.name = name; 14 | } 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cpu-killer/src/main/java/pl/redhat/samples/cpukiller/message/PingEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.cpukiller.message; 2 | 3 | public class PingEvent { 4 | private Long id; 5 | private String bigNumber; 6 | 7 | public Long getId() { 8 | return id; 9 | } 10 | 11 | public void setId(Long id) { 12 | this.id = id; 13 | } 14 | 15 | public String getBigNumber() { 16 | return bigNumber; 17 | } 18 | 19 | public void setBigNumber(String bigNumber) { 20 | this.bigNumber = bigNumber; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "PingEvent{" + 26 | "id=" + id + 27 | ", bigNumber='" + bigNumber + '\'' + 28 | '}'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | 3 | jobs: 4 | analyze: 5 | docker: 6 | - image: 'cimg/openjdk:25.0' 7 | steps: 8 | - checkout 9 | - run: 10 | name: Analyze on SonarCloud 11 | command: mvn verify sonar:sonar -DskipTests 12 | test: 13 | executor: machine_executor_amd64 14 | steps: 15 | - checkout 16 | - run: 17 | name: Maven Tests 18 | command: mvn test 19 | 20 | orbs: 21 | maven: circleci/maven@2.1.1 22 | 23 | executors: 24 | machine_executor_amd64: 25 | machine: 26 | image: ubuntu-2204:current 27 | environment: 28 | architecture: "amd64" 29 | platform: "linux/amd64" 30 | 31 | workflows: 32 | maven_test: 33 | jobs: 34 | - test 35 | - analyze: 36 | context: SonarCloud -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/java/pl/redhat/samples/quarkus/person/startup/StartupListener.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.startup; 2 | 3 | import io.quarkus.runtime.StartupEvent; 4 | import org.jboss.logging.Logger; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | import jakarta.enterprise.event.Observes; 8 | import jakarta.inject.Inject; 9 | 10 | @ApplicationScoped 11 | public class StartupListener { 12 | 13 | @Inject 14 | Logger log; 15 | 16 | public void event(@Observes StartupEvent ev) { 17 | final long delay = 0; 18 | try { 19 | Thread.sleep(delay); 20 | } catch (InterruptedException e) { 21 | throw new RuntimeException(e); 22 | } 23 | log.infof("Application startup - %d ms delay", delay); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/java/pl/redhat/samples/eventdriven/gateway/message/OrderQueryResult.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.gateway.message; 2 | 3 | import java.util.List; 4 | 5 | public class OrderQueryResult { 6 | 7 | private String queryId; 8 | private List orders; 9 | 10 | public OrderQueryResult(String queryId, List orders) { 11 | this.queryId = queryId; 12 | this.orders = orders; 13 | } 14 | 15 | public String getQueryId() { 16 | return queryId; 17 | } 18 | 19 | public void setQueryId(String queryId) { 20 | this.queryId = queryId; 21 | } 22 | 23 | public List getOrders() { 24 | return orders; 25 | } 26 | 27 | public void setOrders(List orders) { 28 | this.orders = orders; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /event-driven/streams/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | event-driven 7 | pl.redhat.samples 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | streams 13 | pom 14 | 15 | 16 | ${project.artifactId} 17 | 18 | 19 | 20 | consumer-streams 21 | producer-streams 22 | 23 | 24 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/model/InsuranceDetails.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.model; 2 | 3 | import pl.redhat.samples.quarkus.insurance.client.message.Person; 4 | 5 | public class InsuranceDetails { 6 | private Person person; 7 | private Insurance insurance; 8 | 9 | public InsuranceDetails(Person person, Insurance insurance) { 10 | this.person = person; 11 | this.insurance = insurance; 12 | } 13 | 14 | public Person getPerson() { 15 | return person; 16 | } 17 | 18 | public void setPerson(Person person) { 19 | this.person = person; 20 | } 21 | 22 | public Insurance getInsurance() { 23 | return insurance; 24 | } 25 | 26 | public void setInsurance(Insurance insurance) { 27 | this.insurance = insurance; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /messaging/simple-consumer/src/main/java/pl/redhat/samples/messaging/simple/SimpleConsumer.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.jms.annotation.EnableJms; 7 | import pl.redhat.samples.messaging.simple.message.SimpleMessage; 8 | 9 | import java.util.concurrent.BlockingQueue; 10 | import java.util.concurrent.LinkedBlockingDeque; 11 | 12 | @SpringBootApplication 13 | @EnableJms 14 | public class SimpleConsumer { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(SimpleConsumer.class, args); 18 | } 19 | 20 | @Bean 21 | BlockingQueue events() { 22 | return new LinkedBlockingDeque<>(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/java/pl/redhat/samples/eventdriven/order/message/OrderQueryResult.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | import pl.redhat.samples.eventdriven.order.domain.Order; 4 | 5 | import java.util.List; 6 | 7 | public class OrderQueryResult { 8 | 9 | private String queryId; 10 | private List orders; 11 | 12 | public OrderQueryResult(String queryId, List orders) { 13 | this.queryId = queryId; 14 | this.orders = orders; 15 | } 16 | 17 | public String getQueryId() { 18 | return queryId; 19 | } 20 | 21 | public void setQueryId(String queryId) { 22 | this.queryId = queryId; 23 | } 24 | 25 | public List getOrders() { 26 | return orders; 27 | } 28 | 29 | public void setOrders(List orders) { 30 | this.orders = orders; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/client/message/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.client.message; 2 | 3 | public class Person { 4 | private Long id; 5 | private String name; 6 | private int age; 7 | private Gender gender; 8 | 9 | public Long getId() { 10 | return id; 11 | } 12 | 13 | public void setId(Long id) { 14 | this.id = id; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | public Gender getGender() { 34 | return gender; 35 | } 36 | 37 | public void setGender(Gender gender) { 38 | this.gender = gender; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/message/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client.message; 2 | 3 | public class Person { 4 | private Long id; 5 | private String name; 6 | private int age; 7 | private Gender gender; 8 | 9 | public Long getId() { 10 | return id; 11 | } 12 | 13 | public void setId(Long id) { 14 | this.id = id; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | 33 | public Gender getGender() { 34 | return gender; 35 | } 36 | 37 | public void setGender(Gender gender) { 38 | this.gender = gender; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: insurance-service 4 | datasource: 5 | url: jdbc:postgresql://insurance-db:5432/${DATABASE_NAME} 6 | username: ${DATABASE_USER} 7 | password: ${DATABASE_PASSWORD} 8 | jpa: 9 | hibernate: 10 | ddl-auto: create 11 | properties: 12 | hibernate: 13 | show_sql: true 14 | format_sql: true 15 | 16 | dekorate: 17 | openshift: 18 | auto-deploy-enabled: true 19 | # deployment-kind: Deployment 20 | replicas: 2 21 | expose: true 22 | env-vars: 23 | - name: DATABASE_USER 24 | value: database-user 25 | secret: person-db 26 | - name: DATABASE_PASSWORD 27 | value: database-password 28 | secret: person-db 29 | - name: DATABASE_NAME 30 | value: database-name 31 | secret: person-db 32 | s2i: 33 | enable: true 34 | auto-deploy-enabled: true -------------------------------------------------------------------------------- /camel-spring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.5.9 9 | 10 | 11 | 1.0-SNAPSHOT 12 | 4.0.0 13 | 14 | pl.redhat.samples 15 | camel-spring 16 | pom 17 | 18 | 19 | ${project.artifactId} 20 | 21 | 22 | 23 | person-demo 24 | 25 | 26 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring.application.name: payment-service 2 | 3 | spring.kafka.bootstrap-servers: pminkows-k-c-ma--adc-smj-himh-g.bf2.kafka.rhcloud.com:443 4 | 5 | spring.cloud.function.definition: orders;confirmations 6 | spring.cloud.stream.bindings.orders-in-0.destination: user.pminkows.ordercommand 7 | spring.cloud.stream.bindings.orders-out-0.destination: user.pminkows.orderevent 8 | spring.cloud.stream.bindings.confirmations-in-0.destination: user.pminkows.confirmorder 9 | 10 | spring.cloud.stream.kafka.binder.configuration.security.protocol: SASL_SSL 11 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism: PLAIN 12 | spring.cloud.stream.kafka.binder.jaas.loginModule: org.apache.kafka.common.security.plain.PlainLoginModule 13 | spring.cloud.stream.kafka.binder.jaas.options.username: srvc-acct-7e2b5429-257e-4b32-a0a7-593d20310267 14 | spring.cloud.stream.kafka.binder.jaas.options.password: 25f07668-33d8-494b-9791-10acbc485b7f -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/resources/db/changeLog.sql: -------------------------------------------------------------------------------- 1 | --liquibase formatted sql 2 | 3 | --changeset piomin:1 4 | create table person ( 5 | id integer GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1), 6 | name varchar(255), 7 | gender varchar(255), 8 | age int, 9 | externalId int 10 | ); 11 | insert into person(name, age, gender) values('John Smith', 25, 'MALE'); 12 | insert into person(name, age, gender) values('Paul Walker', 65, 'MALE'); 13 | insert into person(name, age, gender) values('Lewis Hamilton', 35, 'MALE'); 14 | insert into person(name, age, gender) values('Veronica Jones', 20, 'FEMALE'); 15 | insert into person(name, age, gender) values('Anne Brown', 60, 'FEMALE'); 16 | insert into person(name, age, gender) values('Felicia Scott', 45, 'FEMALE'); 17 | 18 | --changeset piomin:2 19 | CREATE PROCEDURE COUNT_OLDER_THAN_4(IN age_in INTEGER, OUT count_out INTEGER) 20 | IS 21 | BEGIN 22 | SELECT COUNT(*) into count_out from person WHERE age > age_in; 23 | END; 24 | / -------------------------------------------------------------------------------- /messaging/simple-consumer/src/main/java/pl/redhat/samples/messaging/simple/consumer/Listener.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple.consumer; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.jms.annotation.JmsListener; 6 | import org.springframework.stereotype.Service; 7 | import pl.redhat.samples.messaging.simple.message.SimpleMessage; 8 | 9 | import java.util.concurrent.BlockingQueue; 10 | 11 | @Service 12 | public class Listener { 13 | 14 | private static final Logger LOG = LoggerFactory.getLogger(Listener.class); 15 | private BlockingQueue events; 16 | 17 | public Listener(BlockingQueue events) { 18 | this.events = events; 19 | } 20 | 21 | @JmsListener(destination = "test-1") 22 | public void processMsg(SimpleMessage message) throws InterruptedException { 23 | LOG.info("============= Received: " + message); 24 | events.put(message); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /micro-view/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.5.9 9 | 10 | 11 | 4.0.0 12 | 13 | pl.redhat.samples 14 | micro-view 15 | 1.0-SNAPSHOT 16 | pom 17 | 18 | 19 | employee 20 | department 21 | organization 22 | 23 | 24 | 25 | ${project.artifactId} 26 | 27 | 28 | -------------------------------------------------------------------------------- /basic-with-db/person-app/src/test/java/pl/redhat/samples/quarkus/person/PersonRepositoryTests.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | import pl.redhat.samples.quarkus.person.model.Gender; 8 | import pl.redhat.samples.quarkus.person.model.Person; 9 | import pl.redhat.samples.quarkus.person.repository.PersonRepository; 10 | 11 | import jakarta.inject.Inject; 12 | 13 | @QuarkusTest 14 | @TestTransaction 15 | public class PersonRepositoryTests { 16 | 17 | @Inject 18 | PersonRepository personRepository; 19 | 20 | @Test 21 | void addPerson() { 22 | Person newPerson = new Person(); 23 | newPerson.age = 22; 24 | newPerson.name = "TestNew"; 25 | newPerson.gender = Gender.FEMALE; 26 | personRepository.persist(newPerson); 27 | Assertions.assertNotNull(newPerson.id); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring.application.name: event-gateway 2 | 3 | spring.kafka.bootstrap-servers: pminkows-k-c-ma--adc-smj-himh-g.bf2.kafka.rhcloud.com:443 4 | 5 | spring.cloud.stream.source: orders 6 | spring.cloud.stream.bindings.orders-out-0.destination: user.pminkows.ordercommand 7 | spring.cloud.stream.bindings.queries-out-0.destination: user.pminkows.orderquery 8 | spring.cloud.stream.bindings.queries-in-0.destination: user.pminkows.orderqueryresult 9 | 10 | spring.cloud.stream.kafka.binder.configuration.security.protocol: SASL_SSL 11 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism: PLAIN 12 | spring.cloud.stream.kafka.binder.jaas.loginModule: org.apache.kafka.common.security.plain.PlainLoginModule 13 | spring.cloud.stream.kafka.binder.jaas.options.username: srvc-acct-7e2b5429-257e-4b32-a0a7-593d20310267 14 | spring.cloud.stream.kafka.binder.jaas.options.password: 25f07668-33d8-494b-9791-10acbc485b7f 15 | 16 | 17 | logging.level.org.springframework.cloud.stream: DEBUG -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/kubernetes/openshift.yml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: microservices-gateway 5 | spec: 6 | selector: 7 | istio: ingressgateway 8 | servers: 9 | - port: 10 | number: 80 11 | name: http 12 | protocol: HTTP 13 | hosts: 14 | - quarkus-insurance-app.apps.cluster-5935.5935.sandbox474.opentlc.com 15 | - quarkus-person-app.apps.cluster-5935.5935.sandbox474.opentlc.com 16 | --- 17 | apiVersion: networking.istio.io/v1beta1 18 | kind: VirtualService 19 | metadata: 20 | name: quarkus-insurance-app-vs 21 | spec: 22 | hosts: 23 | - quarkus-insurance-app.apps.cluster-5935.5935.sandbox474.opentlc.com 24 | gateways: 25 | - microservices-gateway 26 | http: 27 | - match: 28 | - uri: 29 | prefix: "/insurance" 30 | rewrite: 31 | uri: " " 32 | route: 33 | - destination: 34 | host: quarkus-insurance-app 35 | weight: 100 -------------------------------------------------------------------------------- /micro-springboot/person-service/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: person-service 5 | labels: 6 | app: person 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | app: person 11 | ports: 12 | - port: 8080 13 | name: http 14 | - port: 8081 15 | name: mgmt 16 | --- 17 | apiVersion: apps/v1 18 | kind: Deployment 19 | metadata: 20 | name: person-deployment 21 | spec: 22 | selector: 23 | matchLabels: 24 | app: person 25 | template: 26 | metadata: 27 | labels: 28 | app: person 29 | spec: 30 | containers: 31 | - name: person 32 | image: piomin/person 33 | ports: 34 | - containerPort: 8080 35 | name: http 36 | - containerPort: 8081 37 | name: mgmt 38 | env: 39 | - name: DATABASE_NAME 40 | value: postgres 41 | - name: DATABASE_USER 42 | value: postgres 43 | - name: DATABASE_PASSWORD 44 | value: debezium 45 | -------------------------------------------------------------------------------- /messaging/simple-producer/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-producer 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: simple-producer 9 | ports: 10 | - port: 8080 11 | --- 12 | apiVersion: apps/v1 13 | kind: Deployment 14 | metadata: 15 | name: simple-producer 16 | spec: 17 | replicas: 3 18 | selector: 19 | matchLabels: 20 | app: simple-producer 21 | template: 22 | metadata: 23 | labels: 24 | app: simple-producer 25 | spec: 26 | containers: 27 | - name: simple-producer 28 | image: piomin/simple-producer 29 | env: 30 | - name: ARTEMIS_URL 31 | # value: failover:(amqp://ex-aao-amqp-acceptor-0-svc:5672,amqp://ex-aao-amqp-acceptor-1-svc:5672,amqp://ex-aao-amqp-acceptor-2-svc:5672)?failover.randomize=true 32 | value: amqp://ex-aao-amqp-lb:5672 33 | - name: DESTINATION 34 | value: test-1 35 | ports: 36 | - containerPort: 8080 37 | -------------------------------------------------------------------------------- /messaging/simple-counter/src/main/java/pl/redhat/samples/messaging/counter/CounterApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.counter; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @SpringBootApplication 11 | @RestController 12 | @RequestMapping("/counter") 13 | public class CounterApp { 14 | 15 | private static int c = 0; 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(CounterApp.class, args); 19 | } 20 | 21 | @Value("${DIVIDER:0}") 22 | int divider; 23 | 24 | @GetMapping 25 | public Integer count() { 26 | if (divider > 0) 27 | return c++ % divider; 28 | else 29 | return c++; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/client/PersonClient.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.client; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.web.client.HttpStatusCodeException; 6 | import org.springframework.web.client.RestTemplate; 7 | import pl.redhat.samples.insurance.client.message.Person; 8 | 9 | @Service 10 | public class PersonClient { 11 | 12 | @Value("${PERSON_SERVICE_URL:http://localhost}") 13 | private String personServiceUrl; 14 | private RestTemplate restTemplate; 15 | 16 | public PersonClient(RestTemplate restTemplate) { 17 | this.restTemplate = restTemplate; 18 | } 19 | 20 | public Person getPersonById(Integer personId) { 21 | try { 22 | return restTemplate.getForObject(personServiceUrl + "/persons/{id}", Person.class, personId); 23 | } catch (HttpStatusCodeException e) { 24 | return null; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/java/pl/redhat/samples/eventdriven/gateway/EventGatewayApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import pl.redhat.samples.eventdriven.gateway.message.Order; 7 | import pl.redhat.samples.eventdriven.gateway.message.OrderQueryResult; 8 | 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.function.Consumer; 13 | 14 | @SpringBootApplication 15 | public class EventGatewayApp { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(EventGatewayApp.class, args); 19 | } 20 | 21 | @Bean 22 | public Consumer queries() { 23 | return input -> results().put(input.getQueryId(), input.getOrders()); 24 | } 25 | 26 | @Bean 27 | Map> results() { 28 | return new HashMap(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cicd/pipelines/tekton-maven-version.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: tekton.dev/v1beta1 2 | kind: Task 3 | metadata: 4 | name: maven-get-project-version 5 | spec: 6 | workspaces: 7 | - name: source 8 | params: 9 | - name: MAVEN_IMAGE 10 | type: string 11 | description: Maven base image 12 | default: gcr.io/cloud-builders/mvn@sha256:57523fc43394d6d9d2414ee8d1c85ed7a13460cbb268c3cd16d28cfb3859e641 13 | - name: CONTEXT_DIR 14 | type: string 15 | description: >- 16 | The context directory within the repository for sources on 17 | which we want to execute maven goals. 18 | default: "." 19 | results: 20 | - description: Project version read from pom.xml 21 | name: version 22 | steps: 23 | - name: mvn-command 24 | image: $(params.MAVEN_IMAGE) 25 | workingDir: $(workspaces.source.path)/$(params.CONTEXT_DIR) 26 | script: | 27 | #!/usr/bin/env bash 28 | VERSION=$(/usr/bin/mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 29 | echo -n $VERSION | tee $(results.version.path) 30 | -------------------------------------------------------------------------------- /deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: postgresql 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: postgresql 9 | template: 10 | metadata: 11 | labels: 12 | app: postgresql 13 | spec: 14 | containers: 15 | - name: postgresql 16 | image: registry.redhat.io/rhel9/postgresql-15 17 | resources: 18 | requests: 19 | memory: "128Mi" 20 | cpu: "200m" 21 | limits: 22 | memory: "512Mi" 23 | cpu: "500m" 24 | ports: 25 | - containerPort: 5432 26 | env: 27 | - name: POSTGRESQL_USER 28 | value: spring 29 | - name: POSTGRESQL_PASSWORD 30 | value: spring123 31 | - name: POSTGRESQL_DATABASE 32 | value: sampledb 33 | --- 34 | apiVersion: v1 35 | kind: Service 36 | metadata: 37 | name: postgresql 38 | labels: 39 | app: postgresql 40 | spec: 41 | type: ClusterIP 42 | selector: 43 | app: postgresql 44 | ports: 45 | - port: 5432 46 | name: tcp -------------------------------------------------------------------------------- /cpu-killer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | %prod.kafka.bootstrap.servers = ${KAFKA_BOOTSTRAP_SERVERS} 2 | 3 | mp.messaging.incoming.events.connector = smallrye-kafka 4 | mp.messaging.incoming.events.topic = events 5 | mp.messaging.incoming.events.partitions = 10 6 | mp.messaging.incoming.events.group.id = ${quarkus.uuid} 7 | #mp.messaging.incoming.events.value.serializer = io.quarkus.kafka.client.serialization.ObjectMapperDeserializer 8 | 9 | quarkus.kubernetes-client.trust-certs = true 10 | quarkus.kubernetes.deployment-target = knative 11 | quarkus.container-image.group = demo-apps 12 | quarkus.container-image.registry = image-registry.openshift-image-registry.svc:5000 13 | 14 | quarkus.knative.min-scale = 3 15 | quarkus.knative.revision-auto-scaling.auto-scaler-class = hpa 16 | quarkus.knative.revision-auto-scaling.metric = cpu 17 | quarkus.knative.revision-auto-scaling.target-utilization-percentage = 80 18 | quarkus.knative.resources.limits.cpu = 2000m 19 | quarkus.knative.resources.requests.cpu = 1000m 20 | quarkus.knative.env.vars.kafka-bootstrap-servers = my-cluster-kafka-bootstrap.kafka:9092 21 | -------------------------------------------------------------------------------- /messaging/simple-consumer/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: simple-consumer 5 | spec: 6 | replicas: 3 7 | selector: 8 | matchLabels: 9 | app: simple-consumer 10 | template: 11 | metadata: 12 | labels: 13 | app: simple-consumer 14 | spec: 15 | containers: 16 | - name: simple-consumer 17 | image: piomin/simple-consumer 18 | env: 19 | - name: ARTEMIS_URL 20 | # value: failover:(amqp://ex-aao-amqp-0-svc:5672,amqp://ex-aao-amqp-1-svc:5672,amqp://ex-aao-amqp-2-svc:5672)?failover.randomize=true 21 | value: amqp://ex-aao-amqp-lb:5672 22 | resources: 23 | limits: 24 | memory: 256Mi 25 | cpu: 500m 26 | requests: 27 | memory: 128Mi 28 | cpu: 250m 29 | --- 30 | kind: Service 31 | apiVersion: v1 32 | metadata: 33 | name: ex-aao-amqp-lb 34 | spec: 35 | ports: 36 | - name: amqp 37 | protocol: TCP 38 | port: 5672 39 | type: ClusterIP 40 | selector: 41 | application: ex-aao-app 42 | -------------------------------------------------------------------------------- /messaging/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.5.9 9 | 10 | 11 | 1.0-SNAPSHOT 12 | 4.0.0 13 | 14 | pl.redhat.samples 15 | messaging 16 | pom 17 | 18 | simple-consumer 19 | simple-counter 20 | simple-producer 21 | 22 | 23 | 24 | ${project.artifactId} 25 | 17 26 | 3.5.3 27 | 28 | 29 | -------------------------------------------------------------------------------- /event-driven/order-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring.application.name: order-service 2 | 3 | spring.kafka.bootstrap-servers: pminkows-k-c-ma--adc-smj-himh-g.bf2.kafka.rhcloud.com:443 4 | 5 | spring.cloud.function.definition: orders;events;failedEvents 6 | spring.cloud.stream.source: confirmations 7 | spring.cloud.stream.bindings.orders-in-0.destination: user.pminkows.ordercommand 8 | spring.cloud.stream.bindings.events-in-0.destination: user.pminkows.orderevent 9 | spring.cloud.stream.bindings.failedEvents-in-0.destination: user.pminkows.orderevent 10 | spring.cloud.stream.bindings.confirmations-out-0.destination: user.pminkows.confirmcommand 11 | 12 | spring.cloud.stream.kafka.binder.configuration.security.protocol: SASL_SSL 13 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism: PLAIN 14 | spring.cloud.stream.kafka.binder.jaas.loginModule: org.apache.kafka.common.security.plain.PlainLoginModule 15 | spring.cloud.stream.kafka.binder.jaas.options.username: srvc-acct-7e2b5429-257e-4b32-a0a7-593d20310267 16 | spring.cloud.stream.kafka.binder.jaas.options.password: 25f07668-33d8-494b-9791-10acbc485b7f -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/java/pl/redhat/samples/eventdriven/order/message/OrderQuery.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | import java.util.Date; 4 | 5 | public class OrderQuery { 6 | 7 | private String queryId; 8 | private Integer customerId; 9 | private Date startDate; 10 | private Date endDate; 11 | 12 | public String getQueryId() { 13 | return queryId; 14 | } 15 | 16 | public void setQueryId(String queryId) { 17 | this.queryId = queryId; 18 | } 19 | 20 | public Integer getCustomerId() { 21 | return customerId; 22 | } 23 | 24 | public void setCustomerId(Integer customerId) { 25 | this.customerId = customerId; 26 | } 27 | 28 | public Date getStartDate() { 29 | return startDate; 30 | } 31 | 32 | public void setStartDate(Date startDate) { 33 | this.startDate = startDate; 34 | } 35 | 36 | public Date getEndDate() { 37 | return endDate; 38 | } 39 | 40 | public void setEndDate(Date endDate) { 41 | this.endDate = endDate; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /event-driven/consumer/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: consumer-deployment 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: consumer 9 | template: 10 | metadata: 11 | labels: 12 | app: consumer 13 | spec: 14 | containers: 15 | - name: consumer 16 | image: piomin/consumer 17 | ports: 18 | - containerPort: 8080 19 | --- 20 | apiVersion: keda.sh/v1alpha1 21 | kind: ScaledObject 22 | metadata: 23 | name: consumer-scaled 24 | spec: 25 | scaleTargetRef: 26 | name: consumer-deployment 27 | cooldownPeriod: 30 28 | maxReplicaCount: 10 29 | advanced: 30 | horizontalPodAutoscalerConfig: 31 | behavior: 32 | scaleDown: 33 | stabilizationWindowSeconds: 30 34 | policies: 35 | - type: Percent 36 | value: 50 37 | periodSeconds: 30 38 | triggers: 39 | - type: kafka 40 | metadata: 41 | bootstrapServers: one-node-cluster.redpanda:9092 42 | consumerGroup: a 43 | topic: test-topic 44 | lagThreshold: '10' -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/domain/Product.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.GenerationType; 6 | import jakarta.persistence.Id; 7 | 8 | @Entity 9 | public class Product { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private Integer id; 14 | private int currentCount; 15 | private int reservedCount; 16 | 17 | public Integer getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Integer id) { 22 | this.id = id; 23 | } 24 | 25 | public int getCurrentCount() { 26 | return currentCount; 27 | } 28 | 29 | public void setCurrentCount(int currentCount) { 30 | this.currentCount = currentCount; 31 | } 32 | 33 | public int getReservedCount() { 34 | return reservedCount; 35 | } 36 | 37 | public void setReservedCount(int reservedCount) { 38 | this.reservedCount = reservedCount; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/java/pl/redhat/samples/camel/person/service/PersonService.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.camel.person.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | import pl.redhat.samples.camel.person.domain.Person; 5 | import pl.redhat.samples.camel.person.repository.PersonRepository; 6 | 7 | import java.util.List; 8 | 9 | @Service 10 | public class PersonService { 11 | 12 | private PersonRepository repository; 13 | 14 | public PersonService(PersonRepository repository) { 15 | this.repository = repository; 16 | } 17 | 18 | public List findAll() { 19 | return (List) repository.findAll(); 20 | } 21 | 22 | public Person findById(Integer id) { 23 | return repository.findById(id).orElseThrow(); 24 | } 25 | 26 | public int countOlderThan(int ageIn) { 27 | return repository.countOlderThen(ageIn); 28 | } 29 | 30 | public Person add(Person person) { 31 | return repository.save(person); 32 | } 33 | 34 | public void delete(Integer id) { 35 | repository.deleteById(id); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/java/pl/redhat/samples/eventdriven/gateway/message/AbstractOrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.gateway.message; 2 | 3 | public abstract class AbstractOrderCommand { 4 | 5 | private Integer customerId; 6 | private Integer productId; 7 | private int productCount; 8 | private int amount; 9 | 10 | public Integer getCustomerId() { 11 | return customerId; 12 | } 13 | 14 | public void setCustomerId(Integer customerId) { 15 | this.customerId = customerId; 16 | } 17 | 18 | public Integer getProductId() { 19 | return productId; 20 | } 21 | 22 | public void setProductId(Integer productId) { 23 | this.productId = productId; 24 | } 25 | 26 | public int getProductCount() { 27 | return productCount; 28 | } 29 | 30 | public void setProductCount(int productCount) { 31 | this.productCount = productCount; 32 | } 33 | 34 | public int getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(int amount) { 39 | this.amount = amount; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/message/AbstractOrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | public abstract class AbstractOrderCommand { 4 | 5 | private Integer customerId; 6 | private Integer productId; 7 | private int productCount; 8 | private int amount; 9 | 10 | public Integer getCustomerId() { 11 | return customerId; 12 | } 13 | 14 | public void setCustomerId(Integer customerId) { 15 | this.customerId = customerId; 16 | } 17 | 18 | public Integer getProductId() { 19 | return productId; 20 | } 21 | 22 | public void setProductId(Integer productId) { 23 | this.productId = productId; 24 | } 25 | 26 | public int getProductCount() { 27 | return productCount; 28 | } 29 | 30 | public void setProductCount(int productCount) { 31 | this.productCount = productCount; 32 | } 33 | 34 | public int getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(int amount) { 39 | this.amount = amount; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/java/pl/redhat/samples/eventdriven/order/message/AbstractOrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | public abstract class AbstractOrderCommand { 4 | 5 | private Integer customerId; 6 | private Integer productId; 7 | private int productCount; 8 | private int amount; 9 | 10 | public Integer getCustomerId() { 11 | return customerId; 12 | } 13 | 14 | public void setCustomerId(Integer customerId) { 15 | this.customerId = customerId; 16 | } 17 | 18 | public Integer getProductId() { 19 | return productId; 20 | } 21 | 22 | public void setProductId(Integer productId) { 23 | this.productId = productId; 24 | } 25 | 26 | public int getProductCount() { 27 | return productCount; 28 | } 29 | 30 | public void setProductCount(int productCount) { 31 | this.productCount = productCount; 32 | } 33 | 34 | public int getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(int amount) { 39 | this.amount = amount; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/message/AbstractOrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.message; 2 | 3 | public abstract class AbstractOrderCommand { 4 | 5 | private Integer customerId; 6 | private Integer productId; 7 | private int productCount; 8 | private int amount; 9 | 10 | public Integer getCustomerId() { 11 | return customerId; 12 | } 13 | 14 | public void setCustomerId(Integer customerId) { 15 | this.customerId = customerId; 16 | } 17 | 18 | public Integer getProductId() { 19 | return productId; 20 | } 21 | 22 | public void setProductId(Integer productId) { 23 | this.productId = productId; 24 | } 25 | 26 | public int getProductCount() { 27 | return productCount; 28 | } 29 | 30 | public void setProductCount(int productCount) { 31 | this.productCount = productCount; 32 | } 33 | 34 | public int getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(int amount) { 39 | this.amount = amount; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/message/AbstractOrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.message; 2 | 3 | public abstract class AbstractOrderCommand { 4 | 5 | private Integer customerId; 6 | private Integer productId; 7 | private int productCount; 8 | private int amount; 9 | 10 | public Integer getCustomerId() { 11 | return customerId; 12 | } 13 | 14 | public void setCustomerId(Integer customerId) { 15 | this.customerId = customerId; 16 | } 17 | 18 | public Integer getProductId() { 19 | return productId; 20 | } 21 | 22 | public void setProductId(Integer productId) { 23 | this.productId = productId; 24 | } 25 | 26 | public int getProductCount() { 27 | return productCount; 28 | } 29 | 30 | public void setProductCount(int productCount) { 31 | this.productCount = productCount; 32 | } 33 | 34 | public int getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(int amount) { 39 | this.amount = amount; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/message/OrderCommandDelayed.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.message; 2 | 3 | import jakarta.validation.constraints.NotNull; 4 | 5 | import java.util.concurrent.Delayed; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | public class OrderCommandDelayed implements Delayed { 9 | 10 | private OrderCommand orderCommand; 11 | private long startTime; 12 | 13 | public OrderCommandDelayed(OrderCommand orderCommand, long delayInMilliseconds) { 14 | this.orderCommand = orderCommand; 15 | this.startTime = System.currentTimeMillis() + delayInMilliseconds; 16 | } 17 | 18 | @Override 19 | public long getDelay(@NotNull TimeUnit unit) { 20 | long diff = startTime - System.currentTimeMillis(); 21 | return unit.convert(diff, TimeUnit.MILLISECONDS); 22 | } 23 | 24 | @Override 25 | public int compareTo(@NotNull Delayed o) { 26 | return (int) (this.startTime - ((OrderCommandDelayed) o).startTime); 27 | } 28 | 29 | public OrderCommand getOrderCommand() { 30 | return orderCommand; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/model/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client.model; 2 | 3 | public class Person { 4 | private Long id; 5 | private String name; 6 | private int age; 7 | private Gender gender; 8 | private Integer externalId; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public int getAge() { 27 | return age; 28 | } 29 | 30 | public void setAge(int age) { 31 | this.age = age; 32 | } 33 | 34 | public Gender getGender() { 35 | return gender; 36 | } 37 | 38 | public void setGender(Gender gender) { 39 | this.gender = gender; 40 | } 41 | 42 | public Integer getExternalId() { 43 | return externalId; 44 | } 45 | 46 | public void setExternalId(Integer externalId) { 47 | this.externalId = externalId; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /micro-view/organization/src/main/java/pl/redhat/samples/organization/model/Department.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.organization.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Department { 7 | 8 | private String id; 9 | private String name; 10 | private List employees = new ArrayList<>(); 11 | 12 | public Department() { 13 | 14 | } 15 | 16 | public Department(String name) { 17 | super(); 18 | this.name = name; 19 | } 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public List getEmployees() { 38 | return employees; 39 | } 40 | 41 | public void setEmployees(List employees) { 42 | this.employees = employees; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "Department [id=" + id + ", name=" + name + "]"; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /event-driven/streams/producer-streams/src/main/java/pl/redhat/samples/eventdriven/streams/producer/message/Order.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.streams.producer.message; 2 | 3 | public class Order { 4 | 5 | private Integer id; 6 | private String status; 7 | private Integer customerId; 8 | 9 | public Order() { 10 | } 11 | 12 | public Order(Integer id, String status) { 13 | this.id = id; 14 | this.status = status; 15 | } 16 | 17 | public Order(Integer id, String status, Integer customerId) { 18 | this.id = id; 19 | this.status = status; 20 | this.customerId = customerId; 21 | } 22 | 23 | public Integer getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Integer id) { 28 | this.id = id; 29 | } 30 | 31 | public String getStatus() { 32 | return status; 33 | } 34 | 35 | public void setStatus(String status) { 36 | this.status = status; 37 | } 38 | 39 | public Integer getCustomerId() { 40 | return customerId; 41 | } 42 | 43 | public void setCustomerId(Integer customerId) { 44 | this.customerId = customerId; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /event-driven/streams/producer-streams/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | pl.redhat.samples 8 | streams 9 | 1.0-SNAPSHOT 10 | 11 | 4.0.0 12 | 13 | producer-streams 14 | 15 | 16 | ${project.artifactId} 17 | 18 | 19 | 20 | 21 | org.springframework.cloud 22 | spring-cloud-starter-stream-kafka 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-maven-plugin 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/src/main/java/pl/redhat/samples/quarkus/person/resource/PersonResource.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.resource; 2 | 3 | import org.jboss.logging.Logger; 4 | import pl.redhat.samples.quarkus.person.model.Person; 5 | import pl.redhat.samples.quarkus.person.repository.PersonRepository; 6 | 7 | import jakarta.inject.Inject; 8 | import jakarta.transaction.Transactional; 9 | import jakarta.ws.rs.*; 10 | import java.util.List; 11 | 12 | @Path("/persons") 13 | public class PersonResource { 14 | 15 | @Inject 16 | Logger log; 17 | @Inject 18 | PersonRepository personRepository; 19 | 20 | @POST 21 | @Transactional 22 | public Person addPerson(Person person) { 23 | personRepository.persist(person); 24 | return person; 25 | } 26 | 27 | @GET 28 | public List getPersons() { 29 | return personRepository.listAll(); 30 | } 31 | 32 | @GET 33 | @Path("/{id}") 34 | public Person getPersonById(@PathParam("id") Long id) { 35 | log.infof("getPersonById: id=%d", id); 36 | Person p = personRepository.findById(id); 37 | log.infof("getPersonById: %s", p); 38 | return p; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /mesh-with-db/k8s/mesh/fuse.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: microservices-gateway 5 | spec: 6 | selector: 7 | istio: ingressgateway 8 | servers: 9 | - port: 10 | number: 80 11 | name: http 12 | protocol: HTTP 13 | hosts: 14 | - i-insurance-api.apps.cluster-8e1d.8e1d.sandbox114.opentlc.com 15 | - i-person-api.apps.cluster-8e1d.8e1d.sandbox114.opentlc.com 16 | --- 17 | apiVersion: networking.istio.io/v1beta1 18 | kind: VirtualService 19 | metadata: 20 | name: i-insurance-api-vs 21 | spec: 22 | hosts: 23 | - i-insurance-api.apps.cluster-8e1d.8e1d.sandbox114.opentlc.com 24 | gateways: 25 | - microservices-gateway 26 | http: 27 | - match: 28 | - uri: 29 | prefix: "/insurance" 30 | rewrite: 31 | uri: " " 32 | route: 33 | - destination: 34 | host: i-insurance-api 35 | weight: 100 36 | --- 37 | apiVersion: networking.istio.io/v1beta1 38 | kind: VirtualService 39 | metadata: 40 | name: i-person-api-vs 41 | spec: 42 | hosts: 43 | - i-person-api 44 | http: 45 | - route: 46 | - destination: 47 | host: i-person-api 48 | weight: 100 -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring.application.name: shipment-service 2 | 3 | spring.kafka.bootstrap-servers: pminkows-k-c-ma--adc-smj-himh-g.bf2.kafka.rhcloud.com:443 4 | 5 | spring.cloud.function.definition: orders;confirmations;dlqs 6 | spring.cloud.stream.bindings.orders-in-0.destination: user.pminkows.ordercommand 7 | spring.cloud.stream.bindings.orders-out-0.destination: user.pminkows.orderevent 8 | spring.cloud.stream.bindings.confirmations-in-0.destination: user.pminkows.confirmcommand 9 | spring.cloud.stream.bindings.dlqs-in-0.destination: user.pminkows.shipment.ordercommand.dlq 10 | 11 | spring.cloud.stream.bindings.orders-in-0.consumer.enableDlq: true 12 | spring.cloud.stream.bindings.orders-in-0.consumer.dlqName: user.pminkows.shipment.ordercommand.dlq 13 | 14 | spring.cloud.stream.kafka.binder.configuration.security.protocol: SASL_SSL 15 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism: PLAIN 16 | spring.cloud.stream.kafka.binder.jaas.loginModule: org.apache.kafka.common.security.plain.PlainLoginModule 17 | spring.cloud.stream.kafka.binder.jaas.options.username: srvc-acct-7e2b5429-257e-4b32-a0a7-593d20310267 18 | spring.cloud.stream.kafka.binder.jaas.options.password: 25f07668-33d8-494b-9791-10acbc485b7f -------------------------------------------------------------------------------- /event-driven/streams/consumer-streams/src/main/java/pl/redhat/samples/eventdriven/domain/Order.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.domain; 2 | 3 | public class Order { 4 | 5 | private Integer id; 6 | private String status; 7 | private Integer customerId; 8 | 9 | public Order() { 10 | } 11 | 12 | public Order(Integer id, String status, Integer customerId) { 13 | this.id = id; 14 | this.status = status; 15 | } 16 | 17 | public Integer getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Integer id) { 22 | this.id = id; 23 | } 24 | 25 | public String getStatus() { 26 | return status; 27 | } 28 | 29 | public void setStatus(String status) { 30 | this.status = status; 31 | } 32 | 33 | public Integer getCustomerId() { 34 | return customerId; 35 | } 36 | 37 | public void setCustomerId(Integer customerId) { 38 | this.customerId = customerId; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "Order{" + 44 | "id=" + id + 45 | ", status='" + status + '\'' + 46 | ", customerId=" + customerId + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /messaging/simple-producer/src/main/java/pl/redhat/samples/messaging/simple/producer/ProducerController.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple.producer; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.jms.core.JmsTemplate; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import pl.redhat.samples.messaging.simple.message.SimpleMessage; 10 | 11 | @RestController 12 | @RequestMapping("/producer") 13 | public class ProducerController { 14 | 15 | private static long id = 1; 16 | private final JmsTemplate jmsTemplate; 17 | @Value("${DESTINATION}") 18 | private String destination; 19 | 20 | public ProducerController(JmsTemplate jmsTemplate) { 21 | this.jmsTemplate = jmsTemplate; 22 | } 23 | 24 | @PostMapping("/send") 25 | public SimpleMessage send(@RequestBody SimpleMessage message) { 26 | if (message.getId() == null) { 27 | message.setId(id++); 28 | } 29 | jmsTemplate.convertAndSend(destination, message); 30 | return message; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /event-driven/consumer/src/main/java/pl/redhat/samples/eventdriven/message/CallmeEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.message; 2 | 3 | public class CallmeEvent { 4 | 5 | private Integer id; 6 | private String message; 7 | private String eventType; 8 | 9 | public CallmeEvent() { 10 | } 11 | 12 | public CallmeEvent(Integer id, String message, String eventType) { 13 | this.id = id; 14 | this.message = message; 15 | this.eventType = eventType; 16 | } 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getMessage() { 27 | return message; 28 | } 29 | 30 | public void setMessage(String message) { 31 | this.message = message; 32 | } 33 | 34 | public String getEventType() { 35 | return eventType; 36 | } 37 | 38 | public void setEventType(String eventType) { 39 | this.eventType = eventType; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "CallmeEvent{" + 45 | "id=" + id + 46 | ", message='" + message + '\'' + 47 | ", eventType='" + eventType + '\'' + 48 | '}'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /event-driven/producer/src/main/java/pl/redhat/samples/eventdriven/message/CallmeEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.message; 2 | 3 | public class CallmeEvent { 4 | 5 | private Integer id; 6 | private String message; 7 | private String eventType; 8 | 9 | public CallmeEvent() { 10 | } 11 | 12 | public CallmeEvent(Integer id, String message, String eventType) { 13 | this.id = id; 14 | this.message = message; 15 | this.eventType = eventType; 16 | } 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getMessage() { 27 | return message; 28 | } 29 | 30 | public void setMessage(String message) { 31 | this.message = message; 32 | } 33 | 34 | public String getEventType() { 35 | return eventType; 36 | } 37 | 38 | public void setEventType(String eventType) { 39 | this.eventType = eventType; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "CallmeEvent{" + 45 | "id=" + id + 46 | ", message='" + message + '\'' + 47 | ", eventType='" + eventType + '\'' + 48 | '}'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: person-service 4 | datasource: 5 | url: jdbc:postgresql://${DATABASE_HOST}:5432/${DATABASE_NAME} 6 | username: ${DATABASE_USER} 7 | password: ${DATABASE_PASS} 8 | jpa: 9 | hibernate: 10 | ddl-auto: create 11 | properties: 12 | hibernate: 13 | show_sql: true 14 | format_sql: true 15 | 16 | management: 17 | info.java.enabled: true 18 | endpoints: 19 | web: 20 | exposure: 21 | include: "*" 22 | endpoint.health: 23 | show-details: always 24 | group: 25 | readiness: 26 | include: db 27 | probes: 28 | enabled: true 29 | # server.port: 8081 30 | 31 | dekorate: 32 | openshift: 33 | auto-deploy-enabled: true 34 | # deployment-kind: Deployment 35 | replicas: 2 36 | expose: true 37 | env-vars: 38 | - name: DATABASE_USER 39 | value: database-user 40 | secret: person-db 41 | - name: DATABASE_PASS 42 | value: database-password 43 | secret: person-db 44 | - name: DATABASE_NAME 45 | value: database-name 46 | secret: person-db 47 | - name: DATABASE_HOST 48 | value: person-db 49 | s2i: 50 | enable: true 51 | auto-deploy-enabled: true -------------------------------------------------------------------------------- /basic-with-db/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | openshift-quickstart 7 | pl.redhat.samples 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | basic-with-db 13 | 1.1 14 | pom 15 | 16 | 17 | person-app 18 | insurance-app 19 | 20 | 21 | 22 | ${project.artifactId} 23 | 24 | 25 | 26 | 27 | 28 | io.quarkus.platform 29 | quarkus-bom 30 | ${quarkus.version} 31 | pom 32 | import 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /micro-view/department/src/main/java/pl/redhat/samples/department/model/Employee.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.department.model; 2 | 3 | public class Employee { 4 | 5 | private Long id; 6 | private String name; 7 | private int age; 8 | private String position; 9 | 10 | public Employee() { 11 | 12 | } 13 | 14 | public Employee(String name, int age, String position) { 15 | this.name = name; 16 | this.age = age; 17 | this.position = position; 18 | } 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Long id) { 25 | this.id = id; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public int getAge() { 37 | return age; 38 | } 39 | 40 | public void setAge(int age) { 41 | this.age = age; 42 | } 43 | 44 | public String getPosition() { 45 | return position; 46 | } 47 | 48 | public void setPosition(String position) { 49 | this.position = position; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Employee [id=" + id + ", name=" + name + ", position=" + position + "]"; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /micro-view/organization/src/main/java/pl/redhat/samples/organization/model/Employee.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.organization.model; 2 | 3 | public class Employee { 4 | 5 | private String id; 6 | private String name; 7 | private int age; 8 | private String position; 9 | 10 | public Employee() { 11 | 12 | } 13 | 14 | public Employee(String name, int age, String position) { 15 | this.name = name; 16 | this.age = age; 17 | this.position = position; 18 | } 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public int getAge() { 37 | return age; 38 | } 39 | 40 | public void setAge(int age) { 41 | this.age = age; 42 | } 43 | 44 | public String getPosition() { 45 | return position; 46 | } 47 | 48 | public void setPosition(String position) { 49 | this.position = position; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Employee [id=" + id + ", name=" + name + ", position=" + position + "]"; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mesh-with-db/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | openshift-quickstart 7 | pl.redhat.samples 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | mesh-with-db 13 | 1.1 14 | pom 15 | 16 | 17 | ${project.artifactId} 18 | 19 | 20 | 21 | 22 | 23 | io.quarkus.platform 24 | quarkus-bom 25 | ${quarkus.version} 26 | pom 27 | import 28 | 29 | 30 | 31 | 32 | 33 | quarkus-insurance-app 34 | quarkus-person-app 35 | 36 | 37 | -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/java/pl/redhat/samples/eventdriven/gateway/message/OrderQuery.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.gateway.message; 2 | 3 | import java.util.Date; 4 | import java.util.UUID; 5 | 6 | public class OrderQuery { 7 | 8 | private String queryId; 9 | private Integer customerId; 10 | private Date startDate; 11 | private Date endDate; 12 | 13 | public OrderQuery() { 14 | } 15 | 16 | public OrderQuery(String queryId, Integer customerId) { 17 | this.queryId = queryId; 18 | this.customerId = customerId; 19 | } 20 | 21 | public String getQueryId() { 22 | return queryId; 23 | } 24 | 25 | public void setQueryId(String queryId) { 26 | this.queryId = queryId; 27 | } 28 | 29 | public Integer getCustomerId() { 30 | return customerId; 31 | } 32 | 33 | public void setCustomerId(Integer customerId) { 34 | this.customerId = customerId; 35 | } 36 | 37 | public Date getStartDate() { 38 | return startDate; 39 | } 40 | 41 | public void setStartDate(Date startDate) { 42 | this.startDate = startDate; 43 | } 44 | 45 | public Date getEndDate() { 46 | return endDate; 47 | } 48 | 49 | public void setEndDate(Date endDate) { 50 | this.endDate = endDate; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /messaging/simple-consumer/src/main/java/pl/redhat/samples/messaging/simple/message/SimpleMessage.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple.message; 2 | 3 | import java.io.Serializable; 4 | 5 | public class SimpleMessage implements Serializable { 6 | 7 | private Long id; 8 | private String source; 9 | private String content; 10 | 11 | public SimpleMessage() { 12 | } 13 | 14 | public SimpleMessage(Long id, String source, String content) { 15 | this.id = id; 16 | this.source = source; 17 | this.content = content; 18 | } 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Long id) { 25 | this.id = id; 26 | } 27 | 28 | public String getSource() { 29 | return source; 30 | } 31 | 32 | public void setSource(String source) { 33 | this.source = source; 34 | } 35 | 36 | public String getContent() { 37 | return content; 38 | } 39 | 40 | public void setContent(String content) { 41 | this.content = content; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "SimpleMessage{" + 47 | "id=" + id + 48 | ", source='" + source + '\'' + 49 | ", content='" + content + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /messaging/simple-producer/src/main/java/pl/redhat/samples/messaging/simple/message/SimpleMessage.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.messaging.simple.message; 2 | 3 | import java.io.Serializable; 4 | 5 | public class SimpleMessage implements Serializable { 6 | 7 | private Long id; 8 | private String source; 9 | private String content; 10 | 11 | public SimpleMessage() { 12 | } 13 | 14 | public SimpleMessage(Long id, String source, String content) { 15 | this.id = id; 16 | this.source = source; 17 | this.content = content; 18 | } 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Long id) { 25 | this.id = id; 26 | } 27 | 28 | public String getSource() { 29 | return source; 30 | } 31 | 32 | public void setSource(String source) { 33 | this.source = source; 34 | } 35 | 36 | public String getContent() { 37 | return content; 38 | } 39 | 40 | public void setContent(String content) { 41 | this.content = content; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "SimpleMessage{" + 47 | "id=" + id + 48 | ", source='" + source + '\'' + 49 | ", content='" + content + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/PaymentServiceApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import pl.redhat.samples.eventdriven.payment.message.ConfirmCommand; 8 | import pl.redhat.samples.eventdriven.payment.message.OrderCommand; 9 | import pl.redhat.samples.eventdriven.payment.message.OrderEvent; 10 | import pl.redhat.samples.eventdriven.payment.service.PaymentService; 11 | 12 | import java.util.function.Consumer; 13 | import java.util.function.Function; 14 | 15 | @SpringBootApplication 16 | public class PaymentServiceApp { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(PaymentServiceApp.class, args); 20 | } 21 | 22 | @Autowired 23 | private PaymentService paymentService; 24 | 25 | @Bean 26 | public Function orders() { 27 | return command -> paymentService.reserveBalance(command); 28 | } 29 | 30 | @Bean 31 | public Consumer confirmations() { 32 | return command -> paymentService.confirmBalance(command); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /camel-spring/person-demo/readme.md: -------------------------------------------------------------------------------- 1 | ## Spring Boot Camel REST Example 2 | 3 | ### Start Oracle database instance 4 | 5 | To start it on Docker: 6 | ```shell 7 | docker run -d --name oracle -p 1521:1521 container-registry.oracle.com/database/express:latest 8 | ``` 9 | 10 | ### Run application locally 11 | 12 | To start Spring Boot application in dev mode: 13 | ```shell 14 | $ mvn clean spring-boot:run -Dspring-boot.run.profiles=dev 15 | ``` 16 | 17 | Before launching the app change credentials to your database in `application-dev.yaml`: 18 | ```yaml 19 | spring: 20 | application: 21 | name: person-service 22 | datasource: 23 | url: jdbc:oracle:thin:@localhost:1521/XE 24 | username: ${USER} 25 | password: ${PASSWORD} 26 | ``` 27 | 28 | Then, you can access your application on `8080` port. To test REST API you can access Swagger UI: 29 | ```shell 30 | http://localhost:8080/swagger-ui.html 31 | ``` 32 | 33 | To access Hawtio console: 34 | ```shell 35 | http://localhost:8080/actuator/hawtio 36 | ``` 37 | 38 | ### Run your application on OpenShift 39 | 40 | You can use `oc` client to launch from Git or `odo` to run from local code. First, create app with `odo`: 41 | ```shell 42 | odo create java --s2i person-demo 43 | ``` 44 | 45 | Then push your app to OpenShift: 46 | ```shell 47 | odo push 48 | ``` 49 | 50 | Verify logs: 51 | ```shell 52 | odo log -f 53 | ``` -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/domain/Account.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.GenerationType; 6 | import jakarta.persistence.Id; 7 | 8 | @Entity 9 | public class Account { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private Integer id; 14 | private Integer customerId; 15 | private int currentAmount; 16 | private int reservedAmount; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public Integer getCustomerId() { 27 | return customerId; 28 | } 29 | 30 | public void setCustomerId(Integer customerId) { 31 | this.customerId = customerId; 32 | } 33 | 34 | public int getCurrentAmount() { 35 | return currentAmount; 36 | } 37 | 38 | public void setCurrentAmount(int currentAmount) { 39 | this.currentAmount = currentAmount; 40 | } 41 | 42 | public int getReservedAmount() { 43 | return reservedAmount; 44 | } 45 | 46 | public void setReservedAmount(int reservedAmount) { 47 | this.reservedAmount = reservedAmount; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/message/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order.message; 2 | 3 | import java.util.UUID; 4 | 5 | public class OrderEvent { 6 | 7 | private String id; 8 | private String commandId; 9 | private String type; 10 | private String status; 11 | 12 | public OrderEvent() { 13 | this.id = UUID.randomUUID().toString(); 14 | } 15 | 16 | public OrderEvent(String commandId, String type, String status) { 17 | this.id = UUID.randomUUID().toString(); 18 | this.commandId = commandId; 19 | this.type = type; 20 | this.status = status; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | 31 | public String getCommandId() { 32 | return commandId; 33 | } 34 | 35 | public void setCommandId(String commandId) { 36 | this.commandId = commandId; 37 | } 38 | 39 | public String getType() { 40 | return type; 41 | } 42 | 43 | public void setType(String type) { 44 | this.type = type; 45 | } 46 | 47 | public String getStatus() { 48 | return status; 49 | } 50 | 51 | public void setStatus(String status) { 52 | this.status = status; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/message/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.message; 2 | 3 | import java.util.UUID; 4 | 5 | public class OrderEvent { 6 | 7 | private String id; 8 | private String commandId; 9 | private String type; 10 | private String status; 11 | 12 | public OrderEvent() { 13 | this.id = UUID.randomUUID().toString(); 14 | } 15 | 16 | public OrderEvent(String commandId, String type, String status) { 17 | this.id = UUID.randomUUID().toString(); 18 | this.commandId = commandId; 19 | this.type = type; 20 | this.status = status; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | 31 | public String getCommandId() { 32 | return commandId; 33 | } 34 | 35 | public void setCommandId(String commandId) { 36 | this.commandId = commandId; 37 | } 38 | 39 | public String getType() { 40 | return type; 41 | } 42 | 43 | public void setType(String type) { 44 | this.type = type; 45 | } 46 | 47 | public String getStatus() { 48 | return status; 49 | } 50 | 51 | public void setStatus(String status) { 52 | this.status = status; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /event-driven/streams/consumer-streams/src/main/java/pl/redhat/samples/eventdriven/domain/CustomerOrder.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.domain; 2 | 3 | public class CustomerOrder { 4 | 5 | private Integer id; 6 | private Integer customerId; 7 | private String customerName; 8 | private String status; 9 | 10 | public CustomerOrder() { 11 | } 12 | 13 | public CustomerOrder(Integer id, Integer customerId, String customerName, String status) { 14 | this.id = id; 15 | this.customerId = customerId; 16 | this.customerName = customerName; 17 | this.status = status; 18 | } 19 | 20 | public Integer getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Integer id) { 25 | this.id = id; 26 | } 27 | 28 | public Integer getCustomerId() { 29 | return customerId; 30 | } 31 | 32 | public void setCustomerId(Integer customerId) { 33 | this.customerId = customerId; 34 | } 35 | 36 | public String getCustomerName() { 37 | return customerName; 38 | } 39 | 40 | public void setCustomerName(String customerName) { 41 | this.customerName = customerName; 42 | } 43 | 44 | public String getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(String status) { 49 | this.status = status; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/message/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.message; 2 | 3 | import java.util.UUID; 4 | 5 | public class OrderEvent { 6 | 7 | private String id; 8 | private String commandId; 9 | private String type; 10 | private String status; 11 | 12 | public OrderEvent() { 13 | this.id = UUID.randomUUID().toString(); 14 | } 15 | 16 | public OrderEvent(String commandId, String type, String status) { 17 | this.id = UUID.randomUUID().toString(); 18 | this.commandId = commandId; 19 | this.type = type; 20 | this.status = status; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | 31 | public String getCommandId() { 32 | return commandId; 33 | } 34 | 35 | public void setCommandId(String commandId) { 36 | this.commandId = commandId; 37 | } 38 | 39 | public String getType() { 40 | return type; 41 | } 42 | 43 | public void setType(String type) { 44 | this.type = type; 45 | } 46 | 47 | public String getStatus() { 48 | return status; 49 | } 50 | 51 | public void setStatus(String status) { 52 | this.status = status; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /event-driven/streams/consumer-streams/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | streams 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | consumer-streams 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-stream-binder-kafka-streams 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-maven-plugin 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /event-driven/order-service/src/main/java/pl/redhat/samples/eventdriven/order/OrderServiceApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.order; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import pl.redhat.samples.eventdriven.order.message.OrderCommand; 8 | import pl.redhat.samples.eventdriven.order.message.OrderEvent; 9 | import pl.redhat.samples.eventdriven.order.service.OrderService; 10 | 11 | import java.util.function.Consumer; 12 | 13 | @SpringBootApplication 14 | public class OrderServiceApp { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(OrderServiceApp.class, args); 18 | } 19 | 20 | @Autowired 21 | OrderService orderService; 22 | 23 | @Bean 24 | public Consumer orders() { 25 | return command -> orderService.addOrderCommand(command); 26 | } 27 | 28 | @Bean 29 | public Consumer events() { 30 | return event -> orderService.updateOrderCommandStatus(event.getCommandId()); 31 | } 32 | 33 | @Bean 34 | public Consumer failedEvents() { 35 | // TODO - add implementation 36 | return event -> orderService.updateOrderCommandStatus(event.getCommandId()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/client/RequestHeaderFactory.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.client; 2 | 3 | import org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory; 4 | import org.jboss.logging.Logger; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | import jakarta.inject.Inject; 8 | import jakarta.ws.rs.core.MultivaluedHashMap; 9 | import jakarta.ws.rs.core.MultivaluedMap; 10 | 11 | @ApplicationScoped 12 | public class RequestHeaderFactory implements ClientHeadersFactory { 13 | 14 | @Inject 15 | Logger log; 16 | 17 | @Override 18 | public MultivaluedMap update(MultivaluedMap inHeaders, 19 | MultivaluedMap outHeaders) { 20 | String version = inHeaders.getFirst("x-version"); 21 | log.infof("Version Header: %s", version); 22 | String traceId = inHeaders.getFirst("x-b3-traceid"); 23 | log.infof("Trace Header: %s", traceId); 24 | MultivaluedMap result = new MultivaluedHashMap<>(); 25 | result.add("X-Version", version); 26 | result.add("X-B3-TraceId", traceId); 27 | result.add("X-B3-SpanId", inHeaders.getFirst("x-b3-spanid")); 28 | result.add("X-B3-ParentSpanId", inHeaders.getFirst("x-b3-parentspanid")); 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cpu-killer/src/main/java/pl/redhat/samples/cpukiller/CpuKillerApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.cpukiller; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import org.apache.kafka.clients.consumer.ConsumerRecord; 5 | import org.eclipse.microprofile.reactive.messaging.Incoming; 6 | import org.jboss.logging.Logger; 7 | import pl.redhat.samples.cpukiller.message.PingEvent; 8 | 9 | import java.math.BigInteger; 10 | import java.util.Random; 11 | import java.util.concurrent.ExecutorService; 12 | import java.util.concurrent.Executors; 13 | import java.util.concurrent.atomic.AtomicLong; 14 | 15 | @ApplicationScoped 16 | public class CpuKillerApp { 17 | 18 | AtomicLong counter = new AtomicLong(); 19 | Logger log; 20 | 21 | public CpuKillerApp(Logger log) { 22 | this.log = log; 23 | } 24 | 25 | ExecutorService executor = Executors.newFixedThreadPool(15); 26 | 27 | @Incoming("events") 28 | void onEvent(ConsumerRecord event) { 29 | executor.submit(() -> { 30 | long id = counter.incrementAndGet(); 31 | log.infof("New event: id=%d, partition=%d", id, event.partition()); 32 | BigInteger bi = new BigInteger(1000, 10, new Random()); 33 | PingEvent ping = event.value(); 34 | ping.setId(id); 35 | ping.setBigNumber(bi.toString()); 36 | log.info("Computed: " + ping); 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mesh-with-db/k8s/mesh/mesh-person.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1beta1 2 | kind: DestinationRule 3 | metadata: 4 | name: quarkus-person-app-dr 5 | spec: 6 | host: quarkus-person-app 7 | subsets: 8 | - name: v1 9 | labels: 10 | app.kubernetes.io/version: v1 11 | - name: v2 12 | labels: 13 | app.kubernetes.io/version: v2 14 | --- 15 | apiVersion: networking.istio.io/v1beta1 16 | kind: VirtualService 17 | metadata: 18 | name: quarkus-person-app-vs-via-gw 19 | spec: 20 | hosts: 21 | - quarkus-person-app.apps.cluster-5935.5935.sandbox474.opentlc.com 22 | gateways: 23 | - microservices-gateway 24 | http: 25 | - match: 26 | - uri: 27 | prefix: "/person" 28 | rewrite: 29 | uri: " " 30 | route: 31 | - destination: 32 | host: quarkus-person-app 33 | subset: v1 34 | weight: 100 35 | - destination: 36 | host: quarkus-person-app 37 | subset: v2 38 | weight: 0 39 | --- 40 | apiVersion: networking.istio.io/v1beta1 41 | kind: VirtualService 42 | metadata: 43 | name: quarkus-person-app-vs 44 | spec: 45 | hosts: 46 | - quarkus-person-app 47 | http: 48 | - route: 49 | - destination: 50 | host: quarkus-person-app 51 | subset: v1 52 | weight: 100 53 | - destination: 54 | host: quarkus-person-app 55 | subset: v2 56 | weight: 0 -------------------------------------------------------------------------------- /micro-springboot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | pl.redhat.samples 8 | openshift-quickstart 9 | 1.0-SNAPSHOT 10 | 11 | 4.0.0 12 | 13 | micro-springboot 14 | 1.0-SNAPSHOT 15 | pom 16 | 17 | 18 | person-service 19 | insurance-service 20 | 21 | 22 | 23 | 1.21.4 24 | 1.6.11 25 | ${project.artifactId} 26 | 27 | 28 | 29 | 30 | 31 | org.testcontainers 32 | testcontainers-bom 33 | ${testcontainers.version} 34 | pom 35 | import 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/java/pl/redhat/samples/quarkus/person/resource/PersonResource.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.resource; 2 | 3 | import pl.redhat.samples.quarkus.person.model.Person; 4 | import pl.redhat.samples.quarkus.person.repository.PersonRepository; 5 | 6 | import jakarta.inject.Inject; 7 | import jakarta.transaction.Transactional; 8 | import jakarta.ws.rs.GET; 9 | import jakarta.ws.rs.POST; 10 | import jakarta.ws.rs.Path; 11 | import jakarta.ws.rs.PathParam; 12 | import java.util.List; 13 | 14 | @Path("/persons") 15 | public class PersonResource { 16 | 17 | @Inject 18 | PersonRepository personRepository; 19 | 20 | @POST 21 | @Transactional 22 | public Person addPerson(Person person) { 23 | personRepository.persist(person); 24 | return person; 25 | } 26 | 27 | @GET 28 | public List getPersons() { 29 | return personRepository.listAll(); 30 | } 31 | 32 | @GET 33 | @Path("/name/{name}") 34 | public List getPersonsByName(@PathParam("name") String name) { 35 | return personRepository.findByName(name); 36 | } 37 | 38 | @GET 39 | @Path("/age-greater-than/{age}") 40 | public List getPersonsByAge(@PathParam("age") int age) { 41 | return personRepository.findByAgeGreaterThan(age); 42 | } 43 | 44 | @GET 45 | @Path("/{id}") 46 | public Person getPersonById(@PathParam("id") Long id) { 47 | return personRepository.findById(id); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /event-driven/event-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | event-gateway 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-stream-kafka 26 | 27 | 28 | com.fasterxml.jackson.datatype 29 | jackson-datatype-jsr310 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /event-driven/order-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | order-service 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-stream-kafka 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-data-jpa 26 | 27 | 28 | com.h2database 29 | h2 30 | runtime 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /event-driven/payment-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | payment-service 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-stream-kafka 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-data-jpa 26 | 27 | 28 | com.h2database 29 | h2 30 | runtime 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /event-driven/producer/src/main/java/pl/redhat/samples/eventdriven/message/LargeEvent.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.message; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import java.util.Random; 5 | 6 | public class LargeEvent { 7 | private Integer id; 8 | private String message; 9 | private String eventType; 10 | private int size; 11 | 12 | public LargeEvent() { 13 | byte[] array = new byte[2000]; 14 | new Random().nextBytes(array); 15 | message = new String(array, StandardCharsets.UTF_8); 16 | } 17 | 18 | public LargeEvent(Integer id, String eventType, int size) { 19 | this.id = id; 20 | this.eventType = eventType; 21 | this.size = size; 22 | byte[] array = new byte[size]; 23 | new Random().nextBytes(array); 24 | message = new String(array, StandardCharsets.UTF_8); 25 | } 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getMessage() { 36 | return message; 37 | } 38 | 39 | public void setMessage(String message) { 40 | this.message = message; 41 | } 42 | 43 | public String getEventType() { 44 | return eventType; 45 | } 46 | 47 | public void setEventType(String eventType) { 48 | this.eventType = eventType; 49 | } 50 | 51 | public int getSize() { 52 | return size; 53 | } 54 | 55 | public void setSize(int size) { 56 | this.size = size; 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /event-driven/shipment-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shipment-service 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-stream-kafka 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-data-jpa 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /event-driven/streams/consumer-streams/src/main/java/pl/redhat/samples/eventdriven/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.controller; 2 | 3 | import org.apache.kafka.streams.KeyValue; 4 | import org.apache.kafka.streams.state.KeyValueIterator; 5 | import org.apache.kafka.streams.state.QueryableStoreTypes; 6 | import org.apache.kafka.streams.state.ReadOnlyKeyValueStore; 7 | import org.springframework.cloud.stream.binder.kafka.streams.InteractiveQueryService; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import pl.redhat.samples.eventdriven.domain.Order; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @RestController 17 | @RequestMapping("/orders") 18 | public class OrderController { 19 | 20 | private InteractiveQueryService queryService; 21 | 22 | public OrderController(InteractiveQueryService queryService) { 23 | this.queryService = queryService; 24 | } 25 | 26 | @GetMapping 27 | public List getOrders() { 28 | List orders = new ArrayList<>(); 29 | ReadOnlyKeyValueStore keyValueStore = 30 | queryService.getQueryableStore("orders-view", QueryableStoreTypes.keyValueStore()); 31 | KeyValueIterator it = keyValueStore.all(); 32 | while (it.hasNext()) { 33 | KeyValue kv = it.next(); 34 | orders.add(kv.value); 35 | } 36 | return orders; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/src/main/java/pl/redhat/samples/quarkus/person/model/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.person.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.EnumType; 7 | import jakarta.persistence.Enumerated; 8 | 9 | @Entity 10 | public class Person extends PanacheEntity { 11 | private String name; 12 | private int age; 13 | @Enumerated(EnumType.STRING) 14 | private Gender gender; 15 | // TODO - uncomment to enable v2 16 | private Integer externalId; 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public int getAge() { 27 | return age; 28 | } 29 | 30 | public void setAge(int age) { 31 | this.age = age; 32 | } 33 | 34 | public Gender getGender() { 35 | return gender; 36 | } 37 | 38 | public void setGender(Gender gender) { 39 | this.gender = gender; 40 | } 41 | 42 | public Integer getExternalId() { 43 | return externalId; 44 | } 45 | 46 | public void setExternalId(Integer externalId) { 47 | this.externalId = externalId; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "Person{" + 53 | "name='" + name + '\'' + 54 | ", age=" + age + 55 | ", gender=" + gender + 56 | ", externalID=" + externalId + 57 | ", id=" + id + 58 | '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /basic-with-db/person-app/src/main/resources/db/changeLog.sql: -------------------------------------------------------------------------------- 1 | --liquibase formatted sql 2 | 3 | --changeset piomin:1 4 | create table person ( 5 | id serial primary key, 6 | name varchar(255), 7 | gender varchar(255), 8 | age int, 9 | externalId int 10 | ); 11 | insert into person(name, age, gender) values('John Smith', 25, 'MALE'); 12 | insert into person(name, age, gender) values('Paul Walker', 65, 'MALE'); 13 | insert into person(name, age, gender) values('Lewis Hamilton', 35, 'MALE'); 14 | insert into person(name, age, gender) values('Veronica Jones', 20, 'FEMALE'); 15 | insert into person(name, age, gender) values('Anne Brown', 60, 'FEMALE'); 16 | insert into person(name, age, gender) values('Felicia Scott', 45, 'FEMALE'); 17 | 18 | --changeset piomin:2 19 | create table person2 ( 20 | id serial primary key, 21 | first_name varchar(255), 22 | last_name varchar(255), 23 | gender varchar(255), 24 | age int, 25 | external_id int 26 | ); 27 | insert into person2(first_name, last_name, age, gender, external_id) values('John', 'Smith', 25, 'MALE', 1001); 28 | insert into person2(first_name, last_name, age, gender, external_id) values('Paul', 'Walker', 65, 'MALE', 1005); 29 | insert into person2(first_name, last_name, age, gender, external_id) values('Lewis', 'Hamilton', 35, 'MALE', 1021); 30 | insert into person2(first_name, last_name, age, gender, external_id) values('Veronica', 'Jones', 20, 'FEMALE', 1051); 31 | insert into person2(first_name, last_name, age, gender, external_id) values('Anne', 'Brown', 60, 'FEMALE', 1081); 32 | insert into person2(first_name, last_name, age, gender, external_id) values('Felicia', 'Scott', 45, 'FEMALE', 1201); -------------------------------------------------------------------------------- /event-driven/event-gateway/src/main/java/pl/redhat/samples/eventdriven/gateway/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.gateway.controller; 2 | 3 | import org.springframework.cloud.stream.function.StreamBridge; 4 | import org.springframework.web.bind.annotation.*; 5 | import pl.redhat.samples.eventdriven.gateway.message.Order; 6 | import pl.redhat.samples.eventdriven.gateway.message.OrderCommand; 7 | import pl.redhat.samples.eventdriven.gateway.message.OrderQuery; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | import java.util.UUID; 12 | 13 | @RestController 14 | @RequestMapping("/orders") 15 | public class OrderController { 16 | 17 | private StreamBridge streamBridge; 18 | private Map> results; 19 | 20 | public OrderController(StreamBridge streamBridge, Map> results) { 21 | this.streamBridge = streamBridge; 22 | this.results = results; 23 | } 24 | 25 | @PostMapping 26 | public Boolean orders(@RequestBody OrderCommand orderCommand) { 27 | orderCommand.setId(UUID.randomUUID().toString()); 28 | return streamBridge.send("orders-out-0", orderCommand); 29 | } 30 | 31 | @GetMapping("/customer/{customerId}") 32 | public String query(@PathVariable Integer customerId) { 33 | String uuid = UUID.randomUUID().toString(); 34 | streamBridge.send("queries-out-0", new OrderQuery(uuid, customerId)); 35 | return uuid; 36 | } 37 | 38 | @GetMapping("/results/{queryId}") 39 | public List orders(@PathVariable String queryId) { 40 | return results.remove(queryId); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/message/OrderCommand.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.message; 2 | 3 | public class OrderCommand { 4 | 5 | private String id; 6 | private Integer customerId; 7 | private Integer productId; 8 | private int productCount; 9 | private int amount; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public Integer getCustomerId() { 20 | return customerId; 21 | } 22 | 23 | public void setCustomerId(Integer customerId) { 24 | this.customerId = customerId; 25 | } 26 | 27 | public Integer getProductId() { 28 | return productId; 29 | } 30 | 31 | public void setProductId(Integer productId) { 32 | this.productId = productId; 33 | } 34 | 35 | public int getProductCount() { 36 | return productCount; 37 | } 38 | 39 | public void setProductCount(int productCount) { 40 | this.productCount = productCount; 41 | } 42 | 43 | public int getAmount() { 44 | return amount; 45 | } 46 | 47 | public void setAmount(int amount) { 48 | this.amount = amount; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "OrderCommand{" + 54 | "id=" + id + 55 | ", customerId=" + customerId + 56 | ", productId=" + productId + 57 | ", productCount=" + productCount + 58 | ", amount=" + amount + 59 | '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/java/pl/redhat/samples/camel/person/domain/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.camel.person.domain; 2 | 3 | import jakarta.persistence.*; 4 | 5 | @Entity 6 | public class Person { 7 | @Id 8 | @GeneratedValue(strategy = GenerationType.IDENTITY) 9 | private Integer id; 10 | private String name; 11 | private int age; 12 | @Enumerated(EnumType.STRING) 13 | private Gender gender; 14 | // private Integer externalId; 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public int getAge() { 33 | return age; 34 | } 35 | 36 | public void setAge(int age) { 37 | this.age = age; 38 | } 39 | 40 | public Gender getGender() { 41 | return gender; 42 | } 43 | 44 | public void setGender(Gender gender) { 45 | this.gender = gender; 46 | } 47 | 48 | // public Integer getExternalId() { 49 | // return externalId; 50 | // } 51 | // 52 | // public void setExternalId(Integer externalId) { 53 | // this.externalId = externalId; 54 | // } 55 | 56 | @Override 57 | public String toString() { 58 | return "Person{" + 59 | "id=" + id + 60 | ", name='" + name + '\'' + 61 | ", age=" + age + 62 | ", gender=" + gender + 63 | // ", externalId=" + externalId + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/model/Insurance.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | import jakarta.persistence.Entity; 5 | 6 | import jakarta.persistence.Entity; 7 | import jakarta.persistence.EnumType; 8 | import jakarta.persistence.Enumerated; 9 | import java.util.Date; 10 | 11 | @Entity 12 | public class Insurance extends PanacheEntity { 13 | private Long personId; 14 | @Enumerated(EnumType.STRING) 15 | private InsuranceType type; 16 | private int amount; 17 | private Date expiry; 18 | 19 | public Long getPersonId() { 20 | return personId; 21 | } 22 | 23 | public void setPersonId(Long personId) { 24 | this.personId = personId; 25 | } 26 | 27 | public InsuranceType getType() { 28 | return type; 29 | } 30 | 31 | public void setType(InsuranceType type) { 32 | this.type = type; 33 | } 34 | 35 | public int getAmount() { 36 | return amount; 37 | } 38 | 39 | public void setAmount(int amount) { 40 | this.amount = amount; 41 | } 42 | 43 | public Date getExpiry() { 44 | return expiry; 45 | } 46 | 47 | public void setExpiry(Date expiry) { 48 | this.expiry = expiry; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "Insurance{" + 54 | "personId=" + personId + 55 | ", type=" + type + 56 | ", amount=" + amount + 57 | ", expiry=" + expiry + 58 | ", id=" + id + 59 | '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /micro-view/department/src/main/java/pl/redhat/samples/department/model/Department.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.department.model; 2 | 3 | import jakarta.persistence.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | @Entity 8 | public class Department { 9 | 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | private Long id; 13 | private Long organizationId; 14 | private String name; 15 | @Transient 16 | private List employees = new ArrayList<>(); 17 | 18 | public Department() { 19 | 20 | } 21 | 22 | public Department(Long organizationId, String name) { 23 | super(); 24 | this.organizationId = organizationId; 25 | this.name = name; 26 | } 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Long id) { 33 | this.id = id; 34 | } 35 | 36 | public Long getOrganizationId() { 37 | return organizationId; 38 | } 39 | 40 | public void setOrganizationId(Long organizationId) { 41 | this.organizationId = organizationId; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | public List getEmployees() { 53 | return employees; 54 | } 55 | 56 | public void setEmployees(List employees) { 57 | this.employees = employees; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Department [id=" + id + ", organizationId=" + organizationId + ", name=" + name + "]"; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /mesh-with-db/k8s/traffic/urls.txt: -------------------------------------------------------------------------------- 1 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/1 2 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/2 3 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/3 4 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/4 5 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/5 6 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/6 7 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/7 8 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/8 9 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons/9 10 | http://quarkus-person-app.apps.${CLUSTER_DOMAIN}/person/persons 11 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/1/details 12 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/2/details 13 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/3/details 14 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/4/details 15 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/5/details 16 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/6/details 17 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/1 18 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/2 19 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/3 20 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/4 21 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/5 22 | http://quarkus-insurance-app.apps.${CLUSTER_DOMAIN}/insurance/insurances/6 23 | -------------------------------------------------------------------------------- /micro-view/employee/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: employee 5 | labels: 6 | app: employee 7 | app.openshift.io/runtime: spring-boot 8 | app.kubernetes.io/component: backend 9 | app.kubernetes.io/part-of: employee-app 10 | annotations: 11 | app.openshift.io/connects-to: employee-db 12 | spec: 13 | replicas: 2 14 | selector: 15 | matchLabels: 16 | app: employee 17 | template: 18 | metadata: 19 | labels: 20 | app: employee 21 | app.openshift.io/runtime: spring-boot 22 | app.kubernetes.io/component: backend 23 | app.kubernetes.io/part-of: employee-app 24 | annotations: 25 | app.openshift.io/connects-to: employee-db 26 | spec: 27 | containers: 28 | - name: employee 29 | image: piomin/employee 30 | ports: 31 | - containerPort: 8080 32 | env: 33 | - name: DATABASE_NAME 34 | valueFrom: 35 | secretKeyRef: 36 | name: employee-db 37 | key: database-name 38 | - name: DATABASE_USER 39 | valueFrom: 40 | secretKeyRef: 41 | name: employee-db 42 | key: database-user 43 | - name: DATABASE_PASSWORD 44 | valueFrom: 45 | secretKeyRef: 46 | name: employee-db 47 | key: database-password 48 | --- 49 | apiVersion: v1 50 | kind: Service 51 | metadata: 52 | name: employee 53 | labels: 54 | app: employee 55 | spec: 56 | ports: 57 | - port: 8080 58 | protocol: TCP 59 | selector: 60 | app: employee -------------------------------------------------------------------------------- /event-driven/payment-service/src/main/java/pl/redhat/samples/eventdriven/payment/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.payment.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | import pl.redhat.samples.eventdriven.payment.domain.Account; 5 | import pl.redhat.samples.eventdriven.payment.message.ConfirmCommand; 6 | import pl.redhat.samples.eventdriven.payment.message.OrderCommand; 7 | import pl.redhat.samples.eventdriven.payment.message.OrderEvent; 8 | import pl.redhat.samples.eventdriven.payment.repository.AccountRepository; 9 | 10 | @Service 11 | public class PaymentService { 12 | 13 | private AccountRepository accountRepository; 14 | 15 | public PaymentService(AccountRepository accountRepository) { 16 | this.accountRepository = accountRepository; 17 | } 18 | 19 | public OrderEvent reserveBalance(OrderCommand orderCommand) { 20 | Account account = accountRepository.findByCustomerId(orderCommand.getCustomerId()).stream().findFirst().orElseThrow(); 21 | account.setReservedAmount(account.getReservedAmount() - orderCommand.getAmount()); 22 | if (account.getReservedAmount() > 0) { 23 | return new OrderEvent(orderCommand.getId(), "RESERVATION", "FAILED"); 24 | } else { 25 | accountRepository.save(account); 26 | return new OrderEvent(orderCommand.getId(), "RESERVATION", "OK"); 27 | } 28 | } 29 | 30 | public void confirmBalance(ConfirmCommand confirmCommand) { 31 | Account product = accountRepository.findByCustomerId(confirmCommand.getCustomerId()).stream().findFirst().orElseThrow(); 32 | product.setCurrentAmount(product.getCurrentAmount() - confirmCommand.getAmount()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /micro-view/department/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: department 5 | labels: 6 | app: department 7 | app.openshift.io/runtime: spring-boot 8 | app.kubernetes.io/component: backend 9 | app.kubernetes.io/part-of: department-app 10 | annotations: 11 | app.openshift.io/connects-to: department-db 12 | spec: 13 | replicas: 2 14 | selector: 15 | matchLabels: 16 | app: department 17 | template: 18 | metadata: 19 | labels: 20 | app: department 21 | app.openshift.io/runtime: spring-boot 22 | app.kubernetes.io/component: backend 23 | app.kubernetes.io/part-of: department-app 24 | annotations: 25 | app.openshift.io/connects-to: department-db 26 | spec: 27 | containers: 28 | - name: department 29 | image: piomin/department 30 | ports: 31 | - containerPort: 8080 32 | env: 33 | - name: DATABASE_NAME 34 | valueFrom: 35 | secretKeyRef: 36 | name: department-db 37 | key: database-name 38 | - name: DATABASE_USER 39 | valueFrom: 40 | secretKeyRef: 41 | name: department-db 42 | key: database-user 43 | - name: DATABASE_PASSWORD 44 | valueFrom: 45 | secretKeyRef: 46 | name: department-db 47 | key: database-password 48 | --- 49 | apiVersion: v1 50 | kind: Service 51 | metadata: 52 | name: department 53 | labels: 54 | app: department 55 | spec: 56 | ports: 57 | - port: 8080 58 | protocol: TCP 59 | selector: 60 | app: department -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/domain/Insurance.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance.domain; 2 | 3 | import jakarta.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | public class Insurance { 8 | @Id 9 | @GeneratedValue(strategy = GenerationType.IDENTITY) 10 | private Integer id; 11 | private Integer personId; 12 | @Enumerated(EnumType.STRING) 13 | private InsuranceType type; 14 | private int amount; 15 | @Temporal(TemporalType.DATE) 16 | private Date expiry; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public Integer getPersonId() { 27 | return personId; 28 | } 29 | 30 | public void setPersonId(Integer personId) { 31 | this.personId = personId; 32 | } 33 | 34 | public InsuranceType getType() { 35 | return type; 36 | } 37 | 38 | public void setType(InsuranceType type) { 39 | this.type = type; 40 | } 41 | 42 | public int getAmount() { 43 | return amount; 44 | } 45 | 46 | public void setAmount(int amount) { 47 | this.amount = amount; 48 | } 49 | 50 | public Date getExpiry() { 51 | return expiry; 52 | } 53 | 54 | public void setExpiry(Date expiry) { 55 | this.expiry = expiry; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "Insurance{" + 61 | "id=" + id + 62 | ", personId=" + personId + 63 | ", type=" + type + 64 | ", amount=" + amount + 65 | ", expiry=" + expiry + 66 | '}'; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /event-driven/streams/producer-streams/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring.application.name: producer-streams 2 | 3 | spring.kafka.bootstrap-servers: ${KAFKA_URL} 4 | 5 | spring.cloud.stream.bindings.orderSupplier-out-0.destination: streams.pminkows.test 6 | spring.cloud.stream.bindings.orderSupplier-out-0.producer.partitionKeyExpression: headers['kafka_messageKey'] 7 | spring.cloud.stream.bindings.orderSupplier-out-0.producer.partitionCount: 5 8 | spring.cloud.stream.kafka.bindings.orderSupplier-out-0.producer.configuration.key.serializer: org.apache.kafka.common.serialization.IntegerSerializer 9 | 10 | spring.cloud.stream.bindings.customerSupplier-out-0.destination: streams.pminkows.test2 11 | spring.cloud.stream.bindings.customerSupplier-out-0.producer.partitionKeyExpression: headers['kafka_messageKey'] 12 | spring.cloud.stream.bindings.customerSupplier-out-0.producer.partitionCount: 5 13 | spring.cloud.stream.kafka.bindings.customerSupplier-out-0.producer.configuration.key.serializer: org.apache.kafka.common.serialization.IntegerSerializer 14 | 15 | spring.cloud.function.definition: orderSupplier;customerSupplier 16 | 17 | spring.cloud.stream.kafka.binder.configuration.security.protocol: SASL_SSL 18 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism: PLAIN 19 | spring.cloud.stream.kafka.binder.jaas.loginModule: org.apache.kafka.common.security.plain.PlainLoginModule 20 | spring.cloud.stream.kafka.binder.jaas.options.username: ${KAFKA_USER} 21 | spring.cloud.stream.kafka.binder.jaas.options.password: ${KAFKA_PASSWORD} 22 | 23 | spring.output.ansi.enabled: ALWAYS 24 | 25 | logging.pattern.console: "%clr(%d{HH:mm:ss.SSS}){blue} %clr(---){faint} %clr([%15.15t]){yellow} %clr(:){red} %clr(%m){faint}%n" 26 | 27 | logging.level.org.springframework.cloud.stream: DEBUG -------------------------------------------------------------------------------- /cpu-killer/src/main/kubernetes/k6.yml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: load-test-cm 5 | namespace: demo-apps 6 | data: 7 | load-test.js: | 8 | import { 9 | Writer, 10 | SchemaRegistry, 11 | SCHEMA_TYPE_JSON, 12 | } from "k6/x/kafka"; 13 | 14 | const writer = new Writer({ 15 | brokers: ["my-cluster-kafka-bootstrap.kafka:9092"], 16 | topic: "events", 17 | }); 18 | 19 | const schemaRegistry = new SchemaRegistry(); 20 | 21 | export default function () { 22 | writer.produce({ 23 | messages: [ 24 | { 25 | value: schemaRegistry.serialize({ 26 | data: { 27 | id: 1 28 | }, 29 | schemaType: SCHEMA_TYPE_JSON, 30 | }), 31 | }, 32 | ], 33 | }); 34 | } 35 | 36 | export function teardown(data) { 37 | writer.close(); 38 | } 39 | --- 40 | apiVersion: apps/v1 41 | kind: Deployment 42 | metadata: 43 | name: k6-test 44 | namespace: demo-apps 45 | spec: 46 | selector: 47 | matchLabels: 48 | app.kubernetes.io/name: k6-test 49 | template: 50 | metadata: 51 | labels: 52 | app.kubernetes.io/name: k6-test 53 | spec: 54 | containers: 55 | - image: mostafamoradian/xk6-kafka:latest 56 | name: xk6-kafka 57 | command: 58 | - "k6" 59 | - "run" 60 | - "--vus" 61 | - "20" 62 | - "--duration" 63 | - "600s" 64 | - "/tests/load-test.js" 65 | volumeMounts: 66 | - mountPath: /tests 67 | name: test 68 | volumes: 69 | - name: test 70 | configMap: 71 | name: load-test-cm -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/java/pl/redhat/samples/person/PersonApplication.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.person; 2 | 3 | import com.blazebit.persistence.Criteria; 4 | import com.blazebit.persistence.CriteriaBuilderFactory; 5 | import com.blazebit.persistence.integration.view.spring.EnableEntityViews; 6 | import com.blazebit.persistence.spi.CriteriaBuilderConfiguration; 7 | import com.blazebit.persistence.spring.data.repository.config.EnableBlazeRepositories; 8 | import com.blazebit.persistence.view.EntityViewManager; 9 | import com.blazebit.persistence.view.spi.EntityViewConfiguration; 10 | import org.springframework.boot.SpringApplication; 11 | import org.springframework.boot.autoconfigure.SpringBootApplication; 12 | import org.springframework.context.annotation.Bean; 13 | 14 | import jakarta.persistence.EntityManagerFactory; 15 | import jakarta.persistence.PersistenceUnit; 16 | 17 | @SpringBootApplication 18 | @EnableBlazeRepositories 19 | @EnableEntityViews 20 | public class PersonApplication { 21 | 22 | public static void main(String[] args) { 23 | SpringApplication.run(PersonApplication.class, args); 24 | } 25 | 26 | @PersistenceUnit 27 | private EntityManagerFactory entityManagerFactory; 28 | 29 | @Bean 30 | public CriteriaBuilderFactory createCriteriaBuilderFactory() { 31 | CriteriaBuilderConfiguration config = Criteria.getDefault(); 32 | return config.createCriteriaBuilderFactory(entityManagerFactory); 33 | } 34 | 35 | @Bean 36 | public EntityViewManager createEntityViewManager( 37 | CriteriaBuilderFactory criteriaBuilderFactory, EntityViewConfiguration entityViewConfiguration) { 38 | return entityViewConfiguration.createEntityViewManager(criteriaBuilderFactory); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /event-driven/order-query-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | order-query-service 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-stream-kafka 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-data-jpa 26 | 27 | 28 | com.h2database 29 | h2 30 | runtime 31 | 32 | 33 | com.fasterxml.jackson.datatype 34 | jackson-datatype-jsr310 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /micro-view/employee/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | micro-view 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | employee 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-data-jpa 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.postgresql 29 | postgresql 30 | runtime 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | com.google.cloud.tools 42 | jib-maven-plugin 43 | 3.5.1 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /micro-view/organization/k8s/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: organization 5 | labels: 6 | app: organization 7 | app.openshift.io/runtime: spring-boot 8 | app.kubernetes.io/component: backend 9 | app.kubernetes.io/part-of: organization-app 10 | annotations: 11 | app.openshift.io/connects-to: organization-db 12 | spec: 13 | replicas: 2 14 | selector: 15 | matchLabels: 16 | app: organization 17 | template: 18 | metadata: 19 | labels: 20 | app: organization 21 | app.openshift.io/runtime: spring-boot 22 | app.kubernetes.io/component: backend 23 | app.kubernetes.io/part-of: organization-app 24 | annotations: 25 | app.openshift.io/connects-to: organization-db 26 | spec: 27 | containers: 28 | - name: organization 29 | image: piomin/organization 30 | ports: 31 | - containerPort: 8080 32 | env: 33 | - name: DATABASE_NAME 34 | valueFrom: 35 | secretKeyRef: 36 | name: organization-db 37 | key: database-name 38 | - name: DATABASE_USER 39 | valueFrom: 40 | secretKeyRef: 41 | name: organization-db 42 | key: database-user 43 | - name: DATABASE_PASSWORD 44 | valueFrom: 45 | secretKeyRef: 46 | name: organization-db 47 | key: database-password 48 | --- 49 | apiVersion: v1 50 | kind: Service 51 | metadata: 52 | name: organization 53 | labels: 54 | app: organization 55 | spec: 56 | ports: 57 | - port: 8080 58 | protocol: TCP 59 | selector: 60 | app: organization -------------------------------------------------------------------------------- /micro-view/department/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | pl.redhat.samples 8 | micro-view 9 | 1.0-SNAPSHOT 10 | 11 | 4.0.0 12 | 13 | department 14 | 15 | 16 | ${project.artifactId} 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.postgresql 30 | postgresql 31 | runtime 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-maven-plugin 40 | 41 | 42 | com.google.cloud.tools 43 | jib-maven-plugin 44 | 3.5.1 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /event-driven/consumer/src/main/java/pl/redhat/samples/eventdriven/ConsumerAApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.messaging.Message; 9 | import pl.redhat.samples.eventdriven.message.CallmeEvent; 10 | 11 | import java.util.function.Consumer; 12 | 13 | @SpringBootApplication 14 | public class ConsumerAApp { 15 | 16 | private static final Logger LOG = LoggerFactory.getLogger(ConsumerAApp.class); 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(ConsumerAApp.class, args); 20 | } 21 | 22 | @Bean 23 | public Consumer> eventConsumer() { 24 | return event -> { 25 | LOG.info("Received: {}", event.getPayload()); 26 | // throw new UnsupportedOperationException(); 27 | // Acknowledgment acknowledgment = event.getHeaders().get(KafkaHeaders.ACKNOWLEDGMENT, Acknowledgment.class); 28 | // if (acknowledgment != null) { 29 | // LOG.info("Manual Ack"); 30 | // if (event.getPayload().getEventType().equals("COMMIT")) { 31 | // acknowledgment.acknowledge(); 32 | // LOG.info("Committed"); 33 | // } 34 | // } 35 | }; 36 | } 37 | 38 | // @Bean 39 | // public ListenerContainerCustomizer containerCustomizer() { 40 | // return (container, dest, group) -> container.setErrorHandler(new SeekToCurrentErrorHandler(new FixedBackOff(1000, 3))); 41 | // } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /micro-view/organization/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | pl.redhat.samples 8 | micro-view 9 | 1.0-SNAPSHOT 10 | 11 | 4.0.0 12 | 13 | organization 14 | 15 | 16 | ${project.artifactId} 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.postgresql 30 | postgresql 31 | runtime 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-maven-plugin 40 | 41 | 42 | com.google.cloud.tools 43 | jib-maven-plugin 44 | 3.5.1 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /event-driven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | org.springframework.boot 10 | spring-boot-starter-parent 11 | 3.5.9 12 | 13 | 14 | 15 | pl.redhat.samples 16 | event-driven 17 | 1.0-SNAPSHOT 18 | pom 19 | 20 | 21 | 21 22 | 2025.1.0 23 | ${project.artifactId} 24 | 25 | 26 | 27 | producer 28 | consumer 29 | event-gateway 30 | order-service 31 | payment-service 32 | shipment-service 33 | order-query-service 34 | streams 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-dependencies 42 | ${spring-cloud.version} 43 | pom 44 | import 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /camel-spring/person-demo/src/main/java/pl/redhat/samples/camel/person/route/PersonRouteBuilder.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.camel.person.route; 2 | 3 | import org.apache.camel.builder.RouteBuilder; 4 | import org.apache.camel.model.rest.RestBindingMode; 5 | import org.springframework.stereotype.Component; 6 | import pl.redhat.samples.camel.person.domain.Person; 7 | import pl.redhat.samples.camel.person.service.PersonService; 8 | 9 | @Component 10 | public class PersonRouteBuilder extends RouteBuilder { 11 | 12 | @Override 13 | public void configure() throws Exception { 14 | 15 | restConfiguration() 16 | .contextPath("/camel") 17 | .apiContextPath("/api-doc") 18 | .apiProperty("api.title", "Person Management API") 19 | .apiProperty("api.version", "1.0") 20 | .apiContextRouteId("doc-api") 21 | .port(8080) 22 | .bindingMode(RestBindingMode.json); 23 | 24 | rest("/persons") 25 | .get("/{id}").to("direct:findById") 26 | .get("/").to("direct:findAll") 27 | .get("/older-than/{age}").to("direct:countOlderThan") 28 | .post().consumes("application/json").type(Person.class) 29 | .to("direct:add") 30 | .delete("/{id}").to("direct:delete"); 31 | 32 | from("direct:findById").bean(PersonService.class, "findById(${header.id})"); 33 | from("direct:findAll").bean(PersonService.class, "findAll"); 34 | from("direct:countOlderThan").bean(PersonService.class, "countOlderThan(${header.age})"); 35 | from("direct:add") 36 | .bean(PersonService.class, "add(${body})") 37 | .log("New: ${body}"); 38 | from("direct:delete").bean(PersonService.class, "delete(${header.id})"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/service/ShipmentService.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | import pl.redhat.samples.eventdriven.shipment.domain.Product; 5 | import pl.redhat.samples.eventdriven.shipment.exception.NotEnoughProductsException; 6 | import pl.redhat.samples.eventdriven.shipment.message.ConfirmCommand; 7 | import pl.redhat.samples.eventdriven.shipment.message.OrderCommand; 8 | import pl.redhat.samples.eventdriven.shipment.message.OrderEvent; 9 | import pl.redhat.samples.eventdriven.shipment.repository.ProductRepository; 10 | 11 | @Service 12 | public class ShipmentService { 13 | 14 | private ProductRepository productRepository; 15 | 16 | public ShipmentService(ProductRepository productRepository) { 17 | this.productRepository = productRepository; 18 | } 19 | 20 | public OrderEvent reserveProducts(OrderCommand orderCommand) { 21 | Product product = productRepository.findById(orderCommand.getProductId()).orElseThrow(); 22 | product.setReservedCount(product.getReservedCount() - orderCommand.getProductCount()); 23 | if (product.getReservedCount() > 0) 24 | throw new NotEnoughProductsException(); 25 | productRepository.save(product); 26 | return new OrderEvent(orderCommand.getId(), "OK", "RESERVATION"); 27 | } 28 | 29 | public OrderEvent confirmProducts(ConfirmCommand confirmCommand) { 30 | Product product = productRepository.findById(confirmCommand.getProductId()).orElseThrow(); 31 | product.setReservedCount(product.getCurrentCount() - confirmCommand.getProductCount()); 32 | productRepository.save(product); 33 | return new OrderEvent(confirmCommand.getOrderId(), "OK", "CONFIRMATION"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /basic-with-db/insurance-app/src/main/java/pl/redhat/samples/quarkus/insurance/resource/InsuranceResource.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.quarkus.insurance.resource; 2 | 3 | import org.eclipse.microprofile.rest.client.inject.RestClient; 4 | import pl.redhat.samples.quarkus.insurance.client.PersonService; 5 | import pl.redhat.samples.quarkus.insurance.client.message.Person; 6 | import pl.redhat.samples.quarkus.insurance.model.Insurance; 7 | import pl.redhat.samples.quarkus.insurance.model.InsuranceDetails; 8 | import pl.redhat.samples.quarkus.insurance.repository.InsuranceRepository; 9 | 10 | import jakarta.inject.Inject; 11 | import jakarta.transaction.Transactional; 12 | import jakarta.ws.rs.GET; 13 | import jakarta.ws.rs.POST; 14 | import jakarta.ws.rs.Path; 15 | import jakarta.ws.rs.PathParam; 16 | import java.util.List; 17 | 18 | @Path("/insurances") 19 | public class InsuranceResource { 20 | 21 | @Inject 22 | InsuranceRepository insuranceRepository; 23 | @Inject @RestClient 24 | PersonService personService; 25 | 26 | @POST 27 | @Transactional 28 | public Insurance addInsurance(Insurance insurance) { 29 | insuranceRepository.persist(insurance); 30 | return insurance; 31 | } 32 | 33 | @GET 34 | public List getInsurances() { 35 | return insuranceRepository.listAll(); 36 | } 37 | 38 | @GET 39 | @Path("/{id}") 40 | public Insurance getInsuranceById(@PathParam("id") Long id) { 41 | return insuranceRepository.findById(id); 42 | } 43 | 44 | @GET 45 | @Path("/{id}/details") 46 | public InsuranceDetails getInsuranceDetailsById(@PathParam("id") Long id) { 47 | Insurance insurance = insuranceRepository.findById(id); 48 | Person person = personService.getPersonById(insurance.personId); 49 | return new InsuranceDetails(person, insurance); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /micro-view/organization/src/main/java/pl/redhat/samples/organization/model/Organization.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.organization.model; 2 | 3 | import jakarta.persistence.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | @Entity 8 | public class Organization { 9 | 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | private Long id; 13 | private String name; 14 | private String address; 15 | @Transient 16 | private List departments = new ArrayList<>(); 17 | @Transient 18 | private List employees = new ArrayList<>(); 19 | 20 | public Organization() { 21 | 22 | } 23 | 24 | public Organization(String name, String address) { 25 | this.name = name; 26 | this.address = address; 27 | } 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public String getAddress() { 46 | return address; 47 | } 48 | 49 | public void setAddress(String address) { 50 | this.address = address; 51 | } 52 | 53 | public List getDepartments() { 54 | return departments; 55 | } 56 | 57 | public void setDepartments(List departments) { 58 | this.departments = departments; 59 | } 60 | 61 | public List getEmployees() { 62 | return employees; 63 | } 64 | 65 | public void setEmployees(List employees) { 66 | this.employees = employees; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "Organization [id=" + id + ", name=" + name + ", address=" + address + "]"; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /event-driven/order-query-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring.application.name: order-query-service 2 | 3 | spring.kafka.bootstrap-servers: pminkows-k-c-ma--adc-smj-himh-g.bf2.kafka.rhcloud.com:443 4 | 5 | spring.cloud.stream.bindings.orders-in-0.destination: user.pminkows.ordercommand 6 | spring.cloud.stream.kafka.bindings.orders-in-0.consumer.startOffset: earliest 7 | spring.cloud.stream.kafka.bindings.orders-in-0.consumer.resetOffsets: true 8 | 9 | spring.cloud.stream.bindings.confirmations-in-0.destination: user.pminkows.confirmcommand 10 | spring.cloud.stream.kafka.bindings.confirmations-in-0.consumer.startOffset: earliest 11 | spring.cloud.stream.kafka.bindings.confirmations-in-0.consumer.resetOffsets: true 12 | 13 | spring.cloud.stream.bindings.queries-in-0.destination: user.pminkows.orderquery 14 | spring.cloud.stream.bindings.queries-in-0.consumer.maxAttempts: 5 15 | 16 | spring.cloud.stream.bindings.queries-out-0.destination: user.pminkows.orderqueryresult 17 | 18 | spring.cloud.function.definition: orders;confirmations;queries 19 | 20 | #spring.cloud.stream.kafka.streams.binder.configuration.security.protocol: SASL_SSL 21 | #spring.cloud.stream.kafka.streams.binder.configuration.sasl.mechanism: PLAIN 22 | #spring.cloud.stream.kafka.streams.binder.configuration.sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="srvc-acct-7e2b5429-257e-4b32-a0a7-593d20310267" password="25f07668-33d8-494b-9791-10acbc485b7f"; 23 | 24 | spring.cloud.stream.kafka.binder.configuration.security.protocol: SASL_SSL 25 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism: PLAIN 26 | spring.cloud.stream.kafka.binder.jaas.loginModule: org.apache.kafka.common.security.plain.PlainLoginModule 27 | spring.cloud.stream.kafka.binder.jaas.options.username: srvc-acct-7e2b5429-257e-4b32-a0a7-593d20310267 28 | spring.cloud.stream.kafka.binder.jaas.options.password: 25f07668-33d8-494b-9791-10acbc485b7f -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/README.md: -------------------------------------------------------------------------------- 1 | # quarkus-with-db-openshift project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application can be packaged using: 17 | ```shell script 18 | ./mvnw package 19 | ``` 20 | It produces the `quarkus-with-db-openshift-1.0.0-SNAPSHOT-runner.jar` file in the `/target` directory. 21 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 22 | 23 | If you want to build an _über-jar_, execute the following command: 24 | ```shell script 25 | ./mvnw package -Dquarkus.package.type=uber-jar 26 | ``` 27 | 28 | The application is now runnable using `java -jar target/quarkus-with-db-openshift-1.0.0-SNAPSHOT-runner.jar`. 29 | 30 | ## Creating a native executable 31 | 32 | You can create a native executable using: 33 | ```shell script 34 | ./mvnw package -Pnative 35 | ``` 36 | 37 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 38 | ```shell script 39 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 40 | ``` 41 | 42 | You can then execute your native executable with: `./target/quarkus-with-db-openshift-1.0.0-SNAPSHOT-runner` 43 | 44 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 45 | 46 | # RESTEasy JSON serialisation using Jackson 47 | 48 |

This example demonstrate RESTEasy JSON serialisation by letting you list, add and remove quark types from a list.

49 |

Quarked!

50 | 51 | Guide: https://quarkus.io/guides/rest-json 52 | -------------------------------------------------------------------------------- /micro-springboot/person-service/src/main/java/pl/redhat/samples/person/domain/Person.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.person.domain; 2 | 3 | import jakarta.persistence.*; 4 | 5 | @Entity 6 | public class Person { 7 | @Id 8 | @GeneratedValue(strategy = GenerationType.IDENTITY) 9 | private Integer id; 10 | private String firstName; 11 | private String lastName; 12 | private int age; 13 | @Enumerated(EnumType.STRING) 14 | private Gender gender; 15 | private Integer externalId; 16 | 17 | public Integer getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Integer id) { 22 | this.id = id; 23 | } 24 | 25 | public String getFirstName() { 26 | return firstName; 27 | } 28 | 29 | public void setFirstName(String firstName) { 30 | this.firstName = firstName; 31 | } 32 | 33 | public String getLastName() { 34 | return lastName; 35 | } 36 | 37 | public void setLastName(String lastName) { 38 | this.lastName = lastName; 39 | } 40 | 41 | public int getAge() { 42 | return age; 43 | } 44 | 45 | public void setAge(int age) { 46 | this.age = age; 47 | } 48 | 49 | public Gender getGender() { 50 | return gender; 51 | } 52 | 53 | public void setGender(Gender gender) { 54 | this.gender = gender; 55 | } 56 | 57 | public Integer getExternalId() { 58 | return externalId; 59 | } 60 | 61 | public void setExternalId(Integer externalId) { 62 | this.externalId = externalId; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "Person{" + 68 | "id=" + id + 69 | ", name='" + firstName + " " + lastName + '\'' + 70 | ", age=" + age + 71 | ", gender=" + gender + 72 | ", externalId=" + externalId + 73 | '}'; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /event-driven/consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | consumer 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-actuator 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-stream-kafka 30 | 31 | 32 | io.micrometer 33 | micrometer-registry-prometheus 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | com.google.cloud.tools 45 | jib-maven-plugin 46 | 3.5.1 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /event-driven/producer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | event-driven 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | producer 13 | 14 | 15 | ${project.artifactId} 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-actuator 26 | 27 | 28 | io.micrometer 29 | micrometer-registry-prometheus 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-stream-kafka 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | com.google.cloud.tools 46 | jib-maven-plugin 47 | 3.5.1 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /mesh-with-db/quarkus-insurance-app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.application.name = quarkus-insurance-app 2 | quarkus.application.version = v1 3 | 4 | quarkus.datasource.db-kind = postgresql 5 | quarkus.datasource.username = ${POSTGRES_USER} 6 | quarkus.datasource.password = ${POSTGRES_PASSWORD} 7 | quarkus.datasource.jdbc.url = jdbc:postgresql://insurance-db:5432/${POSTGRES_DB} 8 | 9 | quarkus.swagger-ui.always-include = true 10 | quarkus.smallrye-metrics.micrometer.compatibility = true 11 | 12 | quarkus.container-image.group = demo-mesh 13 | #quarkus.container-image.build = true 14 | #quarkus.kubernetes.deploy = true 15 | quarkus.kubernetes.deployment-target = openshift 16 | 17 | quarkus.kubernetes-client.trust-certs=true 18 | 19 | quarkus.openshift.deployment-kind = Deployment 20 | #quarkus.openshift.replicas = 2 21 | quarkus.openshift.labels.app-type = demo 22 | quarkus.openshift.labels.app = quarkus-insurance-app 23 | quarkus.openshift.labels.version = v1 24 | quarkus.openshift.annotations.app-type = demo 25 | quarkus.openshift.annotations."sidecar.istio.io/inject" = true 26 | quarkus.openshift.env.mapping.postgres_user.from-secret = insurance-db 27 | quarkus.openshift.env.mapping.postgres_user.with-key = database-user 28 | quarkus.openshift.env.mapping.postgres_password.from-secret = insurance-db 29 | quarkus.openshift.env.mapping.postgres_password.with-key = database-password 30 | quarkus.openshift.env.mapping.postgres_db.from-secret = insurance-db 31 | quarkus.openshift.env.mapping.postgres_db.with-key = database-name 32 | 33 | pl.redhat.samples.quarkus.insurance.client.PersonService/mp-rest/url = http://quarkus-person-app:8080 34 | #org.eclipse.microprofile.rest.client.propagateHeaders=x-version,x-b3-traceid,x-b3-spanid,x-b3-parentspanid,X-Request-Id 35 | 36 | quarkus.http.access-log.enabled = true 37 | quarkus.http.access-log.pattern = long 38 | 39 | quarkus.liquibase.migrate-at-start = true 40 | quarkus.liquibase.change-log = db/changeLog.sql -------------------------------------------------------------------------------- /mesh-with-db/quarkus-person-app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # change to v2 in order to deploy as the second version 2 | quarkus.application.version = v1 3 | quarkus.application.name = quarkus-person-app 4 | 5 | quarkus.datasource.db-kind = postgresql 6 | quarkus.datasource.username = ${POSTGRES_USER} 7 | quarkus.datasource.password = ${POSTGRES_PASSWORD} 8 | quarkus.datasource.jdbc.url = jdbc:postgresql://person-db:5432/${POSTGRES_DB} 9 | 10 | quarkus.swagger-ui.always-include = true 11 | quarkus.smallrye-metrics.micrometer.compatibility = true 12 | 13 | quarkus.container-image.group = demo-mesh 14 | #quarkus.container-image.build = true 15 | #quarkus.kubernetes.deploy = true 16 | quarkus.kubernetes.deployment-target = openshift 17 | 18 | quarkus.kubernetes-client.trust-certs=true 19 | 20 | # uncomment for v2 21 | #quarkus.container-image.name = quarkus-person-app-v2 22 | 23 | quarkus.openshift.name = quarkus-person-app-${quarkus.application.version} 24 | quarkus.openshift.version = ${quarkus.application.version} 25 | quarkus.openshift.deployment-kind = Deployment 26 | #quarkus.openshift.route.expose = true 27 | #quarkus.openshift.replicas = 2 28 | quarkus.openshift.labels.app = quarkus-person-app 29 | quarkus.openshift.labels.version = ${quarkus.application.version} 30 | quarkus.openshift.annotations.app-type = demo 31 | quarkus.openshift.annotations."sidecar.istio.io/inject" = true 32 | quarkus.openshift.env.mapping.postgres_user.from-secret = person-db 33 | quarkus.openshift.env.mapping.postgres_user.with-key = database-user 34 | quarkus.openshift.env.mapping.postgres_password.from-secret = person-db 35 | quarkus.openshift.env.mapping.postgres_password.with-key = database-password 36 | quarkus.openshift.env.mapping.postgres_db.from-secret = person-db 37 | quarkus.openshift.env.mapping.postgres_db.with-key = database-name 38 | 39 | quarkus.http.access-log.enabled = true 40 | quarkus.http.access-log.pattern = long 41 | 42 | quarkus.liquibase.migrate-at-start=true 43 | quarkus.liquibase.change-log=db/changeLog.sql -------------------------------------------------------------------------------- /event-driven/producer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=producer 2 | 3 | spring.cloud.stream.bindings.eventSupplier-out-0.destination=test-topic 4 | #spring.cloud.stream.bindings.eventSupplier-out-0.producer.partitionKeyExpression=payload.id 5 | #spring.cloud.stream.bindings.eventSupplier-out-0.producer.partitionCount=1 6 | 7 | #spring.cloud.stream.kafka.bindings.eventSupplier-out-0.producer.bufferSize=32768 8 | 9 | #spring.cloud.stream.poller.maxMessagesPerPoll=10 10 | #spring.cloud.stream.poller.fixedDelay=100 11 | 12 | #spring.kafka.bootstrap-servers=kafka:9092 13 | #spring.kafka.bootstrap-servers=my-cluster-kafka-bootstrap:9092 14 | spring.kafka.bootstrap-servers=pminkows-d-c-ivd-quivqfkb-ogvba.bf2.kafka.rhcloud.com:443 15 | 16 | spring.cloud.stream.kafka.binder.configuration.security.protocol=SASL_SSL 17 | spring.cloud.stream.kafka.binder.configuration.sasl.mechanism=PLAIN 18 | spring.cloud.stream.kafka.binder.jaas.loginModule=org.apache.kafka.common.security.plain.PlainLoginModule 19 | spring.cloud.stream.kafka.binder.jaas.options.username=srvc-acct-1d1a4458-991a-4d7d-a71f-d954d10a5b29 20 | spring.cloud.stream.kafka.binder.jaas.options.password=744149ad-e5bb-478a-9281-ef150b28c72f 21 | 22 | #spring.cloud.stream.kafka.binder.configuration.security.protocol=SASL_PLAINTEXT 23 | #spring.cloud.stream.kafka.binder.configuration.sasl.mechanism=SCRAM-SHA-512 24 | #spring.cloud.stream.kafka.binder.jaas.loginModule=org.apache.kafka.common.security.scram.ScramLoginModule 25 | #spring.cloud.stream.kafka.binder.jaas.options.username=test-user 26 | #spring.cloud.stream.kafka.binder.jaas.options.password=nMtu0CTalijr 27 | 28 | spring.output.ansi.enabled=ALWAYS 29 | 30 | logging.pattern.console=%clr(%d{HH:mm:ss.SSS}){blue} %clr(---){faint} %clr([%15.15t]){yellow} %clr(:){red} %clr(%m){faint}%n 31 | #logging.level.org.springframework.cloud.stream=DEBUG 32 | 33 | management.endpoints.web.exposure.include=* 34 | management.endpoint.health.show-details=always 35 | 36 | #spring.cloud.stream.kafka.binder.requiredAcks=0 -------------------------------------------------------------------------------- /messaging/simple-counter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | pl.redhat.samples 7 | messaging 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simple-counter 13 | 1.0 14 | 15 | 16 | ${project.artifactId} 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | org.slf4j 26 | slf4j-simple 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-maven-plugin 35 | 36 | true 37 | false 38 | 39 | 40 | 41 | 42 | repackage 43 | 44 | 45 | 46 | 47 | 48 | com.google.cloud.tools 49 | jib-maven-plugin 50 | 3.5.1 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/InsuranceApplication.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.insurance; 2 | 3 | import com.blazebit.persistence.Criteria; 4 | import com.blazebit.persistence.CriteriaBuilderFactory; 5 | import com.blazebit.persistence.integration.view.spring.EnableEntityViews; 6 | import com.blazebit.persistence.spi.CriteriaBuilderConfiguration; 7 | import com.blazebit.persistence.spring.data.repository.config.EnableBlazeRepositories; 8 | import com.blazebit.persistence.view.EntityViewManager; 9 | import com.blazebit.persistence.view.spi.EntityViewConfiguration; 10 | import org.springframework.boot.SpringApplication; 11 | import org.springframework.boot.autoconfigure.SpringBootApplication; 12 | import org.springframework.boot.web.client.RestTemplateBuilder; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.web.client.RestTemplate; 15 | 16 | import jakarta.persistence.EntityManagerFactory; 17 | import jakarta.persistence.PersistenceUnit; 18 | 19 | @SpringBootApplication 20 | @EnableBlazeRepositories 21 | @EnableEntityViews 22 | public class InsuranceApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(InsuranceApplication.class, args); 26 | } 27 | 28 | @Bean 29 | RestTemplate restTemplate() { 30 | return new RestTemplateBuilder().build(); 31 | } 32 | 33 | @PersistenceUnit 34 | private EntityManagerFactory entityManagerFactory; 35 | 36 | @Bean 37 | public CriteriaBuilderFactory createCriteriaBuilderFactory() { 38 | CriteriaBuilderConfiguration config = Criteria.getDefault(); 39 | return config.createCriteriaBuilderFactory(entityManagerFactory); 40 | } 41 | 42 | @Bean 43 | public EntityViewManager createEntityViewManager( 44 | CriteriaBuilderFactory criteriaBuilderFactory, EntityViewConfiguration entityViewConfiguration) { 45 | return entityViewConfiguration.createEntityViewManager(criteriaBuilderFactory); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /event-driven/shipment-service/src/main/java/pl/redhat/samples/eventdriven/shipment/ShipmentServiceApp.java: -------------------------------------------------------------------------------- 1 | package pl.redhat.samples.eventdriven.shipment; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.stream.function.StreamBridge; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.scheduling.annotation.EnableScheduling; 9 | import pl.redhat.samples.eventdriven.shipment.message.ConfirmCommand; 10 | import pl.redhat.samples.eventdriven.shipment.message.OrderCommand; 11 | import pl.redhat.samples.eventdriven.shipment.message.OrderCommandDelayed; 12 | import pl.redhat.samples.eventdriven.shipment.message.OrderEvent; 13 | import pl.redhat.samples.eventdriven.shipment.service.ShipmentService; 14 | 15 | import java.util.concurrent.DelayQueue; 16 | import java.util.function.Consumer; 17 | import java.util.function.Function; 18 | 19 | @SpringBootApplication 20 | @EnableScheduling 21 | public class ShipmentServiceApp { 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(ShipmentServiceApp.class, args); 25 | } 26 | 27 | @Autowired 28 | private ShipmentService shipmentService; 29 | @Autowired 30 | private StreamBridge streamBridge; 31 | 32 | @Bean 33 | public Function orders() { 34 | return command -> shipmentService.reserveProducts(command); 35 | } 36 | 37 | @Bean 38 | public Consumer confirmations() { 39 | return command -> shipmentService.confirmProducts(command); 40 | } 41 | 42 | @Bean 43 | public DelayQueue delayQueue() { 44 | return new DelayQueue(); 45 | } 46 | 47 | @Bean 48 | public Consumer dlqs() { 49 | return input -> delayQueue().offer(new OrderCommandDelayed(input, 60000)); 50 | } 51 | 52 | } 53 | --------------------------------------------------------------------------------