├── spring-boot-mapstruct ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── mapstruct │ │ ├── SpringBootMapStructApplication.java │ │ ├── mappers │ │ ├── StudentMapper.java │ │ └── EmployeeMapper.java │ │ ├── dto │ │ ├── sample2 │ │ │ └── EmployeeDTO.java │ │ └── sample1 │ │ │ └── StudentDTO.java │ │ ├── dao │ │ └── entity │ │ │ ├── sample2 │ │ │ └── Employee.java │ │ │ └── sample1 │ │ │ └── Student.java │ │ └── service │ │ └── StudentService.java └── pom.xml ├── spring-boot-resilience4j ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ ├── logback-spring.xml │ │ └── log4j.properties │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── resilience4j │ │ └── SpringBootResilience4jApplication.java └── pom.xml ├── spring-boot-webflux ├── spring-boot-webflux-web │ ├── src │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── app │ │ │ ├── app.component.css │ │ │ ├── app.component.ts │ │ │ ├── app-routing.module.ts │ │ │ ├── app.module.ts │ │ │ └── app.component.spec.ts │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── styles.css │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── main.ts │ │ ├── test.ts │ │ └── polyfills.ts │ ├── e2e │ │ ├── tsconfig.json │ │ ├── src │ │ │ ├── app.po.ts │ │ │ └── app.e2e-spec.ts │ │ └── protractor.conf.js │ ├── tsconfig.app.json │ ├── .editorconfig │ ├── tsconfig.spec.json │ ├── browserslist │ ├── pom.xml │ ├── tsconfig.json │ ├── .gitignore │ ├── README.md │ ├── karma.conf.js │ ├── package.json │ ├── tslint.json │ └── angular.json ├── spring-boot-webflux-rest │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── mailshine │ │ │ └── springboot │ │ │ └── webflux │ │ │ ├── DemoSpringBootApplication.java │ │ │ ├── NotificationSample.java │ │ │ └── controller │ │ │ └── WebfluxController.java │ └── pom.xml ├── spring-boot-webflux-app │ └── pom.xml ├── spring-boot-webflux-parent │ └── pom.xml └── pom.xml ├── spring-boot-aop-aspectj ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── mailshine │ │ │ └── springboot │ │ │ └── aop │ │ │ └── aspectj │ │ │ ├── advise │ │ │ ├── TrackExecutionTime.java │ │ │ └── ExecutionTimeAdvice.java │ │ │ ├── SpringBootAspectJApplication.java │ │ │ ├── service │ │ │ └── EmployeeService.java │ │ │ └── controller │ │ │ └── Employee.java │ └── test │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── aop │ │ └── aspectj │ │ └── EmployeeServiceTest.java └── pom.xml ├── spring-boot-microservice ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── mailshine │ │ │ └── springboot │ │ │ └── microservices │ │ │ ├── DemoSpringBootApplication.java │ │ │ ├── models │ │ │ └── Employee.java │ │ │ ├── config │ │ │ ├── ApplicationConfig.java │ │ │ └── SwaggerConfig.java │ │ │ └── controllers │ │ │ └── SimpleController.java │ └── test │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── microservices │ │ └── ControllerTest.java └── pom.xml ├── spring-boot-jms ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── mailshine │ │ │ └── demo │ │ │ └── jms │ │ │ ├── mq │ │ │ └── MQListener.java │ │ │ ├── config │ │ │ └── MessagingConfig.java │ │ │ └── DemoSpringBootApplication.java │ │ └── resources │ │ └── application.yml └── pom.xml ├── spring-boot-standalone-activemq ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── mailshine │ │ │ └── springbootstandaloneactivemq │ │ │ ├── SpringBootStandaloneActivemqApplication.java │ │ │ ├── model │ │ │ └── Employee.java │ │ │ ├── jms │ │ │ ├── JmsProducer.java │ │ │ └── JmsConsumer.java │ │ │ ├── controller │ │ │ └── ProduceMessageController.java │ │ │ └── config │ │ │ ├── ApplicationConfig.java │ │ │ ├── SwaggerConfig.java │ │ │ └── ActiveMQConfig.java │ └── test │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springbootstandaloneactivemq │ │ └── SpringBootStandaloneActivemqApplicationTests.java ├── HELP.md └── pom.xml ├── spring-boot-swagger-yaml-model ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── swagger │ │ │ └── Model_1.0.0.yaml │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── swagger │ │ └── yaml │ │ ├── SpringBootYamlSwaggerApplication.java │ │ ├── controllers │ │ └── CourseDemoController.java │ │ └── config │ │ ├── ApplicationConfig.java │ │ └── SwaggerConfig.java └── pom.xml ├── spring-boot-kafka ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── kafka │ │ ├── model │ │ └── Student.java │ │ ├── DemoSpringBootApplication.java │ │ ├── listener │ │ └── KafkaMessageConsumer.java │ │ ├── controllers │ │ └── KafkaController.java │ │ ├── config │ │ ├── ApplicationConfig.java │ │ ├── KafkaTopicConfig.java │ │ ├── SwaggerConfig.java │ │ ├── KafkaProducerConfig.java │ │ └── KafkaConsumerConfig.java │ │ └── service │ │ └── ProducerService.java └── pom.xml ├── spring-boot-jms-activemq ├── src │ └── main │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── demo │ │ └── jms │ │ └── activemq │ │ ├── producer │ │ └── Producer.java │ │ ├── config │ │ ├── MQProducerConfig.java │ │ └── MQListenerConfig.java │ │ ├── controller │ │ └── MQController.java │ │ ├── DemoSpringBootApplication.java │ │ └── consumer │ │ └── Listener.java └── pom.xml ├── spring-boot-kafka-avro ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── demo.json │ │ └── avro │ │ │ └── Student.avsc │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── kafka │ │ └── avro │ │ ├── SpringBootKafkaAvroApplication.java │ │ ├── listener │ │ └── KafkaAvroMessageConsumer.java │ │ ├── config │ │ ├── ApplicationConfig.java │ │ ├── KafkaTopicConfig.java │ │ ├── SwaggerConfig.java │ │ ├── KafkaProducerConfig.java │ │ └── KafkaConsumerConfig.java │ │ ├── controller │ │ └── KafkaAvroController.java │ │ ├── serializer │ │ ├── AvroDeserializer.java │ │ └── AvroSerializer.java │ │ ├── service │ │ └── ProducerService.java │ │ └── model │ │ └── SampleReferenceStudent.java └── pom.xml ├── spring-boot-mutation-sample ├── ReadMe.md ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── mailshine │ │ │ └── springboot │ │ │ └── mutation │ │ │ ├── service │ │ │ └── EmployeeService.java │ │ │ ├── SpringBootMutationSampleApplication.java │ │ │ └── controller │ │ │ └── Employee.java │ └── test │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── mutation │ │ ├── controller │ │ └── EmployeeControllerTest.java │ │ └── service │ │ └── EmployeeServiceTest.java └── pom.xml ├── spring-boot-rabbitmq ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── mailshine │ │ │ └── rabbitmq │ │ │ ├── model │ │ │ └── Student.java │ │ │ ├── SpringBootRabbitmqApplication.java │ │ │ ├── mq │ │ │ └── RabbitMQListener.java │ │ │ ├── controller │ │ │ └── MessageController.java │ │ │ ├── service │ │ │ └── RabbitMQService.java │ │ │ └── config │ │ │ ├── ApplicationConfig.java │ │ │ ├── SwaggerConfig.java │ │ │ └── RabbitMQConfig.java │ └── test │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── rabbitmq │ │ └── SpringBootRabbitmqApplicationTests.java ├── HELP.md └── pom.xml ├── spring-boot-hystrix ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── logback-spring.xml │ │ └── log4j.properties │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── spring │ │ └── hystrix │ │ ├── config │ │ ├── RestTemplateBean.java │ │ ├── ApplicationConfig.java │ │ └── SwaggerConfig.java │ │ ├── exception │ │ └── EmployeeNotFoundException.java │ │ ├── service │ │ └── EmployeeService.java │ │ ├── SpringBootHystrixApplication.java │ │ ├── logging │ │ └── RequestFilterMDC.java │ │ └── controller │ │ └── EmployeeController.java └── pom.xml ├── spring-boot-sleuth └── pom.xml ├── spring-boot-message-consumer ├── src │ └── main │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── message │ │ └── consumer │ │ └── handling │ │ ├── DemoSpringBootApplication.java │ │ └── consumer │ │ ├── MessageRouter.java │ │ └── Listener.java └── pom.xml ├── spring-boot-micrometer ├── src │ └── main │ │ └── java │ │ └── com │ │ └── mailshine │ │ └── springboot │ │ └── micrometer │ │ └── SpringBootApplication.java └── pom.xml ├── .gitignore └── demo-spring-boot.iml /spring-boot-mapstruct/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-resilience4j/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/app/app.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | aspect.enabled=true -------------------------------------------------------------------------------- /spring-boot-microservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=microservice-sleuth 2 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /spring-boot-jms/src/main/java/com/mailshine/demo/jms/mq/MQListener.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.mq; 2 | 3 | public class MQListener { 4 | } 5 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | active-mq: 2 | broker-url: tcp://localhost:61616 3 | topic: demo.topic 4 | -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.endpoints.web.exposure.include=prometheus,health,info,metric 2 | 3 | 4 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | kafka.bootstrap.address=localhost:9092 3 | kafka.topic.name=shine-test-local-topic 4 | kafka.consumer=shine-local -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinemon/demo-spring-boot/HEAD/spring-boot-webflux/spring-boot-webflux-web/src/favicon.ico -------------------------------------------------------------------------------- /spring-boot-jms-activemq/src/main/java/com/mailshine/demo/jms/activemq/producer/Producer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.activemq.producer; 2 | 3 | public class Producer { 4 | } 5 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | kafka.bootstrap.address=localhost:9092 2 | kafka.topic.name=shine-test-local-avro-topic 3 | kafka.consumer=shine-local-avro -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/test/java/com/mailshine/springboot/aop/aspectj/EmployeeServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.aop.aspectj; 2 | 3 | public class EmployeeServiceTest { 4 | } 5 | -------------------------------------------------------------------------------- /spring-boot-jms/src/main/java/com/mailshine/demo/jms/config/MessagingConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.config; 2 | 3 | 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class MessagingConfig { 8 | } 9 | -------------------------------------------------------------------------------- /spring-boot-mutation-sample/ReadMe.md: -------------------------------------------------------------------------------- 1 | To verify Mutation Test Coverage 2 | 3 | mvn clean install org.pitest:pitest-maven:mutationCoverage 4 | 5 | [Mutation Testing — Can Unit Test Coverage Survive?](https://medium.com/@mailshine/mutation-testing-can-unit-test-coverage-survive-a9f9b64e6fbf) -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | exchange: 2 | name: myExchange 3 | queue: myQueue 4 | routing: 5 | key: myRoutingKey 6 | spring: 7 | rabbitmq: 8 | host: localhost 9 | passowrd: guest 10 | post: 5672 11 | username: guest 12 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/model/Student.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | @Getter @Setter 8 | @ToString 9 | public class Student { 10 | 11 | private String name; 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-microservice/src/test/java/com/mailshine/springboot/microservices/ControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.microservices; 2 | 3 | import org.junit.Test; 4 | 5 | public class ControllerTest { 6 | 7 | @Test 8 | public void simpleControllerTest(){ 9 | //todo 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-jms-activemq/src/main/java/com/mailshine/demo/jms/activemq/config/MQProducerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.activemq.config; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @Slf4j 8 | public class MQProducerConfig { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/model/Student.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.model; 2 | 3 | import lombok.*; 4 | 5 | @Getter @Setter 6 | @ToString 7 | @AllArgsConstructor @NoArgsConstructor 8 | public class Student { 9 | 10 | private String studentId; 11 | private String name; 12 | private String course; 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'spring-boot-com.mailshine.springboot.webflux-web'; 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | 5 | const routes: Routes = []; 6 | 7 | @NgModule({ 8 | imports: [RouterModule.forRoot(routes)], 9 | exports: [RouterModule] 10 | }) 11 | export class AppRoutingModule { } 12 | -------------------------------------------------------------------------------- /spring-boot-jms/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | jms: 2 | messagingIbmQueueName: 3 | appName: shine_demo 4 | messagingIbmSslProtocol: TLS 5 | messagingIbmKeyStoreType: JKS 6 | messagingIbmKeyStoreLocation: 7 | messagingIbmKeyStoreCode: 8 | messagingIbmHostName: 9 | messagingIbmQueueManager: 10 | messagingIbmPort: 11 | messagingIbmChannel: 12 | messagingIbmCipherSuite: -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/mailshine/rabbitmq/SpringBootRabbitmqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootRabbitmqApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-jms-activemq/src/main/java/com/mailshine/demo/jms/activemq/controller/MQController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.activemq.controller; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Controller; 5 | 6 | @Controller 7 | @Slf4j 8 | public class MQController { 9 | 10 | public void postMessage(String message) { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo(): Promise { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/src/main/resources/swagger/Model_1.0.0.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | 3 | info: 4 | version: "1.0.0" 5 | title: College Model 6 | 7 | definitions: 8 | Course: 9 | type: object 10 | properties: 11 | courseName: 12 | type: string 13 | description: Name of the Course 14 | courseId: 15 | type: string 16 | description: Unique course identifier -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SpringBootWebfluxWeb 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/resources/demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "com.mailshine.springboot.kafka.avro.model", 3 | "type": "record", 4 | "name": "Student", 5 | "fields": [ 6 | { 7 | "name": "studentName", 8 | "type": "string" 9 | }, 10 | { 11 | "name": "studentId", 12 | "type": "string" 13 | }, 14 | { 15 | "name": "age", 16 | "type": "int" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/resources/avro/Student.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "com.mailshine.springboot.kafka.avro.model", 3 | "type": "record", 4 | "name": "Student", 5 | "fields": [ 6 | { 7 | "name": "studentName", 8 | "type": "string" 9 | }, 10 | { 11 | "name": "studentId", 12 | "type": "string" 13 | }, 14 | { 15 | "name": "age", 16 | "type": "int" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /spring-boot-mutation-sample/src/main/java/com/mailshine/springboot/mutation/service/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mutation.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | @Slf4j 8 | public class EmployeeService { 9 | 10 | public String getEmployeeNameFromId(String id){ 11 | return "Name of Employee: " + id; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.endpoints.web.exposure.include=* 2 | # logging level 3 | logging.level.org.springframework=ERROR 4 | logging.level.com.mailshine=DEBUG 5 | # output to a file 6 | logging.file=app.log 7 | # temp folder example 8 | #logging.file=${java.io.tmpdir}/app.log 9 | logging.pattern.file=%d %p %c{1.} [%t] %m%n 10 | logging.pattern.console=%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/test/java/com/mailshine/springbootstandaloneactivemq/SpringBootStandaloneActivemqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootStandaloneActivemqApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mutation-sample/src/test/java/com/mailshine/springboot/mutation/controller/EmployeeControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mutation.controller; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.mockito.junit.MockitoJUnitRunner; 6 | 7 | @RunWith(MockitoJUnitRunner.class) 8 | public class EmployeeControllerTest { 9 | 10 | @Test 11 | public void EmployeServiceTest1(){ 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/main/java/com/mailshine/springboot/aop/aspectj/advise/TrackExecutionTime.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.aop.aspectj.advise; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface TrackExecutionTime { 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-jms/src/main/java/com/mailshine/demo/jms/DemoSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | 7 | @SpringBootApplication 8 | public class DemoSpringBootApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(DemoSpringBootApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/DemoSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoSpringBootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoSpringBootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/SpringBootRabbitmqApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootRabbitmqApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootRabbitmqApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/SpringBootKafkaAvroApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro; 2 | import org.springframework.boot.SpringApplication; 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | @SpringBootApplication 6 | public class SpringBootKafkaAvroApplication { 7 | public static void main(String[] args) { 8 | SpringApplication.run(SpringBootKafkaAvroApplication.class, args); 9 | } 10 | } -------------------------------------------------------------------------------- /spring-boot-sleuth/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | spring-boot-sleuth 9 | 1.0-SNAPSHOT 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-jms-activemq/src/main/java/com/mailshine/demo/jms/activemq/DemoSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.activemq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | 7 | 8 | @SpringBootApplication 9 | public class DemoSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(DemoSpringBootApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/main/java/com/mailshine/springboot/aop/aspectj/SpringBootAspectJApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.aop.aspectj; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootAspectJApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootAspectJApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-4r [%t] trace-id=%X{customMDCTradeId} %5p %c{1} - %m %n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-message-consumer/src/main/java/com/mailshine/message/consumer/handling/DemoSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.message.consumer.handling; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | 7 | @SpringBootApplication 8 | public class DemoSpringBootApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(DemoSpringBootApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/SpringBootMapStructApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | 7 | @SpringBootApplication 8 | public class SpringBootMapStructApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(SpringBootMapStructApplication.class, args); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /spring-boot-resilience4j/src/main/java/com/mailshine/springboot/resilience4j/SpringBootResilience4jApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.resilience4j; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootResilience4jApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(SpringBootResilience4jApplication.class, args); 10 | } 11 | } -------------------------------------------------------------------------------- /spring-boot-resilience4j/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-4r [%t] trace-id=%X{customMDCTradeId} %5p %c{1} - %m %n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /spring-boot-mutation-sample/src/main/java/com/mailshine/springboot/mutation/SpringBootMutationSampleApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mutation; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootMutationSampleApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootMutationSampleApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | 7 | @NgModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | imports: [ 12 | BrowserModule, 13 | AppRoutingModule 14 | ], 15 | providers: [], 16 | bootstrap: [AppComponent] 17 | }) 18 | export class AppModule { } 19 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/config/RestTemplateBean.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.client.RestTemplate; 6 | 7 | @Configuration 8 | public class RestTemplateBean { 9 | 10 | @Bean(value = "hystrixRestTemplate") 11 | public RestTemplate hystrixRestTemplate() { 12 | return new RestTemplate(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/main/java/com/mailshine/springboot/aop/aspectj/service/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.aop.aspectj.service; 2 | 3 | import com.mailshine.springboot.aop.aspectj.advise.TrackExecutionTime; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | @Slf4j 9 | public class EmployeeService { 10 | 11 | @TrackExecutionTime 12 | public String getEmployeeNameFromId(String id){ 13 | return "Test Name From Service"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/mappers/StudentMapper.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.mappers; 2 | 3 | import com.mailshine.springboot.mapstruct.dao.entity.sample1.Student; 4 | import com.mailshine.springboot.mapstruct.dto.sample1.StudentDTO; 5 | import org.mapstruct.Mapper; 6 | 7 | @Mapper(componentModel = "spring") 8 | public interface StudentMapper { 9 | 10 | StudentDTO studentToStudentDTO(Student student); 11 | 12 | Student studentDtoToStudent(StudentDTO studentDTO); 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/exception/EmployeeNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.exception; 2 | 3 | public class EmployeeNotFoundException extends RuntimeException { 4 | 5 | public EmployeeNotFoundException() { 6 | super(); 7 | } 8 | 9 | public EmployeeNotFoundException(String message) { 10 | super(message); 11 | } 12 | 13 | public EmployeeNotFoundException(String message, Throwable cause) { 14 | super(message, cause); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/service/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.service; 2 | 3 | import com.mailshine.spring.hystrix.exception.EmployeeNotFoundException; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @Service 10 | public class EmployeeService { 11 | 12 | public String getEmployees(String emplId) throws EmployeeNotFoundException { 13 | // 14 | 15 | return "Test Emp1"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/SpringBootStandaloneActivemqApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootStandaloneActivemqApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootStandaloneActivemqApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/dto/sample2/EmployeeDTO.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.dto.sample2; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.io.Serializable; 7 | 8 | @Getter 9 | @Setter 10 | public class EmployeeDTO implements Serializable { 11 | private static final long serialVersionUID = -1982320844677160215L; 12 | 13 | private String employeeId; 14 | private String firstName; 15 | private String lastName; 16 | private String department; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/listener/KafkaMessageConsumer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.listener; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.kafka.annotation.KafkaListener; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | @Slf4j 9 | public class KafkaMessageConsumer { 10 | 11 | @KafkaListener(topics = "shine-test-local-topic", groupId = "shine-local") 12 | public void listen(String message) { 13 | log.info("Received Messasge in group : {}", message); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/dto/sample1/StudentDTO.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.dto.sample1; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.io.Serializable; 7 | import java.util.UUID; 8 | 9 | @Getter 10 | @Setter 11 | public class StudentDTO implements Serializable { 12 | private static final long serialVersionUID = -652610286635305248L; 13 | 14 | private UUID id; 15 | private String studentId; 16 | private String studentFullName; 17 | private String course; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-message-consumer/src/main/java/com/mailshine/message/consumer/handling/consumer/MessageRouter.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.message.consumer.handling.consumer; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.function.Consumer; 7 | 8 | @Component 9 | @Slf4j 10 | public class MessageRouter implements Consumer { 11 | 12 | @Override 13 | public void accept(Object o) { 14 | if (true) { 15 | 16 | } else if (false) { 17 | 18 | } else { 19 | //defaultHandling 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-micrometer/src/main/java/com/mailshine/springboot/micrometer/SpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.micrometer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | 5 | /** 6 | * The type Demo spring boot application. 7 | */ 8 | @org.springframework.boot.autoconfigure.SpringBootApplication 9 | public class SpringBootApplication { 10 | 11 | /** 12 | * The entry point of application. 13 | * 14 | * @param args the input arguments 15 | */ 16 | public static void main(String[] args) { 17 | SpringApplication.run(SpringBootApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/dao/entity/sample2/Employee.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.dao.entity.sample2; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.Entity; 7 | import javax.persistence.Id; 8 | import java.io.Serializable; 9 | 10 | @Entity 11 | @Getter 12 | @Setter 13 | public class Employee implements Serializable { 14 | private static final long serialVersionUID = -915074092244502794L; 15 | 16 | @Id 17 | private String empId; 18 | private String firstNm; 19 | private String lastNm; 20 | private String department; 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender 2 | log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout 3 | #note the %X{userName} - this is how you fetch data from Mapped Diagnostic Context (MDC) 4 | # %x is used to fetch data from NDC. So below setting uses both MDC and NDC 5 | log4j.appender.consoleAppender.layout.ConversionPattern=%-4r [%t] %5p %c{1} %x - %m - tx.id=%X{customMDCTradeId} %n 6 | # NDC only setting - %x is used to fetch data from NDC 7 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-4r [%t] %5p %c{1} - %m - [%x]%n 8 | log4j.rootLogger=INFO, consoleAppender -------------------------------------------------------------------------------- /spring-boot-resilience4j/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender 2 | log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout 3 | #note the %X{userName} - this is how you fetch data from Mapped Diagnostic Context (MDC) 4 | # %x is used to fetch data from NDC. So below setting uses both MDC and NDC 5 | log4j.appender.consoleAppender.layout.ConversionPattern=%-4r [%t] %5p %c{1} %x - %m - tx.id=%X{customMDCTradeId} %n 6 | # NDC only setting - %x is used to fetch data from NDC 7 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-4r [%t] %5p %c{1} - %m - [%x]%n 8 | log4j.rootLogger=INFO, consoleAppender -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/listener/KafkaAvroMessageConsumer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.listener; 2 | 3 | import com.mailshine.springboot.kafka.avro.model.Student; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.kafka.annotation.KafkaListener; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | @Slf4j 10 | public class KafkaAvroMessageConsumer { 11 | 12 | @KafkaListener(topics = "shine-test-local-avro-topic", groupId = "shine-local-avro") 13 | public void listen(Student message) { 14 | log.info("Received Messasge in group : {}", message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/dao/entity/sample1/Student.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.dao.entity.sample1; 2 | 3 | 4 | import lombok.Data; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | import javax.persistence.Entity; 9 | import java.io.Serializable; 10 | import java.util.UUID; 11 | 12 | @Entity 13 | @Getter 14 | @Setter 15 | public class Student implements Serializable { 16 | 17 | private static final long serialVersionUID = 5165243234230734093L; 18 | 19 | private UUID id; 20 | private String studentId; 21 | private String studentFullName; 22 | private String course; 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-microservice/src/main/java/com/mailshine/springboot/microservices/DemoSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.microservices; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * The type Demo spring boot application. 8 | */ 9 | @SpringBootApplication 10 | public class DemoSpringBootApplication { 11 | 12 | /** 13 | * The entry point of application. 14 | * 15 | * @param args the input arguments 16 | */ 17 | public static void main(String[] args) { 18 | SpringApplication.run(DemoSpringBootApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-rest/src/main/java/com/mailshine/springboot/webflux/DemoSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.webflux; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * The type Demo spring boot application. 8 | */ 9 | @SpringBootApplication 10 | public class DemoSpringBootApplication { 11 | 12 | /** 13 | * The entry point of application. 14 | * 15 | * @param args the input arguments 16 | */ 17 | public static void main(String[] args) { 18 | SpringApplication.run(DemoSpringBootApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.4.RELEASE 9 | 10 | 11 | 4.0.0 12 | 13 | spring-boot-webflux-web 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/mq/RabbitMQListener.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.mq; 2 | 3 | import com.mailshine.rabbitmq.model.Student; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.amqp.core.Message; 6 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.stereotype.Service; 9 | 10 | @Component 11 | @Slf4j 12 | public class RabbitMQListener { 13 | 14 | @RabbitListener(queues = "${queue}") 15 | public void messageListener(Student message){ 16 | log.info("Received Message from RabbitMQ Listener: {}", message.toString()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | }, 22 | "angularCompilerOptions": { 23 | "fullTemplateTypeCheck": true, 24 | "strictInjectionParameters": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/SpringBootHystrixApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 7 | 8 | @SpringBootApplication 9 | @EnableCircuitBreaker 10 | @EnableHystrixDashboard 11 | public class SpringBootHystrixApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringBootHystrixApplication.class, args); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-app/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.4.RELEASE 9 | 10 | 11 | 4.0.0 12 | 13 | spring-boot-webflux-app 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | spring-boot-webflux-parent 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 2.2.4.RELEASE 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-mutation-sample/src/test/java/com/mailshine/springboot/mutation/service/EmployeeServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mutation.service; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.mockito.InjectMocks; 7 | import org.mockito.junit.MockitoJUnitRunner; 8 | 9 | @RunWith(MockitoJUnitRunner.class) 10 | public class EmployeeServiceTest { 11 | 12 | @InjectMocks 13 | EmployeeService employeeService; 14 | 15 | @Test 16 | public void EmployeServiceTest1(){ 17 | String result = employeeService.getEmployeeNameFromId("Test"); 18 | Assert.assertNotNull(result); 19 | Assert.assertEquals("Name of Employee: Test", result); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/src/main/java/com/mailshine/swagger/yaml/SpringBootYamlSwaggerApplication.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.swagger.yaml; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | 8 | 9 | @SpringBootApplication 10 | @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) 11 | public class SpringBootYamlSwaggerApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringBootYamlSwaggerApplication.class, args); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/src/main/java/com/mailshine/swagger/yaml/controllers/CourseDemoController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.swagger.yaml.controllers; 2 | 3 | import com.mailshine.swagger.yaml.model.Course; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @RequestMapping("/api") 11 | 12 | public class CourseDemoController { 13 | 14 | @Autowired 15 | private Course demoCourse; 16 | 17 | @GetMapping("/getCourse") 18 | public Course getCourse() { 19 | return demoCourse; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-microservice/src/main/java/com/mailshine/springboot/microservices/models/Employee.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.microservices.models; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * The type Employee. 12 | */ 13 | @Getter @Setter @NoArgsConstructor @ToString 14 | public class Employee implements Serializable { 15 | private static final long serialVersionUID = 300002228479017363L; 16 | 17 | private String employeeId; 18 | private String employeeFullName; 19 | private String employeeFirstName; 20 | private String employeeMiddleName; 21 | private String employeeLastName; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/model/Employee.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.model; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * The type Employee. 12 | */ 13 | @Getter @Setter @NoArgsConstructor @ToString 14 | public class Employee implements Serializable { 15 | private static final long serialVersionUID = 300002228479017363L; 16 | 17 | private String employeeId; 18 | private String employeeFullName; 19 | private String employeeFirstName; 20 | private String employeeMiddleName; 21 | private String employeeLastName; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('spring-boot-com.mailshine.springboot.webflux-web app is running!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /spring-boot-jms-activemq/src/main/java/com/mailshine/demo/jms/activemq/consumer/Listener.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.activemq.consumer; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | 6 | import javax.jms.JMSException; 7 | import javax.jms.Message; 8 | import javax.jms.MessageListener; 9 | import javax.jms.TextMessage; 10 | 11 | @Slf4j 12 | @Component 13 | public class Listener implements MessageListener { 14 | 15 | @Override 16 | public void onMessage(Message message) { 17 | 18 | String payload = null; 19 | try { 20 | payload = ((TextMessage)message).getText(); 21 | log.info("Received Message : " + payload); 22 | } catch (JMSException e) { 23 | log.error("Error Processing Message " + e.toString()); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/service/StudentService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.service; 2 | 3 | import com.mailshine.springboot.mapstruct.dao.entity.sample1.Student; 4 | import com.mailshine.springboot.mapstruct.dto.sample1.StudentDTO; 5 | import com.mailshine.springboot.mapstruct.mappers.StudentMapper; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class StudentService { 10 | 11 | private final StudentMapper studentMapper; 12 | 13 | public StudentService(StudentMapper studentMapper) { 14 | this.studentMapper = studentMapper; 15 | } 16 | 17 | public StudentDTO save(StudentDTO studentDTO) { 18 | 19 | Student studentEntity = studentMapper.studentDtoToStudent(studentDTO); 20 | /// actual save actions. 21 | return studentDTO; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/src/main/java/com/mailshine/springboot/mapstruct/mappers/EmployeeMapper.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mapstruct.mappers; 2 | 3 | import com.mailshine.springboot.mapstruct.dao.entity.sample2.Employee; 4 | import com.mailshine.springboot.mapstruct.dto.sample2.EmployeeDTO; 5 | import org.mapstruct.InheritInverseConfiguration; 6 | import org.mapstruct.Mapper; 7 | import org.mapstruct.Mapping; 8 | import org.mapstruct.Mappings; 9 | 10 | @Mapper(componentModel = "spring") 11 | public interface EmployeeMapper { 12 | 13 | @Mapping(source = "empId", target = "employeeId") 14 | @Mapping(source = "firstNm", target = "firstName") 15 | @Mapping(source = "lastNm", target = "lastName") 16 | EmployeeDTO employeeToEmployeeDTO(Employee employee); 17 | 18 | @InheritInverseConfiguration 19 | Employee employeeDtoToEmploye(EmployeeDTO employeeDTO); 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/controllers/KafkaController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.controllers; 2 | 3 | import com.mailshine.springboot.kafka.model.Student; 4 | import com.mailshine.springboot.kafka.service.ProducerService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController 12 | @RequestMapping("/api") 13 | @Slf4j 14 | public class KafkaController { 15 | 16 | @Autowired 17 | ProducerService producerService; 18 | 19 | @PostMapping (value = "/send/student/info") 20 | public String kafkaMessage(@RequestBody Student message){ 21 | producerService.sendMessage(message.toString()); 22 | return "Success"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-rest/src/main/java/com/mailshine/springboot/webflux/NotificationSample.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.webflux; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class NotificationSample { 7 | 8 | public static List stringList(){ 9 | List stringList = new ArrayList<>(); 10 | stringList.add("Demo String One"); 11 | stringList.add("Demo String Two"); 12 | stringList.add("Demo String Three"); 13 | stringList.add("Demo String Four"); 14 | stringList.add("Demo String Five"); 15 | stringList.add("Demo String Six"); 16 | stringList.add("Demo String Seven"); 17 | stringList.add("Demo String Eight"); 18 | stringList.add("Demo String Nine"); 19 | stringList.add("Demo String Ten"); 20 | return stringList; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-rest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 2.2.4.RELEASE 14 | 15 | 16 | 4.0.0 17 | 18 | spring-boot-webflux-rest 19 | 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-rest/src/main/java/com/mailshine/springboot/webflux/controller/WebfluxController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.webflux.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | import reactor.core.publisher.Flux; 7 | 8 | import java.time.Duration; 9 | 10 | import static com.mailshine.springboot.webflux.NotificationSample.stringList; 11 | 12 | @RestController 13 | @RequestMapping("/api") 14 | public class WebfluxController { 15 | 16 | @GetMapping("/stream/notification") 17 | public Flux streamString(){ 18 | return Flux.fromStream(stringList().stream()) 19 | .map(s -> String.valueOf(s)) 20 | .delayElements(Duration.ofSeconds(1)); 21 | } 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Configuration 8 | public class ApplicationConfig { 9 | 10 | @Configuration 11 | public static class BrowserHistoryConfig implements WebMvcConfigurer { 12 | 13 | @Override 14 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 15 | registry 16 | .addResourceHandler("swagger-ui.html") 17 | .addResourceLocations("classpath:/META-INF/resources/"); 18 | 19 | registry 20 | .addResourceHandler("/webjars/**") 21 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Configuration 8 | public class ApplicationConfig { 9 | 10 | @Configuration 11 | public static class BrowserHistoryConfig implements WebMvcConfigurer { 12 | 13 | @Override 14 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 15 | registry 16 | .addResourceHandler("swagger-ui.html") 17 | .addResourceLocations("classpath:/META-INF/resources/"); 18 | 19 | registry 20 | .addResourceHandler("/webjars/**") 21 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Configuration 8 | public class ApplicationConfig { 9 | 10 | @Configuration 11 | public static class BrowserHistoryConfig implements WebMvcConfigurer { 12 | 13 | @Override 14 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 15 | registry 16 | .addResourceHandler("swagger-ui.html") 17 | .addResourceLocations("classpath:/META-INF/resources/"); 18 | 19 | registry 20 | .addResourceHandler("/webjars/**") 21 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/HELP.md: -------------------------------------------------------------------------------- 1 | # Read Me First 2 | The following was discovered as part of building this project: 3 | 4 | * The original package name 'com.mailshine.spring-boot-standalone-activemq' is invalid and this project uses 'com.mailshine.springbootstandaloneactivemq' instead. 5 | 6 | # Getting Started 7 | 8 | ### Reference Documentation 9 | For further reference, please consider the following sections: 10 | 11 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) 12 | * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/maven-plugin/) 13 | * [Spring for Apache ActiveMQ 5](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/reference/htmlsingle/#boot-features-activemq) 14 | 15 | ### Guides 16 | The following guides illustrate how to use some features concretely: 17 | 18 | * [Java Message Service API via Apache ActiveMQ Classic.](https://spring.io/guides/gs/messaging-jms/) 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.controller; 2 | 3 | import com.mailshine.rabbitmq.model.Student; 4 | import com.mailshine.rabbitmq.service.RabbitMQService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @Slf4j 13 | public class MessageController { 14 | 15 | @Autowired 16 | RabbitMQService rabbitMQService; 17 | 18 | @PostMapping(value = "/api/send/student/info") 19 | public String sendStudentData(@RequestBody Student student){ 20 | log.info("Attempting send message to RabbitMQService"); 21 | 22 | rabbitMQService.sendMessage(student); 23 | return "Sent Message"; 24 | } 25 | } -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/main/java/com/mailshine/springboot/aop/aspectj/controller/Employee.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.aop.aspectj.controller; 2 | 3 | import com.mailshine.springboot.aop.aspectj.advise.TrackExecutionTime; 4 | import com.mailshine.springboot.aop.aspectj.service.EmployeeService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | @RestController 11 | @Slf4j 12 | @RequestMapping("/api") 13 | public class Employee { 14 | 15 | @Autowired 16 | private EmployeeService employeeService; 17 | 18 | @GetMapping(value = "/get/employee/name/{id}") 19 | @TrackExecutionTime 20 | public String getEmployeeName(@PathVariable String id){ 21 | if (StringUtils.isBlank(id)){ 22 | return null; 23 | } 24 | return employeeService.getEmployeeNameFromId(id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | baseUrl: 'http://localhost:4200/', 20 | framework: 'jasmine', 21 | jasmineNodeOpts: { 22 | showColors: true, 23 | defaultTimeoutInterval: 30000, 24 | print: function() {} 25 | }, 26 | onPrepare() { 27 | require('ts-node').register({ 28 | project: require('path').join(__dirname, './tsconfig.json') 29 | }); 30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 31 | } 32 | }; -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/service/RabbitMQService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.service; 2 | 3 | 4 | import com.mailshine.rabbitmq.model.Student; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | @Slf4j 13 | public class RabbitMQService { 14 | 15 | @Autowired 16 | RabbitTemplate rabbitTemplate; 17 | 18 | @Value(("${exchange.name}")) 19 | private String exchangeName; 20 | 21 | @Value("${routing.key}") 22 | private String routngKey; 23 | 24 | public void sendMessage(Student student){ 25 | log.info("Starting: Send Message to RabbitMQ."); 26 | rabbitTemplate.convertAndSend(exchangeName, routngKey, student); 27 | log.info("Sent Message to RabbitMQ with payload: {}", student.toString()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/jms/JmsProducer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.jms; 2 | 3 | import com.mailshine.springbootstandaloneactivemq.model.Employee; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.jms.core.JmsTemplate; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | @Slf4j 12 | public class JmsProducer { 13 | 14 | @Autowired 15 | JmsTemplate jmsTemplate; 16 | 17 | @Value("${active-mq.topic}") 18 | private String topic; 19 | 20 | public void sendMessage(Employee message){ 21 | try{ 22 | log.info("Attempting Send message to Topic: "+ topic); 23 | jmsTemplate.convertAndSend(topic, message); 24 | } catch(Exception e){ 25 | log.error("Recieved Exception during send Message: ", e); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/controller/KafkaAvroController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.controller; 2 | 3 | 4 | import com.mailshine.springboot.kafka.avro.model.Student; 5 | import com.mailshine.springboot.kafka.avro.service.ProducerService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("/api") 15 | @Slf4j 16 | public class KafkaAvroController { 17 | 18 | @Autowired 19 | ProducerService producerService; 20 | 21 | @PostMapping(value = "/send/avro/student/info") 22 | public String kafkaMessage(@RequestBody Student message) { 23 | producerService.sendMessage(message); 24 | return "Success"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/HELP.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ### Reference Documentation 4 | For further reference, please consider the following sections: 5 | 6 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) 7 | * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/maven-plugin/) 8 | * [Spring Web](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications) 9 | * [Spring for RabbitMQ](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/reference/htmlsingle/#boot-features-amqp) 10 | 11 | ### Guides 12 | The following guides illustrate how to use some features concretely: 13 | 14 | * [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) 15 | * [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) 16 | * [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/) 17 | * [Messaging with RabbitMQ](https://spring.io/guides/gs/messaging-rabbitmq/) 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * The type Application config. 9 | */ 10 | @Configuration 11 | public class ApplicationConfig { 12 | 13 | /** 14 | * The type Browser history config. 15 | */ 16 | @Configuration 17 | public static class BrowserHistoryConfig implements WebMvcConfigurer{ 18 | 19 | @Override 20 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 21 | registry.addResourceHandler("swagger-ui.html") 22 | .addResourceLocations("classpath:/META-INF/resources/"); 23 | 24 | registry.addResourceHandler("/webjars/**") 25 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-mutation-sample/src/main/java/com/mailshine/springboot/mutation/controller/Employee.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.mutation.controller; 2 | 3 | import com.mailshine.springboot.mutation.service.EmployeeService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | @RestController 13 | @Slf4j 14 | @RequestMapping("/api") 15 | public class Employee { 16 | 17 | @Autowired 18 | private EmployeeService employeeService; 19 | 20 | @GetMapping(value = "/get/employee/name/{id}") 21 | public String getEmployeeName(@PathVariable String id){ 22 | if (StringUtils.isBlank(id)){ 23 | return null; 24 | } 25 | return employeeService.getEmployeeNameFromId(id); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/controller/ProduceMessageController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.controller; 2 | 3 | import com.mailshine.springbootstandaloneactivemq.jms.JmsProducer; 4 | import com.mailshine.springbootstandaloneactivemq.model.Employee; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @Slf4j 15 | public class ProduceMessageController { 16 | 17 | @Autowired 18 | JmsProducer jmsProducer; 19 | 20 | @PostMapping(value="/api/employee") 21 | public Employee sendMessage(@RequestBody Employee employee){ 22 | jmsProducer.sendMessage(employee); 23 | return employee; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/logging/RequestFilterMDC.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.logging; 2 | 3 | 4 | import com.mailshine.spring.hystrix.controller.EmployeeController; 5 | import org.slf4j.MDC; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.filter.OncePerRequestFilter; 9 | 10 | import javax.servlet.FilterChain; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | 16 | @Component 17 | 18 | public class RequestFilterMDC extends OncePerRequestFilter { 19 | 20 | @Override 21 | protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { 22 | MDC.clear(); 23 | MDC.put("customMDCTradeId", "customMDCTradeId"); 24 | filterChain.doFilter(httpServletRequest, httpServletResponse); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-microservice/src/main/java/com/mailshine/springboot/microservices/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.microservices.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * The type Application config. 9 | */ 10 | @Configuration 11 | public class ApplicationConfig { 12 | 13 | /** 14 | * The type Browser history config. 15 | */ 16 | @Configuration 17 | public static class BrowserHistoryConfig implements WebMvcConfigurer{ 18 | 19 | @Override 20 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 21 | registry.addResourceHandler("swagger-ui.html") 22 | .addResourceLocations("classpath:/META-INF/resources/"); 23 | 24 | registry.addResourceHandler("/webjars/**") 25 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * The type Application config. 9 | */ 10 | @Configuration 11 | public class ApplicationConfig { 12 | 13 | /** 14 | * The type Browser history config. 15 | */ 16 | @Configuration 17 | public static class BrowserHistoryConfig implements WebMvcConfigurer{ 18 | 19 | @Override 20 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 21 | registry.addResourceHandler("swagger-ui.html") 22 | .addResourceLocations("classpath:/META-INF/resources/"); 23 | 24 | registry.addResourceHandler("/webjars/**") 25 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-message-consumer/src/main/java/com/mailshine/message/consumer/handling/consumer/Listener.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.message.consumer.handling.consumer; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.jms.JMSException; 8 | import javax.jms.Message; 9 | import javax.jms.MessageListener; 10 | import javax.jms.TextMessage; 11 | 12 | @Slf4j 13 | @Component 14 | public class Listener implements MessageListener { 15 | 16 | @Autowired 17 | MessageRouter router; 18 | 19 | @Override 20 | public void onMessage(Message message) { 21 | 22 | Object payload = null; 23 | try { 24 | payload = ((TextMessage) message).getText(); 25 | 26 | if (true) { 27 | router.accept(payload); 28 | } else { 29 | log.info("Message is ignore as it doesnt match Filter criteria"); 30 | } 31 | } catch (JMSException e) { 32 | log.error("Error Processing Message " + e.toString()); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/config/KafkaTopicConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.config; 2 | 3 | import org.apache.kafka.clients.admin.AdminClientConfig; 4 | import org.apache.kafka.clients.admin.NewTopic; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.kafka.core.KafkaAdmin; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Configuration 14 | public class KafkaTopicConfig { 15 | 16 | @Value(value = "${kafka.bootstrap.address}") 17 | private String bootstrapAddress; 18 | 19 | @Value(value = "${kafka.topic.name}") 20 | private String topicName; 21 | 22 | @Bean 23 | public KafkaAdmin kafkaAdmin() { 24 | Map configs = new HashMap<>(); 25 | configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); 26 | return new KafkaAdmin(configs); 27 | } 28 | 29 | @Bean 30 | public NewTopic topic1() { 31 | return new NewTopic(topicName, 1, (short) 1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/config/KafkaTopicConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.config; 2 | 3 | import org.apache.kafka.clients.admin.AdminClientConfig; 4 | import org.apache.kafka.clients.admin.NewTopic; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.kafka.core.KafkaAdmin; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Configuration 14 | public class KafkaTopicConfig { 15 | 16 | @Value(value = "${kafka.bootstrap.address}") 17 | private String bootstrapAddress; 18 | 19 | @Value(value = "${kafka.topic.name}") 20 | private String topicName; 21 | 22 | @Bean 23 | public KafkaAdmin kafkaAdmin() { 24 | Map configs = new HashMap<>(); 25 | configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); 26 | return new KafkaAdmin(configs); 27 | } 28 | 29 | @Bean 30 | public NewTopic topic1() { 31 | return new NewTopic(topicName, 1, (short) 1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/README.md: -------------------------------------------------------------------------------- 1 | # SpringBootWebfluxWeb 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.4. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | @Configuration 13 | @EnableSwagger2 14 | public class SwaggerConfig { 15 | 16 | @Bean 17 | public Docket api() { 18 | return new Docket(DocumentationType.SWAGGER_2) 19 | .select() 20 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.springboot.kafka.controllers")) 21 | .paths(PathSelectors.any()) 22 | .build() 23 | .apiInfo(apiInfo()); 24 | } 25 | 26 | private ApiInfo apiInfo() { 27 | return new ApiInfo( 28 | "Demo SpringBoot", "This Api is for demo purpose", null, null, null, null, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/spring-boot-webflux-web'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | @Configuration 13 | @EnableSwagger2 14 | public class SwaggerConfig { 15 | 16 | @Bean 17 | public Docket api() { 18 | return new Docket(DocumentationType.SWAGGER_2) 19 | .select() 20 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.spring.hystrix.controller")) 21 | .paths(PathSelectors.any()) 22 | .build() 23 | .apiInfo(apiInfo()); 24 | } 25 | 26 | private ApiInfo apiInfo() { 27 | return new ApiInfo( 28 | "Demo SpringBoot Hystrix", "This Api is for demo purpose", null, null, null, null, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | @Configuration 13 | @EnableSwagger2 14 | public class SwaggerConfig { 15 | 16 | @Bean 17 | public Docket api() { 18 | return new Docket(DocumentationType.SWAGGER_2) 19 | .select() 20 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.springboot.kafka.avro.controller")) 21 | .paths(PathSelectors.any()) 22 | .build() 23 | .apiInfo(apiInfo()); 24 | } 25 | 26 | private ApiInfo apiInfo() { 27 | return new ApiInfo( 28 | "Demo SpringBoot", "This Api is for demo purpose", null, null, null, null, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-resilience4j/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.3.0.RELEASE 10 | 11 | 12 | com.mailshine.springboot.resilience4j 13 | spring-boot-resilience4j 14 | 1.0-SNAPSHOT 15 | 16 | 17 | 1.8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | io.github.resilience4j 26 | resilience4j-circuitbreaker 27 | 1.7.1 28 | 29 | 30 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/jms/JmsConsumer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.jms; 2 | 3 | import com.mailshine.springbootstandaloneactivemq.model.Employee; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.jms.annotation.JmsListener; 8 | import org.springframework.jms.core.JmsTemplate; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.jms.Message; 12 | import javax.jms.MessageListener; 13 | import javax.jms.ObjectMessage; 14 | 15 | @Component 16 | @Slf4j 17 | public class JmsConsumer implements MessageListener { 18 | 19 | 20 | @Override 21 | @JmsListener(destination = "${active-mq.topic}") 22 | public void onMessage(Message message) { 23 | try{ 24 | ObjectMessage objectMessage = (ObjectMessage)message; 25 | Employee employee = (Employee)objectMessage.getObject(); 26 | //do additional processing 27 | log.info("Received Message from Topic: "+ employee.toString()); 28 | } catch(Exception e) { 29 | log.error("Received Exception while processing message: "+ e); 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-jms-activemq/src/main/java/com/mailshine/demo/jms/activemq/config/MQListenerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.demo.jms.activemq.config; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.activemq.ActiveMQConnectionFactory; 6 | import org.checkerframework.checker.units.qual.A; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.jms.config.DefaultJmsListenerContainerFactory; 10 | 11 | @Configuration 12 | @Slf4j 13 | public class MQListenerConfig { 14 | 15 | @Bean 16 | public ActiveMQConnectionFactory consumerActiveMQConnectionFactory(){ 17 | ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); 18 | activeMQConnectionFactory.setBrokerURL(""); 19 | return activeMQConnectionFactory; 20 | } 21 | 22 | @Bean 23 | public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(){ 24 | 25 | DefaultJmsListenerContainerFactory defaultJmsListenerContainerFactory = new DefaultJmsListenerContainerFactory(); 26 | defaultJmsListenerContainerFactory.setConnectionFactory(consumerActiveMQConnectionFactory()); 27 | defaultJmsListenerContainerFactory.setPubSubDomain(true); 28 | return defaultJmsListenerContainerFactory; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | })); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'spring-boot-com.mailshine.springboot.webflux-web'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('spring-boot-com.mailshine.springboot.webflux-web'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('spring-boot-com.mailshine.springboot.webflux-web app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/src/main/java/com/mailshine/swagger/yaml/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.swagger.yaml.config; 2 | 3 | import com.mailshine.swagger.yaml.model.Course; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | /** 10 | * The type Application config. 11 | */ 12 | @Configuration 13 | public class ApplicationConfig { 14 | 15 | /** 16 | * The type Browser history config. 17 | */ 18 | @Configuration 19 | public static class BrowserHistoryConfig implements WebMvcConfigurer { 20 | 21 | @Override 22 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 23 | registry.addResourceHandler("swagger-ui.html") 24 | .addResourceLocations("classpath:/META-INF/resources/"); 25 | 26 | registry.addResourceHandler("/webjars/**") 27 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 28 | } 29 | } 30 | 31 | @Bean 32 | public Course demoCourse() { 33 | Course course = new Course(); 34 | course.setCourseName("CSDemo550"); 35 | course.setCourseId("10"); 36 | return course; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | /** 13 | * The type Swagger config. 14 | */ 15 | @Configuration 16 | @EnableSwagger2 17 | public class SwaggerConfig { 18 | 19 | /** 20 | * Api docket. 21 | * 22 | * @return the docket 23 | */ 24 | @Bean 25 | public Docket api(){ 26 | return new Docket(DocumentationType.SWAGGER_2) 27 | .select() 28 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.rabbitmq.controller")) 29 | .paths(PathSelectors.any()) 30 | .build().apiInfo(apiInfo()); 31 | 32 | 33 | } 34 | 35 | private ApiInfo apiInfo() { 36 | return new ApiInfo( 37 | "Demo SpringBoot", 38 | "This Api is for demo purpose", 39 | null, 40 | null, 41 | null, null , null 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/config/KafkaProducerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.config; 2 | 3 | import org.apache.kafka.clients.producer.ProducerConfig; 4 | import org.apache.kafka.common.serialization.StringSerializer; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; 9 | import org.springframework.kafka.core.KafkaTemplate; 10 | import org.springframework.kafka.core.ProducerFactory; 11 | 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @Configuration 16 | public class KafkaProducerConfig { 17 | 18 | @Value(value = "${kafka.bootstrap.address}") 19 | private String bootstrapAddress; 20 | 21 | @Bean 22 | public ProducerFactory producerFactory() { 23 | Map configProps = new HashMap<>(); 24 | configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); 25 | configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 26 | configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 27 | return new DefaultKafkaProducerFactory<>(configProps); 28 | } 29 | 30 | @Bean 31 | public KafkaTemplate kafkaTemplate() { 32 | return new KafkaTemplate<>(producerFactory()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/src/main/java/com/mailshine/swagger/yaml/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.swagger.yaml.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | /** 13 | * The type Swagger config. 14 | */ 15 | @Configuration 16 | @EnableSwagger2 17 | public class SwaggerConfig { 18 | 19 | /** 20 | * Api docket. 21 | * 22 | * @return the docket 23 | */ 24 | @Bean 25 | public Docket api() { 26 | return new Docket(DocumentationType.SWAGGER_2) 27 | .select() 28 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.swagger.yaml.controllers")) 29 | .paths(PathSelectors.any()) 30 | .build().apiInfo(apiInfo()); 31 | 32 | 33 | } 34 | 35 | private ApiInfo apiInfo() { 36 | return new ApiInfo( 37 | "Demo SpringBoot", 38 | "This Api is for demo purpose", 39 | null, 40 | null, 41 | null, null, null 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-microservice/src/main/java/com/mailshine/springboot/microservices/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.microservices.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | /** 13 | * The type Swagger config. 14 | */ 15 | @Configuration 16 | @EnableSwagger2 17 | public class SwaggerConfig { 18 | 19 | /** 20 | * Api docket. 21 | * 22 | * @return the docket 23 | */ 24 | @Bean 25 | public Docket api(){ 26 | return new Docket(DocumentationType.SWAGGER_2) 27 | .select() 28 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.springboot.microservices")) 29 | .paths(PathSelectors.any()) 30 | .build().apiInfo(apiInfo()); 31 | 32 | 33 | } 34 | 35 | private ApiInfo apiInfo() { 36 | return new ApiInfo( 37 | "Demo SpringBoot", 38 | "This Api is for demo purpose", 39 | null, 40 | null, 41 | null, null , null 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.service.ApiInfo; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | /** 13 | * The type Swagger config. 14 | */ 15 | @Configuration 16 | @EnableSwagger2 17 | public class SwaggerConfig { 18 | 19 | /** 20 | * Api docket. 21 | * 22 | * @return the docket 23 | */ 24 | @Bean 25 | public Docket api(){ 26 | return new Docket(DocumentationType.SWAGGER_2) 27 | .select() 28 | .apis(RequestHandlerSelectors.basePackage("com.mailshine.springbootstandaloneactivemq.controller")) 29 | .paths(PathSelectors.any()) 30 | .build().apiInfo(apiInfo()); 31 | 32 | 33 | } 34 | 35 | private ApiInfo apiInfo() { 36 | return new ApiInfo( 37 | "Demo SpringBoot", 38 | "This Api is for demo purpose", 39 | null, 40 | null, 41 | null, null , null 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spring-boot-webflux-web", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~9.0.3", 15 | "@angular/common": "~9.0.3", 16 | "@angular/compiler": "~9.0.3", 17 | "@angular/core": "~11.0.5", 18 | "@angular/forms": "~9.0.3", 19 | "@angular/platform-browser": "~9.0.3", 20 | "@angular/platform-browser-dynamic": "~9.0.3", 21 | "@angular/router": "~9.0.3", 22 | "rxjs": "~6.5.4", 23 | "tslib": "^1.10.0", 24 | "zone.js": "~0.10.2" 25 | }, 26 | "devDependencies": { 27 | "@angular-devkit/build-angular": "~20.1.4", 28 | "@angular/cli": "~20.1.4", 29 | "@angular/compiler-cli": "~9.0.3", 30 | "@angular/language-service": "~9.0.3", 31 | "@types/node": "^12.11.1", 32 | "@types/jasmine": "~3.5.0", 33 | "@types/jasminewd2": "~2.0.3", 34 | "codelyzer": "^5.1.2", 35 | "jasmine-core": "~3.5.0", 36 | "jasmine-spec-reporter": "~4.2.1", 37 | "karma": "~6.3.16", 38 | "karma-chrome-launcher": "~3.1.0", 39 | "karma-coverage-istanbul-reporter": "~2.1.0", 40 | "karma-jasmine": "~2.0.1", 41 | "karma-jasmine-html-reporter": "^1.4.2", 42 | "protractor": "~6.0.0", 43 | "ts-node": "~8.3.0", 44 | "tslint": "~5.18.0", 45 | "typescript": "~3.7.5" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/service/ProducerService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.kafka.core.KafkaTemplate; 7 | import org.springframework.kafka.support.SendResult; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.util.concurrent.ListenableFuture; 10 | import org.springframework.util.concurrent.ListenableFutureCallback; 11 | 12 | @Service 13 | @Slf4j 14 | public class ProducerService { 15 | 16 | @Value("${kafka.topic.name}") 17 | private String topicName; 18 | 19 | @Autowired 20 | private KafkaTemplate kafkaTemplate; 21 | 22 | public void sendMessage(String message){ 23 | 24 | ListenableFuture> future = 25 | kafkaTemplate.send(topicName, message); 26 | 27 | future.addCallback(new ListenableFutureCallback>() { 28 | 29 | @Override 30 | public void onSuccess(SendResult result) { 31 | log.info("Sent message=[{}] with offset=[{}]" , message ,result.getRecordMetadata().offset()); 32 | } 33 | @Override 34 | public void onFailure(Throwable ex) { 35 | log.info("Unable to send message=[{}] due to : {}",message,ex.getMessage()); 36 | } 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/serializer/AvroDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.serializer; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.avro.generic.GenericRecord; 5 | import org.apache.avro.io.*; 6 | import org.apache.avro.specific.SpecificDatumReader; 7 | import org.apache.avro.specific.SpecificRecordBase; 8 | import org.apache.kafka.common.serialization.Deserializer; 9 | 10 | import java.util.Map; 11 | 12 | @Slf4j 13 | public class AvroDeserializer implements Deserializer { 14 | 15 | protected final Class targetType; 16 | 17 | public AvroDeserializer(Class targetType) { 18 | this.targetType = targetType; 19 | } 20 | 21 | @Override 22 | public void configure(Map configs, boolean isKey) { 23 | // do nothing 24 | } 25 | 26 | @Override 27 | public T deserialize(String topic, byte[] bytes) { 28 | T returnObject = null; 29 | 30 | try { 31 | 32 | if (bytes != null) { 33 | DatumReader datumReader = new SpecificDatumReader<>(targetType.newInstance().getSchema()); 34 | Decoder decoder = DecoderFactory.get().binaryDecoder(bytes, null); 35 | returnObject = (T) datumReader.read(null, decoder); 36 | log.info("deserialized data='{}'", returnObject.toString()); 37 | } 38 | } catch (Exception e) { 39 | log.error("Unable to Deserialize bytes[] ", e); 40 | } 41 | 42 | return returnObject; 43 | } 44 | 45 | @Override 46 | public void close() { 47 | // do nothing 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/config/KafkaProducerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.config; 2 | 3 | import com.mailshine.springboot.kafka.avro.model.Student; 4 | import com.mailshine.springboot.kafka.avro.serializer.AvroSerializer; 5 | import org.apache.kafka.clients.producer.ProducerConfig; 6 | import org.apache.kafka.common.serialization.StringSerializer; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; 11 | import org.springframework.kafka.core.KafkaTemplate; 12 | import org.springframework.kafka.core.ProducerFactory; 13 | 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | @Configuration 18 | public class KafkaProducerConfig { 19 | 20 | @Value(value = "${kafka.bootstrap.address}") 21 | private String bootstrapAddress; 22 | 23 | @Bean 24 | public ProducerFactory producerFactory() { 25 | Map configProps = new HashMap<>(); 26 | configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); 27 | configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 28 | configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, AvroSerializer.class); 29 | return new DefaultKafkaProducerFactory<>(configProps); 30 | } 31 | 32 | @Bean 33 | public KafkaTemplate kafkaTemplate() { 34 | return new KafkaTemplate<>(producerFactory()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /tmp 4 | /out-tsc 5 | 6 | # dependencies 7 | /node_modules 8 | 9 | # IDEs and editors 10 | /.idea 11 | .project 12 | .classpath 13 | .c9/ 14 | *.launch 15 | .settings/ 16 | *.sublime-workspace 17 | 18 | # IDE - VSCode 19 | .vscode/* 20 | !.vscode/settings.json 21 | !.vscode/tasks.json 22 | !.vscode/launch.json 23 | !.vscode/extensions.json 24 | 25 | # misc 26 | /.sass-cache 27 | /connect.lock 28 | /coverage 29 | /libpeerconnection.log 30 | npm-debug.log 31 | yarn-error.log 32 | testem.log 33 | /typings 34 | 35 | # System Files 36 | .DS_Store 37 | Thumbs.db 38 | 39 | # Compiled class file 40 | *.class 41 | 42 | # Log file 43 | *.log 44 | 45 | # BlueJ files 46 | *.ctxt 47 | 48 | # Mobile Tools for Java (J2ME) 49 | .mtj.tmp/ 50 | 51 | # Package Files # 52 | *.jar 53 | *.war 54 | *.ear 55 | *.tar.gz 56 | *.rar 57 | *.cmd 58 | *.classpath 59 | *.settings 60 | *.project 61 | *.mvn 62 | mvnw 63 | target 64 | *.DS_Store 65 | 66 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 67 | hs_err_pid* 68 | 69 | # Compiled class file 70 | *.class 71 | 72 | # Log file 73 | *.log 74 | 75 | # BlueJ files 76 | *.ctxt 77 | 78 | # Mobile Tools for Java (J2ME) 79 | .mtj.tmp/ 80 | 81 | # Package Files # 82 | *.jar 83 | *.war 84 | *.ear 85 | *.zip 86 | *.tar.gz 87 | *.rar 88 | *.cmd 89 | *.classpath 90 | *.settings 91 | *.project 92 | *.mvn 93 | mvnw 94 | target 95 | node_modules 96 | *.DS_Store 97 | 98 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 99 | hs_err_pid* 100 | bin -------------------------------------------------------------------------------- /spring-boot-microservice/src/main/java/com/mailshine/springboot/microservices/controllers/SimpleController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.microservices.controllers; 2 | 3 | import com.mailshine.springboot.microservices.models.Employee; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 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 | import java.util.HashSet; 11 | import java.util.Set; 12 | 13 | /** 14 | * The type Simple controller. 15 | */ 16 | @RestController 17 | @RequestMapping("/api") 18 | public class SimpleController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(SimpleController.class); 21 | 22 | /** 23 | * Say hello string. 24 | * 25 | * @return the string 26 | */ 27 | @GetMapping (value = "/get/hello/message") 28 | public String sayHello(){ 29 | return "Hello There!"; 30 | } 31 | 32 | /** 33 | * Employee set set. 34 | * 35 | * @return the set 36 | */ 37 | @GetMapping (value = "/get/employee/list") 38 | public Set employeeSet(){ 39 | Set employees = new HashSet<>(); 40 | Employee employee = new Employee(); 41 | employee.setEmployeeId("1"); 42 | employee.setEmployeeFirstName("John"); 43 | employee.setEmployeeLastName("Smith"); 44 | employee.setEmployeeFullName("John Smith"); 45 | employees.add(employee); 46 | logger.info("Employee Details returned is : " + employee.toString()); 47 | return employees; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/service/ProducerService.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.service; 2 | 3 | import com.mailshine.springboot.kafka.avro.model.Student; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.kafka.core.KafkaTemplate; 8 | import org.springframework.kafka.support.SendResult; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.util.concurrent.ListenableFuture; 11 | import org.springframework.util.concurrent.ListenableFutureCallback; 12 | 13 | @Service 14 | @Slf4j 15 | public class ProducerService { 16 | 17 | @Value("${kafka.topic.name}") 18 | private String topicName; 19 | 20 | @Autowired 21 | private KafkaTemplate kafkaTemplate; 22 | 23 | public void sendMessage(Student message) { 24 | ListenableFuture> future = kafkaTemplate.send(topicName, message); 25 | future.addCallback( 26 | new ListenableFutureCallback>() { 27 | @Override 28 | public void onSuccess(SendResult result) { 29 | log.info( 30 | "Sent message=[{}] with offset=[{}]", message, result.getRecordMetadata().offset()); 31 | } 32 | 33 | @Override 34 | public void onFailure(Throwable ex) { 35 | log.info("Unable to send message=[{}] due to : {}", message, ex.getMessage()); 36 | } 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/src/main/java/com/mailshine/springbootstandaloneactivemq/config/ActiveMQConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springbootstandaloneactivemq.config; 2 | 3 | import org.apache.activemq.ActiveMQConnectionFactory; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.jms.config.DefaultJmsListenerContainerFactory; 8 | import org.springframework.jms.core.JmsTemplate; 9 | 10 | import javax.jms.ConnectionFactory; 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | 14 | @Configuration 15 | public class ActiveMQConfig { 16 | 17 | @Value("${active-mq.broker-url}") 18 | private String brokerUrl; 19 | 20 | @Bean 21 | public ConnectionFactory connectionFactory(){ 22 | ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); 23 | activeMQConnectionFactory.setBrokerURL(brokerUrl); 24 | activeMQConnectionFactory.setTrustedPackages(Arrays.asList("com.mailshine.springbootstandaloneactivemq")); 25 | return activeMQConnectionFactory; 26 | } 27 | 28 | @Bean 29 | public JmsTemplate jmsTemplate(){ 30 | JmsTemplate jmsTemplate = new JmsTemplate(); 31 | jmsTemplate.setConnectionFactory(connectionFactory()); 32 | jmsTemplate.setPubSubDomain(true); // enable for Pub Sub to topic. Not Required for Queue. 33 | return jmsTemplate; 34 | } 35 | 36 | @Bean 37 | public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(){ 38 | DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); 39 | factory.setConnectionFactory(connectionFactory()); 40 | factory.setPubSubDomain(true); 41 | return factory; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/serializer/AvroSerializer.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.serializer; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.avro.generic.GenericDatumWriter; 5 | import org.apache.avro.generic.GenericRecord; 6 | import org.apache.avro.io.BinaryEncoder; 7 | import org.apache.avro.io.DatumWriter; 8 | import org.apache.avro.io.EncoderFactory; 9 | import org.apache.avro.specific.SpecificRecordBase; 10 | import org.apache.kafka.common.serialization.Serializer; 11 | 12 | import javax.xml.bind.DatatypeConverter; 13 | import java.io.ByteArrayOutputStream; 14 | import java.io.IOException; 15 | import java.util.Map; 16 | 17 | @Slf4j 18 | public class AvroSerializer implements Serializer { 19 | 20 | @Override 21 | public void configure(Map configs, boolean isKey) { 22 | // do nothing 23 | } 24 | 25 | @Override 26 | public byte[] serialize(String topic, T payload) { 27 | byte[] bytes = null; 28 | try { 29 | if (payload != null) { 30 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 31 | BinaryEncoder binaryEncoder = EncoderFactory.get().binaryEncoder(byteArrayOutputStream, null); 32 | DatumWriter datumWriter = new GenericDatumWriter<>(payload.getSchema()); 33 | datumWriter.write(payload, binaryEncoder); 34 | binaryEncoder.flush(); 35 | byteArrayOutputStream.close(); 36 | bytes = byteArrayOutputStream.toByteArray(); 37 | log.info("serialized payload='{}'", DatatypeConverter.printHexBinary(bytes)); 38 | } 39 | } catch (Exception e) { 40 | log.error("Unable to serialize payload ", e); 41 | } 42 | return bytes; 43 | } 44 | 45 | @Override 46 | public void close() { 47 | // do nothing 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/mailshine/springboot/kafka/config/KafkaConsumerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.config; 2 | 3 | import org.apache.kafka.clients.consumer.ConsumerConfig; 4 | import org.apache.kafka.common.serialization.StringDeserializer; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.kafka.annotation.EnableKafka; 9 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; 10 | import org.springframework.kafka.core.ConsumerFactory; 11 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | @EnableKafka 17 | @Configuration 18 | public class KafkaConsumerConfig { 19 | 20 | @Value(value = "${kafka.bootstrap.address}") 21 | private String bootstrapAddress; 22 | 23 | @Value(value = "${kafka.consumer}") 24 | private String groupId; 25 | 26 | @Bean 27 | public ConsumerFactory consumerFactory() { 28 | Map props = new HashMap<>(); 29 | props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); 30 | props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); 31 | props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 32 | props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 33 | return new DefaultKafkaConsumerFactory<>(props); 34 | } 35 | 36 | @Bean 37 | public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() { 38 | 39 | ConcurrentKafkaListenerContainerFactory factory = 40 | new ConcurrentKafkaListenerContainerFactory<>(); 41 | factory.setConsumerFactory(consumerFactory()); 42 | return factory; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/config/KafkaConsumerConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.kafka.avro.config; 2 | 3 | import com.mailshine.springboot.kafka.avro.model.Student; 4 | import com.mailshine.springboot.kafka.avro.serializer.AvroDeserializer; 5 | import org.apache.kafka.clients.consumer.ConsumerConfig; 6 | import org.apache.kafka.common.serialization.StringDeserializer; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.kafka.annotation.EnableKafka; 11 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; 12 | import org.springframework.kafka.core.ConsumerFactory; 13 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | @EnableKafka 19 | @Configuration 20 | public class KafkaConsumerConfig { 21 | 22 | @Value(value = "${kafka.bootstrap.address}") 23 | private String bootstrapAddress; 24 | 25 | @Value(value = "${kafka.consumer}") 26 | private String groupId; 27 | 28 | @Bean 29 | public ConsumerFactory consumerFactory() { 30 | Map props = new HashMap<>(); 31 | props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); 32 | props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); 33 | props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 34 | props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, AvroDeserializer.class); 35 | return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new AvroDeserializer<>(Student.class)); 36 | } 37 | 38 | @Bean 39 | public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() { 40 | 41 | ConcurrentKafkaListenerContainerFactory factory = 42 | new ConcurrentKafkaListenerContainerFactory<>(); 43 | factory.setConsumerFactory(consumerFactory()); 44 | return factory; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/src/main/java/com/mailshine/springboot/aop/aspectj/advise/ExecutionTimeAdvice.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.springboot.aop.aspectj.advise; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.aspectj.lang.JoinPoint; 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.annotation.After; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Before; 10 | import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Aspect 14 | @Component 15 | @Slf4j 16 | @ConditionalOnExpression("${aspect.enabled:true}") 17 | public class ExecutionTimeAdvice { 18 | 19 | @Around("@annotation(com.mailshine.springboot.aop.aspectj.advise.TrackExecutionTime)") 20 | public Object executionTime(ProceedingJoinPoint point) throws Throwable { 21 | long startTime = System.currentTimeMillis(); 22 | Object object = point.proceed(); 23 | long endtime = System.currentTimeMillis(); 24 | log.info("Class Name: "+ point.getSignature().getDeclaringTypeName() +". Method Name: "+ point.getSignature().getName() + ". Time taken for Execution is : " + (endtime-startTime) +"ms"); 25 | return object; 26 | } 27 | 28 | /* @Before("execution(* com.mailshine.springboot.aop.aspectj.service.EmployeeService.*(..))") 29 | public void executionTimeBefore(JoinPoint point) throws Throwable { 30 | long startTime = System.currentTimeMillis(); 31 | //long endtime = System.currentTimeMillis(); 32 | log.info("Method Name: "+ point.getSignature().getName() + ". Time taken for Execution is : " + (startTime) +"ms"); 33 | } 34 | 35 | @After("execution(* com.mailshine.springboot.aop.aspectj.service.EmployeeService.*(..))") 36 | public void executionTimeAfter(JoinPoint point) throws Throwable { 37 | // long startTime = System.currentTimeMillis(); 38 | long endtime = System.currentTimeMillis(); 39 | log.info("Method Name: "+ point.getSignature().getName() + ". Time taken for Execution is : " + (endtime) +"ms"); 40 | }*/ 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-standalone-activemq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.7.RELEASE 9 | 10 | 11 | com.mailshine 12 | spring-boot-standalone-activemq 13 | 0.0.1-SNAPSHOT 14 | spring-boot-standalone-activemq 15 | Producer and Consumer against standalone activeMQ 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-activemq 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | org.projectlombok 32 | lombok 33 | true 34 | 35 | 36 | io.springfox 37 | springfox-swagger2 38 | 2.9.2 39 | 40 | 41 | io.springfox 42 | springfox-swagger-ui 43 | 2.9.2 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-test 48 | test 49 | 50 | 51 | org.junit.vintage 52 | junit-vintage-engine 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "array-type": false, 5 | "arrow-parens": false, 6 | "deprecation": { 7 | "severity": "warning" 8 | }, 9 | "component-class-suffix": true, 10 | "contextual-lifecycle": true, 11 | "directive-class-suffix": true, 12 | "directive-selector": [ 13 | true, 14 | "attribute", 15 | "app", 16 | "camelCase" 17 | ], 18 | "component-selector": [ 19 | true, 20 | "element", 21 | "app", 22 | "kebab-case" 23 | ], 24 | "import-blacklist": [ 25 | true, 26 | "rxjs/Rx" 27 | ], 28 | "interface-name": false, 29 | "max-classes-per-file": false, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-consecutive-blank-lines": false, 47 | "no-console": [ 48 | true, 49 | "debug", 50 | "info", 51 | "time", 52 | "timeEnd", 53 | "trace" 54 | ], 55 | "no-empty": false, 56 | "no-inferrable-types": [ 57 | true, 58 | "ignore-params" 59 | ], 60 | "no-non-null-assertion": true, 61 | "no-redundant-jsdoc": true, 62 | "no-switch-case-fall-through": true, 63 | "no-var-requires": false, 64 | "object-literal-key-quotes": [ 65 | true, 66 | "as-needed" 67 | ], 68 | "object-literal-sort-keys": false, 69 | "ordered-imports": false, 70 | "quotemark": [ 71 | true, 72 | "single" 73 | ], 74 | "trailing-comma": false, 75 | "no-conflicting-lifecycle": true, 76 | "no-host-metadata-property": true, 77 | "no-input-rename": true, 78 | "no-inputs-metadata-property": true, 79 | "no-output-native": true, 80 | "no-output-on-prefix": true, 81 | "no-output-rename": true, 82 | "no-outputs-metadata-property": true, 83 | "template-banana-in-box": true, 84 | "template-no-negated-async": true, 85 | "use-lifecycle-interface": true, 86 | "use-pipe-transform-interface": true 87 | }, 88 | "rulesDirectory": [ 89 | "codelyzer" 90 | ] 91 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.7.RELEASE 9 | 10 | 11 | com.mailshine.rabbitmq 12 | spring-boot-rabbitmq 13 | 0.0.1-SNAPSHOT 14 | spring-boot-rabbitmq 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-amqp 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.projectlombok 33 | lombok 34 | true 35 | 36 | 37 | io.springfox 38 | springfox-swagger2 39 | 2.9.2 40 | 41 | 42 | io.springfox 43 | springfox-swagger-ui 44 | 2.9.2 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-test 49 | test 50 | 51 | 52 | org.junit.vintage 53 | junit-vintage-engine 54 | 55 | 56 | 57 | 58 | org.springframework.amqp 59 | spring-rabbit-test 60 | test 61 | 62 | 63 | 64 | 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-maven-plugin 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/mailshine/rabbitmq/config/RabbitMQConfig.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.rabbitmq.config; 2 | 3 | import com.mailshine.rabbitmq.mq.RabbitMQListener; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.amqp.core.Binding; 6 | import org.springframework.amqp.core.BindingBuilder; 7 | import org.springframework.amqp.core.DirectExchange; 8 | import org.springframework.amqp.core.Queue; 9 | import org.springframework.amqp.rabbit.connection.ConnectionFactory; 10 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 11 | import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar; 12 | import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; 13 | import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; 14 | import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; 15 | import org.springframework.amqp.support.converter.MessageConverter; 16 | import org.springframework.beans.factory.annotation.Value; 17 | import org.springframework.context.annotation.Bean; 18 | import org.springframework.context.annotation.Configuration; 19 | import org.springframework.messaging.converter.MappingJackson2MessageConverter; 20 | import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; 21 | 22 | @Configuration 23 | @Slf4j 24 | public class RabbitMQConfig { 25 | 26 | @Value("${queue}") 27 | private String queueName; 28 | 29 | @Value(("${exchange.name}")) 30 | private String exchangeName; 31 | 32 | @Value("${routing.key}") 33 | private String routngKey; 34 | 35 | @Bean 36 | public Queue queue() { 37 | return new Queue(queueName, false); 38 | } 39 | 40 | @Bean 41 | public DirectExchange exchange(){ 42 | return new DirectExchange(exchangeName); 43 | } 44 | 45 | @Bean 46 | public Binding binding(Queue queue, DirectExchange exchange){ 47 | return BindingBuilder.bind(queue).to(exchange).with(routngKey); 48 | } 49 | 50 | @Bean 51 | public MessageConverter messageConverter(){ 52 | return new Jackson2JsonMessageConverter(); 53 | } 54 | 55 | @Bean 56 | public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory){ 57 | RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); 58 | rabbitTemplate.setMessageConverter(messageConverter()); 59 | return rabbitTemplate; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /spring-boot-message-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 2.3.0.RELEASE 11 | 12 | 13 | 14 | org.example 15 | spring-boot-message-consumer 16 | 1.0-SNAPSHOT 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-data-jpa 27 | 28 | 29 | io.springfox 30 | springfox-swagger2 31 | 2.9.2 32 | 33 | 34 | io.springfox 35 | springfox-swagger-ui 36 | 2.9.2 37 | 38 | 39 | 40 | org.projectlombok 41 | lombok 42 | true 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-test 47 | test 48 | 49 | 50 | org.junit.vintage 51 | junit-vintage-engine 52 | 53 | 54 | 55 | 56 | javax.jms 57 | javax.jms-api 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-maven-plugin 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /spring-boot-hystrix/src/main/java/com/mailshine/spring/hystrix/controller/EmployeeController.java: -------------------------------------------------------------------------------- 1 | package com.mailshine.spring.hystrix.controller; 2 | 3 | import com.mailshine.spring.hystrix.exception.EmployeeNotFoundException; 4 | import com.mailshine.spring.hystrix.service.EmployeeService; 5 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 6 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.beans.factory.annotation.Qualifier; 10 | import org.springframework.core.ParameterizedTypeReference; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | import org.springframework.web.client.RestTemplate; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | @RestController 22 | @Slf4j 23 | @RequestMapping("/api/sample/hystrix") 24 | public class EmployeeController { 25 | 26 | @Autowired 27 | @Qualifier(value = "hystrixRestTemplate") 28 | private RestTemplate hystrixRestTemplate; 29 | 30 | @Autowired 31 | EmployeeService employeeService; 32 | 33 | /** 34 | * @param id 35 | * @return employee name 36 | * To induce Failure/OpenCircuit and Hystrix FallBack plz reduce timeoutInMilliseconds to lower value. 37 | */ 38 | @GetMapping("/employee/name/{id}") 39 | @HystrixCommand(fallbackMethod = "getDataFallBack", commandProperties = { 40 | @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")}) 41 | public String getEmployeeName(@PathVariable String id) { 42 | ResponseEntity responseEntity = null; 43 | try { 44 | log.info("Processing getEmployeeName for Name: {}.", id); 45 | responseEntity = hystrixRestTemplate.getForEntity("http://localhost:8080/api/sample/hystrix/employee/by/id/" + id, String.class); 46 | return responseEntity.getBody(); 47 | } catch (Exception e) { 48 | throw new EmployeeNotFoundException("Test"); 49 | } 50 | } 51 | 52 | 53 | @GetMapping("/employee/by/id/{id}") 54 | public ResponseEntity getEmployeesNameById(@PathVariable String id) throws EmployeeNotFoundException { 55 | log.info("Processing getEmployeesNameById for ID: {}.", id); 56 | return ResponseEntity.ok(employeeService.getEmployees(id)); 57 | } 58 | 59 | public String getDataFallBack(String id) { 60 | return "Default Emp"; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-boot-kafka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.4.RELEASE 9 | 10 | 11 | net.mailshine.demo 12 | spring-boot-kafka 13 | 0.0.1-SNAPSHOT 14 | spring-boot-kafka 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | 29 | org.springframework.kafka 30 | spring-kafka 31 | 2.4.6.RELEASE 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | org.junit.vintage 41 | junit-vintage-engine 42 | 43 | 44 | 45 | 46 | 47 | org.projectlombok 48 | lombok 49 | 1.18.10 50 | provided 51 | 52 | 53 | 54 | io.springfox 55 | springfox-swagger2 56 | 2.9.2 57 | 58 | 59 | io.springfox 60 | springfox-swagger-ui 61 | 2.9.2 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /spring-boot-webflux/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | pom 7 | 8 | spring-boot-webflux-web 9 | spring-boot-webflux-rest 10 | spring-boot-webflux-app 11 | spring-boot-webflux-parent 12 | 13 | 14 | 15 | 16 | org.example 17 | spring-boot-webflux 18 | 1.0-SNAPSHOT 19 | 20 | 21 | 1.8 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-web 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-webflux 32 | 33 | 34 | junit 35 | junit 36 | 4.13.1 37 | test 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | org.junit.vintage 47 | junit-vintage-engine 48 | 49 | 50 | 51 | 52 | 53 | org.projectlombok 54 | lombok 55 | 1.18.10 56 | provided 57 | 58 | 59 | 60 | io.springfox 61 | springfox-swagger2 62 | 2.9.2 63 | 64 | 65 | io.springfox 66 | springfox-swagger-ui 67 | 2.9.2 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-maven-plugin 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /spring-boot-jms-activemq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | pom 7 | 8 | 9 | org.springframework.boot 10 | spring-boot-starter-parent 11 | 2.2.4.RELEASE 12 | 13 | 14 | 15 | com.mailshine.demo.jms 16 | spring-boot-jms-activemq 17 | 0.0.1-SNAPSHOT 18 | spring-boot-jms 19 | Demo project for Spring Boot 20 | 21 | 22 | 1.8 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-activemq 33 | 34 | 35 | 36 | 37 | org.apache.activemq 38 | activemq-broker 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-test 43 | test 44 | 45 | 46 | org.junit.vintage 47 | junit-vintage-engine 48 | 49 | 50 | 51 | 52 | 53 | org.projectlombok 54 | lombok 55 | 1.18.10 56 | provided 57 | 58 | 59 | 60 | io.springfox 61 | springfox-swagger2 62 | 2.9.2 63 | 64 | 65 | io.springfox 66 | springfox-swagger-ui 67 | 2.9.2 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /spring-boot-micrometer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | pom 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 2.2.4.RELEASE 11 | 12 | 13 | com.mailshine.springboot 14 | spring-boot-micrometer 15 | 0.0.1-SNAPSHOT 16 | spring-boot-aop-aspectj 17 | Demo project for Spring Boot 18 | 19 | 20 | 1.8 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-aop 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | org.junit.vintage 40 | junit-vintage-engine 41 | 42 | 43 | 44 | 45 | org.apache.commons 46 | commons-lang3 47 | 3.0 48 | 49 | 50 | org.projectlombok 51 | lombok 52 | 1.18.10 53 | provided 54 | 55 | 56 | 57 | io.springfox 58 | springfox-swagger2 59 | 2.9.2 60 | 61 | 62 | io.springfox 63 | springfox-swagger-ui 64 | 2.9.2 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /spring-boot-aop-aspectj/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | pom 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 2.2.4.RELEASE 11 | 12 | 13 | com.mailshine.springboot 14 | spring-boot-aop-aspectj 15 | 0.0.1-SNAPSHOT 16 | spring-boot-aop-aspectj 17 | Demo project for Spring Boot 18 | 19 | 20 | 1.8 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-aop 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | org.junit.vintage 40 | junit-vintage-engine 41 | 42 | 43 | 44 | 45 | org.apache.commons 46 | commons-lang3 47 | 3.0 48 | 49 | 50 | org.projectlombok 51 | lombok 52 | 1.18.10 53 | provided 54 | 55 | 56 | 57 | io.springfox 58 | springfox-swagger2 59 | 2.9.2 60 | 61 | 62 | io.springfox 63 | springfox-swagger-ui 64 | 2.9.2 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /spring-boot-mapstruct/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 2.3.0.RELEASE 11 | 12 | 13 | 14 | com.mailshine.springboot.mapstruct 15 | spring-boot-mapstruct 16 | 1.0-SNAPSHOT 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.mapstruct 29 | mapstruct-jdk8 30 | 1.3.1.Final 31 | 32 | 33 | org.mapstruct 34 | mapstruct-processor 35 | 1.3.1.Final 36 | provided 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-data-jpa 42 | 43 | 44 | io.springfox 45 | springfox-swagger2 46 | 2.9.2 47 | 48 | 49 | io.springfox 50 | springfox-swagger-ui 51 | 2.9.2 52 | 53 | 54 | 55 | org.projectlombok 56 | lombok 57 | true 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-test 62 | test 63 | 64 | 65 | org.junit.vintage 66 | junit-vintage-engine 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /spring-boot-jms/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | pom 7 | 8 | 9 | org.springframework.boot 10 | spring-boot-starter-parent 11 | 2.2.4.RELEASE 12 | 13 | 14 | 15 | com.mailshine.demo.jms 16 | spring-boot-jms 17 | 0.0.1-SNAPSHOT 18 | spring-boot-jms 19 | Demo project for Spring Boot 20 | 21 | 22 | 1.8 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | org.junit.vintage 38 | junit-vintage-engine 39 | 40 | 41 | 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | 1.18.10 47 | provided 48 | 49 | 50 | 51 | io.springfox 52 | springfox-swagger2 53 | 2.9.2 54 | 55 | 56 | io.springfox 57 | springfox-swagger-ui 58 | 2.9.2 59 | 60 | 61 | 62 | 63 | org.springframework 64 | spring-jms 65 | 66 | 67 | com.ibm.mq 68 | com.ibm.mq.allclient 69 | 9.0.5.0 70 | 71 | 72 | javax.jms 73 | javax.jms-api 74 | 2.0.1 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.springframework.boot 82 | spring-boot-maven-plugin 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /spring-boot-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | pom 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.2.4.RELEASE 10 | 11 | 12 | net.mailshine.demo 13 | spring-boot-microservice 14 | 0.0.1-SNAPSHOT 15 | spring-boot-microservice 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-dependencies 26 | Hoxton.SR5 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | junit 40 | junit 41 | 4.13.1 42 | test 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-test 48 | test 49 | 50 | 51 | org.junit.vintage 52 | junit-vintage-engine 53 | 54 | 55 | 56 | 57 | 58 | org.projectlombok 59 | lombok 60 | 1.18.10 61 | provided 62 | 63 | 64 | 65 | org.springframework.cloud 66 | spring-cloud-starter-sleuth 67 | 68 | 69 | 70 | io.springfox 71 | springfox-swagger2 72 | 2.9.2 73 | 74 | 75 | io.springfox 76 | springfox-swagger-ui 77 | 2.9.2 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /spring-boot-hystrix/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.0.RELEASE 9 | 10 | 11 | com.mailshine.spring.hystrix 12 | spring-boot-hystrix 13 | 0.0.1-SNAPSHOT 14 | spring-boot-hystrix 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | Hoxton.SR5 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-netflix-hystrix 34 | 35 | 36 | org.springframework.cloud 37 | spring-cloud-starter-netflix-hystrix-dashboard 38 | 39 | 40 | 41 | io.springfox 42 | springfox-swagger2 43 | 2.9.2 44 | 45 | 46 | io.springfox 47 | springfox-swagger-ui 48 | 2.9.2 49 | 50 | 51 | 52 | org.projectlombok 53 | lombok 54 | true 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | test 60 | 61 | 62 | org.junit.vintage 63 | junit-vintage-engine 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | org.springframework.cloud 73 | spring-cloud-dependencies 74 | ${spring-cloud.version} 75 | pom 76 | import 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /spring-boot-mutation-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.mailshine.springboot 7 | spring-boot-mutation-sample 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 2.2.4.RELEASE 14 | 15 | 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-aop 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | org.junit.vintage 38 | junit-vintage-engine 39 | 40 | 41 | 42 | 43 | org.apache.commons 44 | commons-lang3 45 | 3.0 46 | 47 | 48 | org.projectlombok 49 | lombok 50 | 1.18.10 51 | provided 52 | 53 | 54 | 55 | io.springfox 56 | springfox-swagger2 57 | 2.9.2 58 | 59 | 60 | io.springfox 61 | springfox-swagger-ui 62 | 2.9.2 63 | 64 | 65 | junit 66 | junit 67 | test 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-maven-plugin 76 | 77 | 78 | 79 | org.pitest 80 | pitest-maven 81 | 1.5.1 82 | 83 | 84 | com.mailshine.springboot.mutation.service.* 85 | 86 | 87 | com.mailshine.springboot.mutation.service.* 88 | 89 | 90 | XML 91 | HTML 92 | 93 | true 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.0.RELEASE 9 | 10 | 11 | com.mailshine.springboot.kafka.avro 12 | spring-boot-kafka-avro 13 | 0.0.1-SNAPSHOT 14 | spring-boot-kafka-avro 15 | spring-boot-kafka-avro 16 | 17 | 1.8 18 | 1.11.4 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-web 24 | 25 | 26 | 27 | org.apache.avro 28 | avro 29 | ${avro.version} 30 | 31 | 32 | 33 | 34 | org.springframework.kafka 35 | spring-kafka 36 | 2.4.6.RELEASE 37 | 38 | 39 | io.springfox 40 | springfox-swagger2 41 | 2.9.2 42 | 43 | 44 | io.springfox 45 | springfox-swagger-ui 46 | 2.9.2 47 | 48 | 49 | org.projectlombok 50 | lombok 51 | true 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-test 56 | test 57 | 58 | 59 | org.junit.vintage 60 | junit-vintage-engine 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | org.apache.avro 73 | avro-maven-plugin 74 | ${avro.version} 75 | 76 | 77 | generate-sources 78 | 79 | schema 80 | 81 | 82 | ${project.basedir}/src/main/resources/avro 83 | ${project.build.directory}/generated/avro 84 | 85 | ${project.basedir}/src/main/resources/avro/Student.avsc 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /spring-boot-webflux/spring-boot-webflux-web/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "spring-boot-webflux-web": { 7 | "projectType": "application", 8 | "schematics": {}, 9 | "root": "", 10 | "sourceRoot": "src", 11 | "prefix": "app", 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/spring-boot-webflux-web", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "tsconfig.app.json", 21 | "aot": true, 22 | "assets": [ 23 | "src/favicon.ico", 24 | "src/assets" 25 | ], 26 | "styles": [ 27 | "src/styles.css" 28 | ], 29 | "scripts": [] 30 | }, 31 | "configurations": { 32 | "production": { 33 | "fileReplacements": [ 34 | { 35 | "replace": "src/environments/environment.ts", 36 | "with": "src/environments/environment.prod.ts" 37 | } 38 | ], 39 | "optimization": true, 40 | "outputHashing": "all", 41 | "sourceMap": false, 42 | "extractCss": true, 43 | "namedChunks": false, 44 | "extractLicenses": true, 45 | "vendorChunk": false, 46 | "buildOptimizer": true, 47 | "budgets": [ 48 | { 49 | "type": "initial", 50 | "maximumWarning": "2mb", 51 | "maximumError": "5mb" 52 | }, 53 | { 54 | "type": "anyComponentStyle", 55 | "maximumWarning": "6kb", 56 | "maximumError": "10kb" 57 | } 58 | ] 59 | } 60 | } 61 | }, 62 | "serve": { 63 | "builder": "@angular-devkit/build-angular:dev-server", 64 | "options": { 65 | "browserTarget": "spring-boot-webflux-web:build" 66 | }, 67 | "configurations": { 68 | "production": { 69 | "browserTarget": "spring-boot-webflux-web:build:production" 70 | } 71 | } 72 | }, 73 | "extract-i18n": { 74 | "builder": "@angular-devkit/build-angular:extract-i18n", 75 | "options": { 76 | "browserTarget": "spring-boot-webflux-web:build" 77 | } 78 | }, 79 | "test": { 80 | "builder": "@angular-devkit/build-angular:karma", 81 | "options": { 82 | "main": "src/test.ts", 83 | "polyfills": "src/polyfills.ts", 84 | "tsConfig": "tsconfig.spec.json", 85 | "karmaConfig": "karma.conf.js", 86 | "assets": [ 87 | "src/favicon.ico", 88 | "src/assets" 89 | ], 90 | "styles": [ 91 | "src/styles.css" 92 | ], 93 | "scripts": [] 94 | } 95 | }, 96 | "lint": { 97 | "builder": "@angular-devkit/build-angular:tslint", 98 | "options": { 99 | "tsConfig": [ 100 | "tsconfig.app.json", 101 | "tsconfig.spec.json", 102 | "e2e/tsconfig.json" 103 | ], 104 | "exclude": [ 105 | "**/node_modules/**" 106 | ] 107 | } 108 | }, 109 | "e2e": { 110 | "builder": "@angular-devkit/build-angular:protractor", 111 | "options": { 112 | "protractorConfig": "e2e/protractor.conf.js", 113 | "devServerTarget": "spring-boot-webflux-web:serve" 114 | }, 115 | "configurations": { 116 | "production": { 117 | "devServerTarget": "spring-boot-webflux-web:serve:production" 118 | } 119 | } 120 | } 121 | } 122 | }}, 123 | "defaultProject": "spring-boot-webflux-web" 124 | } 125 | -------------------------------------------------------------------------------- /spring-boot-swagger-yaml-model/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 2.3.0.RELEASE 11 | 12 | 13 | 14 | com.mailshine.swagger.yaml 15 | spring-boot-swagger-yaml-model 16 | 1.0-SNAPSHOT 17 | 18 | 1.8 19 | 1.5.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-data-jpa 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-actuator 35 | 36 | 37 | io.swagger 38 | swagger-annotations 39 | ${swagger-annotations-version} 40 | 41 | 42 | io.springfox 43 | springfox-swagger2 44 | 2.9.2 45 | 46 | 47 | io.springfox 48 | springfox-swagger-ui 49 | 2.9.2 50 | 51 | 52 | 53 | org.projectlombok 54 | lombok 55 | true 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | test 61 | 62 | 63 | org.junit.vintage 64 | junit-vintage-engine 65 | 66 | 67 | 68 | 69 | com.google.code.gson 70 | gson 71 | 72 | 73 | 74 | io.micrometer 75 | micrometer-registry-prometheus 76 | runtime 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | io.swagger 89 | swagger-codegen-maven-plugin 90 | 2.3.1 91 | 92 | 93 | 94 | generate 95 | 96 | 97 | ${project.basedir}/src/main/resources/swagger/Model_1.0.0.yaml 98 | java 99 | ${project.basedir} 100 | 101 | 104 | com.mailshine.swagger.yaml.model 105 | false 106 | false 107 | false 108 | false 109 | false 110 | 111 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /demo-spring-boot.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /spring-boot-kafka-avro/src/main/java/com/mailshine/springboot/kafka/avro/model/SampleReferenceStudent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Source code recreated from a .class file by IntelliJ IDEA 3 | // (powered by Fernflower decompiler) 4 | // 5 | 6 | package com.mailshine.springboot.kafka.avro.model; 7 | 8 | import java.io.IOException; 9 | import java.io.ObjectInput; 10 | import java.io.ObjectOutput; 11 | import java.nio.ByteBuffer; 12 | import org.apache.avro.AvroMissingFieldException; 13 | import org.apache.avro.AvroRuntimeException; 14 | import org.apache.avro.Schema; 15 | import org.apache.avro.Schema.Field; 16 | import org.apache.avro.Schema.Parser; 17 | import org.apache.avro.data.RecordBuilder; 18 | import org.apache.avro.io.DatumReader; 19 | import org.apache.avro.io.DatumWriter; 20 | import org.apache.avro.io.Encoder; 21 | import org.apache.avro.io.ResolvingDecoder; 22 | import org.apache.avro.message.BinaryMessageDecoder; 23 | import org.apache.avro.message.BinaryMessageEncoder; 24 | import org.apache.avro.message.SchemaStore; 25 | import org.apache.avro.specific.AvroGenerated; 26 | import org.apache.avro.specific.SpecificData; 27 | import org.apache.avro.specific.SpecificRecord; 28 | import org.apache.avro.specific.SpecificRecordBase; 29 | import org.apache.avro.specific.SpecificRecordBuilderBase; 30 | import org.apache.avro.util.Utf8; 31 | 32 | @AvroGenerated 33 | public class SampleReferenceStudent extends SpecificRecordBase implements SpecificRecord { 34 | private static final long serialVersionUID = -888439186857538565L; 35 | public static final Schema SCHEMA$ = (new Parser()).parse("{\"type\":\"record\",\"name\":\"Student\",\"namespace\":\"com.mailshine.springboot.kafka.avro.model\",\"fields\":[{\"name\":\"studentName\",\"type\":\"string\"},{\"name\":\"studentId\",\"type\":\"string\"}]}"); 36 | private static SpecificData MODEL$ = new SpecificData(); 37 | private static final BinaryMessageEncoder ENCODER; 38 | private static final BinaryMessageDecoder DECODER; 39 | /** @deprecated */ 40 | @Deprecated 41 | public CharSequence studentName; 42 | /** @deprecated */ 43 | @Deprecated 44 | public CharSequence studentId; 45 | private static final DatumWriter WRITER$; 46 | private static final DatumReader READER$; 47 | 48 | public static Schema getClassSchema() { 49 | return SCHEMA$; 50 | } 51 | 52 | public static BinaryMessageEncoder getEncoder() { 53 | return ENCODER; 54 | } 55 | 56 | public static BinaryMessageDecoder getDecoder() { 57 | return DECODER; 58 | } 59 | 60 | public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { 61 | return new BinaryMessageDecoder(MODEL$, SCHEMA$, resolver); 62 | } 63 | 64 | public ByteBuffer toByteBuffer() throws IOException { 65 | return ENCODER.encode(this); 66 | } 67 | 68 | public static SampleReferenceStudent fromByteBuffer(ByteBuffer b) throws IOException { 69 | return (SampleReferenceStudent)DECODER.decode(b); 70 | } 71 | 72 | public SampleReferenceStudent() { 73 | } 74 | 75 | public SampleReferenceStudent(CharSequence studentName, CharSequence studentId) { 76 | this.studentName = studentName; 77 | this.studentId = studentId; 78 | } 79 | 80 | public SpecificData getSpecificData() { 81 | return MODEL$; 82 | } 83 | 84 | public Schema getSchema() { 85 | return SCHEMA$; 86 | } 87 | 88 | public Object get(int field$) { 89 | switch(field$) { 90 | case 0: 91 | return this.studentName; 92 | case 1: 93 | return this.studentId; 94 | default: 95 | throw new AvroRuntimeException("Bad index"); 96 | } 97 | } 98 | 99 | public void put(int field$, Object value$) { 100 | switch(field$) { 101 | case 0: 102 | this.studentName = (CharSequence)value$; 103 | break; 104 | case 1: 105 | this.studentId = (CharSequence)value$; 106 | break; 107 | default: 108 | throw new AvroRuntimeException("Bad index"); 109 | } 110 | 111 | } 112 | 113 | public CharSequence getStudentName() { 114 | return this.studentName; 115 | } 116 | 117 | public void setStudentName(CharSequence value) { 118 | this.studentName = value; 119 | } 120 | 121 | public CharSequence getStudentId() { 122 | return this.studentId; 123 | } 124 | 125 | public void setStudentId(CharSequence value) { 126 | this.studentId = value; 127 | } 128 | 129 | public static SampleReferenceStudent.Builder newBuilder() { 130 | return new SampleReferenceStudent.Builder(); 131 | } 132 | 133 | public static SampleReferenceStudent.Builder newBuilder(SampleReferenceStudent.Builder other) { 134 | return other == null ? new SampleReferenceStudent.Builder() : new SampleReferenceStudent.Builder(other); 135 | } 136 | 137 | public static SampleReferenceStudent.Builder newBuilder(SampleReferenceStudent other) { 138 | return other == null ? new SampleReferenceStudent.Builder() : new SampleReferenceStudent.Builder(other); 139 | } 140 | 141 | public void writeExternal(ObjectOutput out) throws IOException { 142 | WRITER$.write(this, SpecificData.getEncoder(out)); 143 | } 144 | 145 | public void readExternal(ObjectInput in) throws IOException { 146 | READER$.read(this, SpecificData.getDecoder(in)); 147 | } 148 | 149 | protected boolean hasCustomCoders() { 150 | return true; 151 | } 152 | 153 | public void customEncode(Encoder out) throws IOException { 154 | out.writeString(this.studentName); 155 | out.writeString(this.studentId); 156 | } 157 | 158 | public void customDecode(ResolvingDecoder in) throws IOException { 159 | Field[] fieldOrder = in.readFieldOrderIfDiff(); 160 | if (fieldOrder == null) { 161 | this.studentName = in.readString(this.studentName instanceof Utf8 ? (Utf8)this.studentName : null); 162 | this.studentId = in.readString(this.studentId instanceof Utf8 ? (Utf8)this.studentId : null); 163 | } else { 164 | for(int i = 0; i < 2; ++i) { 165 | switch(fieldOrder[i].pos()) { 166 | case 0: 167 | this.studentName = in.readString(this.studentName instanceof Utf8 ? (Utf8)this.studentName : null); 168 | break; 169 | case 1: 170 | this.studentId = in.readString(this.studentId instanceof Utf8 ? (Utf8)this.studentId : null); 171 | break; 172 | default: 173 | throw new IOException("Corrupt ResolvingDecoder."); 174 | } 175 | } 176 | } 177 | 178 | } 179 | 180 | static { 181 | ENCODER = new BinaryMessageEncoder(MODEL$, SCHEMA$); 182 | DECODER = new BinaryMessageDecoder(MODEL$, SCHEMA$); 183 | WRITER$ = MODEL$.createDatumWriter(SCHEMA$); 184 | READER$ = MODEL$.createDatumReader(SCHEMA$); 185 | } 186 | 187 | @AvroGenerated 188 | public static class Builder extends SpecificRecordBuilderBase implements RecordBuilder { 189 | private CharSequence studentName; 190 | private CharSequence studentId; 191 | 192 | private Builder() { 193 | super(SampleReferenceStudent.SCHEMA$); 194 | } 195 | 196 | private Builder(SampleReferenceStudent.Builder other) { 197 | super(other); 198 | if (isValidValue(this.fields()[0], other.studentName)) { 199 | this.studentName = (CharSequence)this.data().deepCopy(this.fields()[0].schema(), other.studentName); 200 | this.fieldSetFlags()[0] = other.fieldSetFlags()[0]; 201 | } 202 | 203 | if (isValidValue(this.fields()[1], other.studentId)) { 204 | this.studentId = (CharSequence)this.data().deepCopy(this.fields()[1].schema(), other.studentId); 205 | this.fieldSetFlags()[1] = other.fieldSetFlags()[1]; 206 | } 207 | 208 | } 209 | 210 | private Builder(SampleReferenceStudent other) { 211 | super(SampleReferenceStudent.SCHEMA$); 212 | if (isValidValue(this.fields()[0], other.studentName)) { 213 | this.studentName = (CharSequence)this.data().deepCopy(this.fields()[0].schema(), other.studentName); 214 | this.fieldSetFlags()[0] = true; 215 | } 216 | 217 | if (isValidValue(this.fields()[1], other.studentId)) { 218 | this.studentId = (CharSequence)this.data().deepCopy(this.fields()[1].schema(), other.studentId); 219 | this.fieldSetFlags()[1] = true; 220 | } 221 | 222 | } 223 | 224 | public CharSequence getStudentName() { 225 | return this.studentName; 226 | } 227 | 228 | public SampleReferenceStudent.Builder setStudentName(CharSequence value) { 229 | this.validate(this.fields()[0], value); 230 | this.studentName = value; 231 | this.fieldSetFlags()[0] = true; 232 | return this; 233 | } 234 | 235 | public boolean hasStudentName() { 236 | return this.fieldSetFlags()[0]; 237 | } 238 | 239 | public SampleReferenceStudent.Builder clearStudentName() { 240 | this.studentName = null; 241 | this.fieldSetFlags()[0] = false; 242 | return this; 243 | } 244 | 245 | public CharSequence getStudentId() { 246 | return this.studentId; 247 | } 248 | 249 | public SampleReferenceStudent.Builder setStudentId(CharSequence value) { 250 | this.validate(this.fields()[1], value); 251 | this.studentId = value; 252 | this.fieldSetFlags()[1] = true; 253 | return this; 254 | } 255 | 256 | public boolean hasStudentId() { 257 | return this.fieldSetFlags()[1]; 258 | } 259 | 260 | public SampleReferenceStudent.Builder clearStudentId() { 261 | this.studentId = null; 262 | this.fieldSetFlags()[1] = false; 263 | return this; 264 | } 265 | 266 | public SampleReferenceStudent build() { 267 | try { 268 | SampleReferenceStudent record = new SampleReferenceStudent(); 269 | record.studentName = this.fieldSetFlags()[0] ? this.studentName : (CharSequence)this.defaultValue(this.fields()[0]); 270 | record.studentId = this.fieldSetFlags()[1] ? this.studentId : (CharSequence)this.defaultValue(this.fields()[1]); 271 | return record; 272 | } catch (AvroMissingFieldException var2) { 273 | throw var2; 274 | } catch (Exception var3) { 275 | throw new AvroRuntimeException(var3); 276 | } 277 | } 278 | } 279 | } 280 | --------------------------------------------------------------------------------