├── soap-springws-learncamel-spring-boot ├── LOG_PATH_IS_UNDEFINED │ └── camellog.log ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── sql │ └── application.sql ├── src │ ├── main │ │ ├── java │ │ │ ├── net │ │ │ │ └── webservicex │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── GetCountries.java │ │ │ │ │ ├── GetCurrencies.java │ │ │ │ │ ├── GetCurrencyCode.java │ │ │ │ │ ├── GetISD.java │ │ │ │ │ ├── GetGMTbyCountry.java │ │ │ │ │ ├── GetISDResponse.java │ │ │ │ │ ├── GetCurrencyByCountry.java │ │ │ │ │ ├── GetCountryByCountryCode.java │ │ │ │ │ ├── GetCountryByCurrencyCode.java │ │ │ │ │ ├── GetISOCountryCodeByCountyName.java │ │ │ │ │ ├── GetCurrencyCodeByCurrencyName.java │ │ │ │ │ ├── GetCountriesResponse.java │ │ │ │ │ ├── GetCurrenciesResponse.java │ │ │ │ │ ├── GetCurrencyCodeResponse.java │ │ │ │ │ ├── GetGMTbyCountryResponse.java │ │ │ │ │ ├── GetCurrencyByCountryResponse.java │ │ │ │ │ ├── GetCountryByCountryCodeResponse.java │ │ │ │ │ ├── GetCountryByCurrencyCodeResponse.java │ │ │ │ │ ├── GetCurrencyCodeByCurrencyNameResponse.java │ │ │ │ │ └── GetISOCountryCodeByCountyNameResponse.java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── SoapCamelApplication.java │ │ │ │ ├── config │ │ │ │ ├── DBConfig.java │ │ │ │ └── SoapConfig.java │ │ │ │ ├── domain │ │ │ │ └── Country.java │ │ │ │ ├── processor │ │ │ │ ├── BuildSQLProcessor.java │ │ │ │ ├── RequestXMLBuildProcessor.java │ │ │ │ └── HealthCheckProcessor.java │ │ │ │ ├── routes │ │ │ │ └── HealthCheckRoute.java │ │ │ │ └── alert │ │ │ │ └── MailProcessor.java │ │ └── resources │ │ │ └── logback.xml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ ├── SoapCamelRouteTest.java │ │ └── HealthCheckMockTest.java ├── README.md └── .gitignore ├── learncamel-spring-boot ├── datafile │ ├── fileDelete.txt │ └── fileUpdate.txt ├── data │ └── input │ │ └── fileAdd.txt ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── sql │ └── Application.sql ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── LearncamelSpringBootApplication.java │ │ │ │ ├── processor │ │ │ │ ├── SuccessMessageProcessor.java │ │ │ │ ├── BuildSQLProcessor.java │ │ │ │ └── HealthCheckProcessor.java │ │ │ │ ├── config │ │ │ │ └── DBConfig.java │ │ │ │ ├── alert │ │ │ │ └── MailProcessor.java │ │ │ │ ├── routes │ │ │ │ └── HealthCheckRoute.java │ │ │ │ └── domain │ │ │ │ └── Item.java │ │ └── resources │ │ │ └── logback.xml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ └── HealthRouteMockTest.java ├── .gitignore └── README.md ├── simple-rest-api ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── learnspringboot │ │ │ ├── SimpleRestApiApplication.java │ │ │ ├── controller │ │ │ └── CurrentTimeController.java │ │ │ └── service │ │ │ └── CurrentTimeService.java │ └── test │ │ └── java │ │ └── com │ │ └── learnspringboot │ │ └── SimpleRestApiApplicationTests.java ├── .gitignore └── pom.xml ├── activemq-learncamel-spring-boot ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── ActiveMQCamelApplication.java │ │ │ │ ├── config │ │ │ │ ├── ActiveMQConfig.java │ │ │ │ └── DBConfig.java │ │ │ │ ├── processor │ │ │ │ ├── ValidateDataProcessor.java │ │ │ │ ├── BuildSQLProcessor.java │ │ │ │ └── HealthCheckProcessor.java │ │ │ │ ├── routes │ │ │ │ ├── HealthCheckRoute.java │ │ │ │ └── ActiveMQRoute.java │ │ │ │ ├── alert │ │ │ │ └── MailProcessor.java │ │ │ │ └── domain │ │ │ │ └── Item.java │ │ └── resources │ │ │ └── logback.xml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ ├── SimpleCamelRouteMockTest.java │ │ ├── ActiveMQRouteTest.java │ │ └── HealthCheckMockTest.java ├── .gitignore ├── README.md └── data │ └── input ├── camel-spring-boot-boiler-plate ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── CamelSpringBoilerPlateApplication.java │ │ │ │ ├── config │ │ │ │ └── DBConfig.java │ │ │ │ ├── routes │ │ │ │ ├── HealthCheckRoute.java │ │ │ │ └── SimpleCamelRoute.java │ │ │ │ ├── alert │ │ │ │ └── MailProcessor.java │ │ │ │ └── processor │ │ │ │ └── HealthCheckProcessor.java │ │ └── resources │ │ │ ├── logback.xml │ │ │ └── application.yml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ ├── SimpleCamelRouteMockTest.java │ │ ├── SimpleCamelRouteTest.java │ │ └── HealthCheckMockTest.java ├── README.md └── .gitignore ├── kafka-learncamel-spring-boot ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── KafkaCamelApplication.java │ │ │ │ ├── config │ │ │ │ └── DBConfig.java │ │ │ │ ├── processor │ │ │ │ ├── ValidateDataProcessor.java │ │ │ │ ├── BuildSQLProcessor.java │ │ │ │ └── HealthCheckProcessor.java │ │ │ │ ├── routes │ │ │ │ ├── HealthCheckRoute.java │ │ │ │ └── KafkaRoute.java │ │ │ │ ├── alert │ │ │ │ └── MailProcessor.java │ │ │ │ └── domain │ │ │ │ └── Item.java │ │ └── resources │ │ │ └── logback.xml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ ├── HealthCheckMockTest.java │ │ └── KafkaRouteMockTest.java ├── .gitignore ├── README.md └── data │ └── input ├── rest-learncamel-spring-boot ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── sql │ └── application.sql ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── RestCamelApplication.java │ │ │ │ ├── service │ │ │ │ └── CountryService.java │ │ │ │ ├── config │ │ │ │ └── DBConfig.java │ │ │ │ ├── processor │ │ │ │ ├── CountrySelectProcessor.java │ │ │ │ ├── BuildSQLProcessor.java │ │ │ │ └── HealthCheckProcessor.java │ │ │ │ ├── domain │ │ │ │ └── Country.java │ │ │ │ ├── routes │ │ │ │ ├── HealthCheckRoute.java │ │ │ │ ├── RestCamelRoute.java │ │ │ │ └── CountryRestRoute.java │ │ │ │ └── alert │ │ │ │ └── MailProcessor.java │ │ └── resources │ │ │ ├── logback.xml │ │ │ └── application.yml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ ├── SimpleCamelRouteMockTest.java │ │ ├── SimpleCamelRouteTest.java │ │ └── HealthCheckMockTest.java ├── .gitignore └── README.md ├── rest-learncamel-spring-boot-with-mockito ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── sql │ └── application.sql ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── learncamel │ │ │ │ ├── exception │ │ │ │ └── DataException.java │ │ │ │ ├── RestCamelApplication.java │ │ │ │ ├── config │ │ │ │ ├── ApplicationConfig.java │ │ │ │ └── DBConfig.java │ │ │ │ ├── processor │ │ │ │ ├── CountrySelectProcessor.java │ │ │ │ ├── BuildSQLProcessor.java │ │ │ │ └── HealthCheckProcessor.java │ │ │ │ ├── service │ │ │ │ └── CountryService.java │ │ │ │ ├── domain │ │ │ │ └── Country.java │ │ │ │ ├── routes │ │ │ │ ├── HealthCheckRoute.java │ │ │ │ ├── RestCamelRoute.java │ │ │ │ └── CountryRestRoute.java │ │ │ │ └── alert │ │ │ │ └── MailProcessor.java │ │ └── resources │ │ │ └── logback.xml │ └── test │ │ └── java │ │ └── com │ │ └── learncamel │ │ └── routes │ │ ├── service │ │ ├── CountryServiceTest.java │ │ └── CountriesMockTest.java │ │ ├── SimpleCamelRouteMockTest.java │ │ ├── SimpleCamelRouteTest.java │ │ └── HealthCheckMockTest.java ├── .gitignore └── README.md ├── set-up ├── How-to-download:run-activemq.md ├── How-to-install-Postgres-in-Windows.md └── How-to-install-Postgres-in-Mac.md └── README.md /soap-springws-learncamel-spring-boot/LOG_PATH_IS_UNDEFINED/camellog.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /learncamel-spring-boot/datafile/fileDelete.txt: -------------------------------------------------------------------------------- 1 | type,sku#,item description,price 2 | DELETE,100,Samsung TV,500.00 -------------------------------------------------------------------------------- /learncamel-spring-boot/datafile/fileUpdate.txt: -------------------------------------------------------------------------------- 1 | type,sku#,item description,price 2 | UPDATE,100,Samsung TV,600.00 -------------------------------------------------------------------------------- /learncamel-spring-boot/data/input/fileAdd.txt: -------------------------------------------------------------------------------- 1 | type,sku#,item description,price 2 | ADD,100,Samsung TV,500.00 3 | ADD,101,LG TV,300.00 4 | ADD,,Sony TV,300.00 -------------------------------------------------------------------------------- /simple-rest-api/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /simple-rest-api/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/simple-rest-api/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /learncamel-spring-boot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/kafka-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/rest-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/camel-spring-boot-boiler-plate/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/activemq-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/soap-springws-learncamel-spring-boot/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/sql/application.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE COUNTRIES( 2 | COUNTRY_I SERIAL, 3 | NAME TEXT, 4 | COUNTRY_CODE TEXT, 5 | CRTE_TS TIMESTAMPTZ NULL default current_timestamp 6 | ); -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/HEAD/rest-learncamel-spring-boot-with-mockito/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/sql/application.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE COUNTRY( 2 | COUNTRY_I SERIAL, 3 | NAME TEXT, 4 | COUNTRY_CODE TEXT, 5 | POPULATION NUMERIC, 6 | CRTE_TS TIMESTAMPTZ NULL default current_timestamp 7 | ); -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/sql/application.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE COUNTRY( 2 | COUNTRY_I SERIAL, 3 | NAME TEXT, 4 | COUNTRY_CODE TEXT, 5 | POPULATION NUMERIC, 6 | CRTE_TS TIMESTAMPTZ NULL default current_timestamp 7 | ); -------------------------------------------------------------------------------- /learncamel-spring-boot/sql/Application.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE ITEMS; 2 | 3 | CREATE TABLE ITEMS( 4 | ITEM_I SERIAL, 5 | SKU TEXT NOT NULL, 6 | ITEM_DESCRIPTION TEXT DEFAULT NULL, 7 | PRICE NUMERIC (5, 2), 8 | CRTE_TS TIMESTAMPTZ NULL default current_timestamp 9 | ); -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/package-info.java: -------------------------------------------------------------------------------- 1 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webserviceX.NET", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 2 | package net.webservicex; 3 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/exception/DataException.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.exception; 2 | 3 | /** 4 | * Created by Dilip on 1/21/18. 5 | */ 6 | public class DataException extends RuntimeException { 7 | 8 | public DataException( String message) { 9 | super( message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /simple-rest-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | 5 | --- 6 | spring: 7 | profiles: dev 8 | 9 | message: Hello from DEV environment and the current time is 10 | 11 | 12 | --- 13 | spring: 14 | profiles: prod 15 | 16 | message: Hello from PROD environment and the current time is 17 | 18 | --- -------------------------------------------------------------------------------- /simple-rest-api/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/README.md: -------------------------------------------------------------------------------- 1 | # camel-spring-boot-boiler-plate 2 | Boiler Plate Code for building Camel Spring Boot Projects 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/README.md: -------------------------------------------------------------------------------- 1 | # camel-spring-boot-boiler-plate 2 | Boiler Plate Code for building Camel Spring Boot Projects 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. -------------------------------------------------------------------------------- /learncamel-spring-boot/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ 26 | /logs 27 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/README.md: -------------------------------------------------------------------------------- 1 | # kafka-learncamel-spring-boot 2 | This code base has the working code to connect to the Kafka 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. 11 | - Kafka Configuration 12 | -------------------------------------------------------------------------------- /learncamel-spring-boot/README.md: -------------------------------------------------------------------------------- 1 | # learncamel-spring-boot 2 | This code base has the working code to connect to the File component 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. 11 | - File/Folder Configuration 12 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/README.md: -------------------------------------------------------------------------------- 1 | # activemq-learncamel-spring-boot 2 | This code base has the working code to connect to the REST API 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. 11 | - ActiveMQ Configuration 12 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/RestCamelApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RestCamelApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RestCamelApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/KafkaCamelApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class KafkaCamelApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(KafkaCamelApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/RestCamelApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RestCamelApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RestCamelApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /simple-rest-api/src/main/java/com/learnspringboot/SimpleRestApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.learnspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SimpleRestApiApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SimpleRestApiApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/service/CountryService.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | @Component 8 | public class CountryService { 9 | 10 | public String getCurrentDateTime(){ 11 | 12 | LocalDateTime localDateTime = LocalDateTime.now(); 13 | return localDateTime.toString(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/SoapCamelApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SoapCamelApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SoapCamelApplication.class, args); 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/LearncamelSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class LearncamelSpringBootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(LearncamelSpringBootApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/README.md: -------------------------------------------------------------------------------- 1 | # rest-learncamel-spring-boot 2 | This code base has the working code to connect to the Kafka 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. 11 | - Kafka Configuration 12 | - Rest/Restlet Configuration 13 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/README.md: -------------------------------------------------------------------------------- 1 | # rest-learncamel-spring-boot 2 | This code base has the working code to connect to the Kafka 3 | 4 | This code base is bundled with the following: 5 | 6 | - Lombok - application logging 7 | - jdbc - Postgres DB configuration 8 | - Email - Email configuration 9 | - Application Health Check Configuration. 10 | - Camel Spring Boot Testing Libraries. 11 | - Kafka Configuration 12 | - Rest/Restlet Configuration 13 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/CamelSpringBoilerPlateApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CamelSpringBoilerPlateApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CamelSpringBoilerPlateApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/data/input: -------------------------------------------------------------------------------- 1 | {"transactionType":"ADD", "sku":"100", "itemDescription":"SamsungTV", "price":"500.00"} 2 | {"transactionType":"ADD", "sku":"101", "itemDescription":"LG TV", "price":"500.00"} 3 | {"transactionType":"UPDATE", "sku":"101", "itemDescription":"LG TV", "price":"700.00"} 4 | {"transactionType":"DELETE", "sku":"101", "itemDescription":"LG TV", "price":"500"} 5 | 6 | --Error 7 | {"transactionType":"ADD", "sku":"", "itemDescription":"ABC TV", "price":"500.00"} -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/data/input: -------------------------------------------------------------------------------- 1 | {"transactionType":"ADD", "sku":"100", "itemDescription":"SamsungTV", "price":"500.00"} 2 | {"transactionType":"ADD", "sku":"101", "itemDescription":"LG TV", "price":"500.00"} 3 | {"transactionType":"UPDATE", "sku":"101", "itemDescription":"LG TV", "price":"700.00"} 4 | {"transactionType":"DELETE", "sku":"101", "itemDescription":"LG TV", "price":"500"} 5 | 6 | --Error 7 | {"transactionType":"ADD", "sku":"", "itemDescription":"ABC TV", "price":"500.00"} -------------------------------------------------------------------------------- /simple-rest-api/src/test/java/com/learnspringboot/SimpleRestApiApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.learnspringboot; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SimpleRestApiApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.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 ApplicationConfig { 9 | 10 | @Bean 11 | public RestTemplate restTemplate(){ 12 | return new RestTemplate(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/ActiveMQCamelApplication.java: -------------------------------------------------------------------------------- 1 | package com.learncamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableAutoConfiguration 9 | public class ActiveMQCamelApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ActiveMQCamelApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/processor/SuccessMessageProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.camel.Exchange; 5 | import org.apache.camel.Processor; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by Dilip on 1/18/18. 10 | */ 11 | @Component 12 | @Slf4j 13 | public class SuccessMessageProcessor implements Processor { 14 | @Override 15 | public void process(Exchange exchange) throws Exception { 16 | exchange.getIn().setBody("Data Updated Successfully"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /set-up/How-to-download:run-activemq.md: -------------------------------------------------------------------------------- 1 | ## Apache ActiveMQ 2 | Apache ActiveMQ is the most popular and powerful open source messaging server. 3 | 4 | Step 1: Download Active MQ. 5 | 6 | ``` 7 | http://activemq.apache.org/activemq-5145-release.html 8 | ``` 9 | 10 | Step 2: Navigate to the bin directory and run the following command. 11 | 12 | ``` 13 | ./activemq console 14 | ``` 15 | 16 | Step 3: Below link has the steps to run Active MQ in your machine. 17 | 18 | ``` 19 | http://activemq.apache.org/getting-started.html#GettingStarted-StartingActiveMQStartingActiveMQ 20 | ``` 21 | 22 | Step 4: 23 | 24 | Console URL: 25 | 26 | ``` 27 | http://127.0.0.1:8161/admin/ 28 | ``` 29 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/config/ActiveMQConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.apache.activemq.ActiveMQConnectionFactory; 4 | import org.apache.activemq.camel.component.ActiveMQComponent; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import javax.jms.ConnectionFactory; 8 | 9 | @Configuration 10 | public class ActiveMQConfig { 11 | 12 | 13 | @Bean(name = "activemq") 14 | public ActiveMQComponent createComponent(ConnectionFactory factory) { 15 | ActiveMQComponent activeMQComponent = new ActiveMQComponent(); 16 | activeMQComponent.setConnectionFactory(factory); 17 | return activeMQComponent; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Configuration 14 | public class DBConfig { 15 | 16 | @Bean(name = "dataSource") 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | public DataSource dataSource() { 19 | DataSource ds = DataSourceBuilder.create().build(); 20 | return ds; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/domain/Country.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.domain; 2 | 3 | public class Country { 4 | 5 | protected String sISOCode; 6 | protected String sName; 7 | 8 | public String getsISOCode() { 9 | return sISOCode; 10 | } 11 | 12 | public void setsISOCode(String sISOCode) { 13 | this.sISOCode = sISOCode; 14 | } 15 | 16 | public String getsName() { 17 | return sName; 18 | } 19 | 20 | public void setsName(String sName) { 21 | this.sName = sName; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "Country{" + 27 | "sISOCode='" + sISOCode + '\'' + 28 | ", sName='" + sName + '\'' + 29 | '}'; 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/config/SoapConfig.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.ws.client.core.WebServiceTemplate; 6 | 7 | @Configuration 8 | public class SoapConfig { 9 | 10 | @Bean(value = "webServiceTemplate") 11 | public WebServiceTemplate createWebServiceTemplate(){ 12 | WebServiceTemplate template = new WebServiceTemplate(); 13 | template.setDefaultUri("http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"); 14 | return template; 15 | } 16 | 17 | /* @Bean(value = "cdataTransformer") 18 | public CDataTransformer cDataTransformer(){ 19 | return new CDataTransformer(); 20 | }*/ 21 | } 22 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/processor/ValidateDataProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Item; 4 | import com.learncamel.exception.DataException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.util.ObjectUtils; 10 | 11 | @Component 12 | @Slf4j 13 | public class ValidateDataProcessor implements Processor { 14 | @Override 15 | public void process(Exchange exchange) throws Exception { 16 | 17 | Item item = (Item) exchange.getIn().getBody(); 18 | log.info(" Item in ValidateDataProcessor is : " + item); 19 | 20 | if(ObjectUtils.isEmpty(item.getSku())){ 21 | throw new DataException("Sku is null for " + item.getItemDescription()); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /simple-rest-api/src/main/java/com/learnspringboot/controller/CurrentTimeController.java: -------------------------------------------------------------------------------- 1 | package com.learnspringboot.controller; 2 | 3 | import com.learnspringboot.service.CurrentTimeService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | /** 11 | * Created by Dilip on 1/7/18. 12 | */ 13 | @RestController 14 | public class CurrentTimeController { 15 | 16 | @Autowired 17 | CurrentTimeService currentTimeService; 18 | 19 | @RequestMapping(value = "/currentTime") 20 | public String getCurrentDateTime() throws InterruptedException { 21 | System.out.println("controller getCurrentDateTime call"+ LocalDateTime.now().toString()); 22 | return currentTimeService.getCurrentDateTime(); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/processor/ValidateDataProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Item; 4 | import com.learncamel.exception.DataException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.util.ObjectUtils; 10 | 11 | @Component 12 | @Slf4j 13 | public class ValidateDataProcessor implements Processor { 14 | @Override 15 | public void process(Exchange exchange) throws Exception { 16 | 17 | Item item = (Item) exchange.getIn().getBody(); 18 | log.info(" Item in ValidateDataProcessor is : " + item); 19 | 20 | if(ObjectUtils.isEmpty(item.getSku())){ 21 | throw new DataException("Sku is null for " + item.getItemDescription()); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCountries.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | import javax.xml.bind.annotation.XmlType; 8 | 9 | 10 | /** 11 | *

Java class for anonymous complex type. 12 | * 13 | *

The following schema fragment specifies the expected content contained within this class. 14 | * 15 | *

16 |  * <complexType>
17 |  *   <complexContent>
18 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
19 |  *     </restriction>
20 |  *   </complexContent>
21 |  * </complexType>
22 |  * 
23 | * 24 | * 25 | */ 26 | @XmlAccessorType(XmlAccessType.FIELD) 27 | @XmlType(name = "") 28 | @XmlRootElement(name = "GetCountries") 29 | public class GetCountries { 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencies.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | import javax.xml.bind.annotation.XmlType; 8 | 9 | 10 | /** 11 | *

Java class for anonymous complex type. 12 | * 13 | *

The following schema fragment specifies the expected content contained within this class. 14 | * 15 | *

16 |  * <complexType>
17 |  *   <complexContent>
18 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
19 |  *     </restriction>
20 |  *   </complexContent>
21 |  * </complexType>
22 |  * 
23 | * 24 | * 25 | */ 26 | @XmlAccessorType(XmlAccessType.FIELD) 27 | @XmlType(name = "") 28 | @XmlRootElement(name = "GetCurrencies") 29 | public class GetCurrencies { 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/processor/CountrySelectProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.camel.Exchange; 5 | import org.apache.camel.Processor; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.Random; 11 | 12 | @Component 13 | @Slf4j 14 | public class CountrySelectProcessor implements Processor { 15 | 16 | 17 | List countryList = Arrays.asList("us","in", "gb","cn","jp"); 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | Random random = new Random(); 22 | String countryCode = countryList.get(random.nextInt(countryList.size()-1)); 23 | 24 | log.info("Selected Country Code is : " + countryCode); 25 | 26 | exchange.getIn().setHeader("countryId", countryCode); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencyCode.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | import javax.xml.bind.annotation.XmlType; 8 | 9 | 10 | /** 11 | *

Java class for anonymous complex type. 12 | * 13 | *

The following schema fragment specifies the expected content contained within this class. 14 | * 15 | *

16 |  * <complexType>
17 |  *   <complexContent>
18 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
19 |  *     </restriction>
20 |  *   </complexContent>
21 |  * </complexType>
22 |  * 
23 | * 24 | * 25 | */ 26 | @XmlAccessorType(XmlAccessType.FIELD) 27 | @XmlType(name = "") 28 | @XmlRootElement(name = "GetCurrencyCode") 29 | public class GetCurrencyCode { 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/processor/CountrySelectProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.camel.Exchange; 5 | import org.apache.camel.Processor; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.Random; 11 | 12 | @Component 13 | @Slf4j 14 | public class CountrySelectProcessor implements Processor { 15 | 16 | 17 | List countryList = Arrays.asList("us","in", "gb","cn","jp"); 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | Random random = new Random(); 22 | String countryCode = countryList.get(random.nextInt(countryList.size()-1)); 23 | 24 | log.info("Selected Country Code is : " + countryCode); 25 | 26 | exchange.getIn().setHeader("countryId", countryCode); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/service/CountryService.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Component 11 | public class CountryService { 12 | 13 | 14 | @Autowired 15 | RestTemplate restTemplate; 16 | 17 | public String getCurrentDateTime(){ 18 | 19 | LocalDateTime localDateTime = LocalDateTime.now(); 20 | return localDateTime.toString(); 21 | } 22 | 23 | 24 | public String getCountryDetails(String countryCode){ 25 | 26 | String url = "https://restcountries.eu/rest/v2/alpha/".concat(countryCode); 27 | 28 | ResponseEntity response = restTemplate.getForEntity(url, String.class); 29 | 30 | return response.getBody(); 31 | } 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/processor/BuildSQLProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Country; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | @Slf4j 11 | public class BuildSQLProcessor implements Processor { 12 | 13 | @Override 14 | public void process(Exchange exchange) throws Exception { 15 | 16 | Country country = (Country) exchange.getIn().getBody(); 17 | 18 | StringBuilder query = new StringBuilder(); 19 | 20 | query.append("INSERT INTO COUNTRIES (NAME, COUNTRY_CODE) VALUES ('"); 21 | query.append(country.getsName()+"','"+country.getsISOCode()+"');"); 22 | log.info("Final Query is : " + query); 23 | exchange.getIn().setBody(query.toString()); 24 | exchange.getIn().setHeader("countryCode",country.getsISOCode()); 25 | 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /set-up/How-to-install-Postgres-in-Windows.md: -------------------------------------------------------------------------------- 1 | # PostGresSql 2 | 3 | ## How to install PostGres? 4 | 5 | Download postgres from the below link. 6 | 7 | ``` 8 | https://www.enterprisedb.com/downloads/postgres-postgresql-downloads#windows 9 | ``` 10 | 11 | ## Postgres GUI client 12 | 13 | The installer will provide you the **pgAdmin** client as part of the installation. 14 | 15 | We can use this client to connect to the database. 16 | 17 | ## How to connect to Postgres from Intellij: 18 | 19 | Step 1: 20 | 21 | **Mac :** 22 | 23 | ``` 24 | Intellij IDEA -> Preferences -> Plugins 25 | ``` 26 | 27 | **Windows:** 28 | 29 | ``` 30 | File -> Settings-> Plugins 31 | ``` 32 | 33 | Below steps are the same for windows and Mac. 34 | Step 2: 35 | 36 | Search for **DataBase Navigator**. 37 | 38 | Step 3: 39 | 40 | Install the plugin and restart the Intellij. 41 | 42 | Step 4: 43 | 44 | There will be a **Database Navigator** in the Menu bar. 45 | 46 | Step 5: 47 | 48 | Click on **DataBase Navigator**. 49 | 50 | Click on **Open SQL Console**. 51 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/domain/Country.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.domain; 2 | 3 | public class Country { 4 | 5 | String name; 6 | String alpha3Code; 7 | String population; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getAlpha3Code() { 18 | return alpha3Code; 19 | } 20 | 21 | public void setAlpha3Code(String alpha3Code) { 22 | this.alpha3Code = alpha3Code; 23 | } 24 | 25 | public String getPopulation() { 26 | return population; 27 | } 28 | 29 | public void setPopulation(String population) { 30 | this.population = population; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Country{" + 36 | "name='" + name + '\'' + 37 | ", alpha3Code='" + alpha3Code + '\'' + 38 | ", population='" + population + '\'' + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/domain/Country.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.domain; 2 | 3 | public class Country { 4 | 5 | String name; 6 | String alpha3Code; 7 | String population; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getAlpha3Code() { 18 | return alpha3Code; 19 | } 20 | 21 | public void setAlpha3Code(String alpha3Code) { 22 | this.alpha3Code = alpha3Code; 23 | } 24 | 25 | public String getPopulation() { 26 | return population; 27 | } 28 | 29 | public void setPopulation(String population) { 30 | this.population = population; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Country{" + 36 | "name='" + name + '\'' + 37 | ", alpha3Code='" + alpha3Code + '\'' + 38 | ", population='" + population + '\'' + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/processor/BuildSQLProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Country; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | import java.util.Random; 12 | 13 | @Component 14 | @Slf4j 15 | public class BuildSQLProcessor implements Processor { 16 | 17 | @Override 18 | public void process(Exchange exchange) throws Exception { 19 | 20 | Country country = (Country) exchange.getIn().getBody(); 21 | 22 | StringBuilder query = new StringBuilder(); 23 | 24 | query.append("INSERT INTO COUNTRY (NAME, COUNTRY_CODE,POPULATION) VALUES ('"); 25 | query.append(country.getName()+"','"+country.getAlpha3Code()+"',"+country.getPopulation()+");"); 26 | log.info("Final Query is : " + query); 27 | exchange.getIn().setBody(query.toString()); 28 | exchange.getIn().setHeader("countryCode" , country.getAlpha3Code()); 29 | 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/processor/BuildSQLProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Country; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | import java.util.Random; 12 | 13 | @Component 14 | @Slf4j 15 | public class BuildSQLProcessor implements Processor { 16 | 17 | @Override 18 | public void process(Exchange exchange) throws Exception { 19 | 20 | Country country = (Country) exchange.getIn().getBody(); 21 | 22 | StringBuilder query = new StringBuilder(); 23 | 24 | query.append("INSERT INTO COUNTRY (NAME, COUNTRY_CODE,POPULATION) VALUES ('"); 25 | query.append(country.getName()+"','"+country.getAlpha3Code()+"',"+country.getPopulation()+");"); 26 | log.info("Final Query is : " + query); 27 | exchange.getIn().setBody(query.toString()); 28 | exchange.getIn().setHeader("countryCode" , country.getAlpha3Code()); 29 | 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/test/java/com/learncamel/routes/service/CountryServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes.service; 2 | 3 | import com.learncamel.service.CountryService; 4 | import org.apache.camel.test.spring.CamelSpringBootRunner; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.annotation.DirtiesContext; 10 | import org.springframework.test.context.ActiveProfiles; 11 | 12 | import static org.junit.Assert.assertNotNull; 13 | import static org.junit.Assert.assertTrue; 14 | 15 | @ActiveProfiles("dev") 16 | @RunWith(CamelSpringBootRunner.class) 17 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 18 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 19 | public class CountryServiceTest { 20 | 21 | @Autowired 22 | CountryService countryService; 23 | 24 | @Test 25 | public void getCountryDetails(){ 26 | String responseBody = countryService.getCountryDetails("us"); 27 | System.out.println("responseBody : " + responseBody); 28 | assertNotNull(responseBody); 29 | assertTrue(responseBody.contains("United States of America")); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /simple-rest-api/src/main/java/com/learnspringboot/service/CurrentTimeService.java: -------------------------------------------------------------------------------- 1 | package com.learnspringboot.service; 2 | 3 | import org.apache.tomcat.jni.Local; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.core.env.Environment; 6 | import org.springframework.scheduling.annotation.Async; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | /** 12 | * Created by Dilip on 1/7/18. 13 | */ 14 | @Service 15 | public class CurrentTimeService { 16 | 17 | @Autowired 18 | Environment environment; 19 | 20 | public String getCurrentDateTime() throws InterruptedException { 21 | 22 | LocalDateTime localDateTime = getCurrentTime(); 23 | System.out.println("Inside getCurrentDateTime" + LocalDateTime.now().toString()); 24 | String response = environment.getProperty("message").concat("\n").concat(localDateTime.toString()); 25 | System.out.println("after getCurrentDateTime call"+ LocalDateTime.now().toString()); 26 | return response; 27 | } 28 | 29 | @Async 30 | public LocalDateTime getCurrentTime() throws InterruptedException { 31 | System.out.println("Inside getCurrentTime"+ LocalDateTime.now().toString()); 32 | Thread.sleep(5000); 33 | return LocalDateTime.now(); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{dd-MM-yyyy HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${LOG_PATH}/camellog.log 19 | 20 | 21 | 22 | %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | ${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log 29 | 30 | 10 31 | 100MB 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Predicate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by Dilip on 2/10/18. 12 | */ 13 | @Component 14 | public class HealthCheckRoute extends RouteBuilder{ 15 | 16 | 17 | @Autowired 18 | HealthCheckProcessor healthCheckProcessor; 19 | 20 | @Autowired 21 | MailProcessor mailProcessor; 22 | 23 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 24 | 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | 29 | from("{{healthRoute}}").routeId("healthRoute") 30 | .choice() // Content based EIP 31 | .when(isNotDev) // not dev check 32 | .pollEnrich("http://localhost:8080/health") 33 | .end() 34 | .process(healthCheckProcessor) 35 | .choice() 36 | .when(header("error").isEqualTo(true)) 37 | .choice() 38 | .when(isNotDev) 39 | .process(mailProcessor) 40 | .end() 41 | .end(); 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Predicate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by Dilip on 2/10/18. 12 | */ 13 | @Component 14 | public class HealthCheckRoute extends RouteBuilder{ 15 | 16 | 17 | @Autowired 18 | HealthCheckProcessor healthCheckProcessor; 19 | 20 | @Autowired 21 | MailProcessor mailProcessor; 22 | 23 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 24 | 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | 29 | from("{{healthRoute}}").routeId("healthRoute") 30 | .choice() // Content based EIP 31 | .when(isNotDev) // not dev check 32 | .pollEnrich("http://localhost:8080/health") 33 | .end() 34 | .process(healthCheckProcessor) 35 | .choice() 36 | .when(header("error").isEqualTo(true)) 37 | .choice() 38 | .when(isNotDev) 39 | .process(mailProcessor) 40 | .end() 41 | .end(); 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Predicate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by Dilip on 2/10/18. 12 | */ 13 | @Component 14 | public class HealthCheckRoute extends RouteBuilder{ 15 | 16 | 17 | @Autowired 18 | HealthCheckProcessor healthCheckProcessor; 19 | 20 | @Autowired 21 | MailProcessor mailProcessor; 22 | 23 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 24 | 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | 29 | from("{{healthRoute}}").routeId("healthRoute") 30 | .choice() // Content based EIP 31 | .when(isNotDev) // not dev check 32 | .pollEnrich("http://localhost:8080/health") 33 | .end() 34 | .process(healthCheckProcessor) 35 | .choice() 36 | .when(header("error").isEqualTo(true)) 37 | .choice() 38 | .when(isNotDev) 39 | .process(mailProcessor) 40 | .end() 41 | .end(); 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Predicate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by Dilip on 2/10/18. 12 | */ 13 | @Component 14 | public class HealthCheckRoute extends RouteBuilder{ 15 | 16 | 17 | @Autowired 18 | HealthCheckProcessor healthCheckProcessor; 19 | 20 | @Autowired 21 | MailProcessor mailProcessor; 22 | 23 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 24 | 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | 29 | from("{{healthRoute}}").routeId("healthRoute") 30 | .choice() // Content based EIP 31 | .when(isNotDev) // not dev check 32 | .pollEnrich("http://localhost:8080/health") 33 | .end() 34 | .process(healthCheckProcessor) 35 | .choice() 36 | .when(header("error").isEqualTo(true)) 37 | .choice() 38 | .when(isNotDev) 39 | .process(mailProcessor) 40 | .end() 41 | .end(); 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | @Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | @Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | @Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | @Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | // emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | @Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Predicate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by Dilip on 2/10/18. 12 | */ 13 | @Component 14 | public class HealthCheckRoute extends RouteBuilder{ 15 | 16 | 17 | @Autowired 18 | HealthCheckProcessor healthCheckProcessor; 19 | 20 | @Autowired 21 | MailProcessor mailProcessor; 22 | 23 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 24 | 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | 29 | from("{{healthRoute}}").routeId("healthRoute") 30 | .choice() // Content based EIP 31 | .when(isNotDev) // not dev check 32 | .pollEnrich("http://localhost:8080/health") 33 | .end() 34 | .process(healthCheckProcessor) 35 | .choice() 36 | .when(header("error").isEqualTo(true)) 37 | .choice() 38 | .when(isNotDev) 39 | .process(mailProcessor) 40 | .end() 41 | .end(); 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Predicate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by Dilip on 2/10/18. 12 | */ 13 | //@Component 14 | public class HealthCheckRoute extends RouteBuilder{ 15 | 16 | 17 | @Autowired 18 | HealthCheckProcessor healthCheckProcessor; 19 | 20 | @Autowired 21 | MailProcessor mailProcessor; 22 | 23 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 24 | 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | 29 | from("{{healthRoute}}").routeId("healthRoute") 30 | .choice() // Content based EIP 31 | .when(isNotDev) // not dev check 32 | .pollEnrich("http://localhost:8080/health") 33 | .end() 34 | .process(healthCheckProcessor) 35 | .choice() 36 | .when(header("error").isEqualTo(true)) 37 | .choice() 38 | .when(isNotDev) 39 | .process(mailProcessor) 40 | .end() 41 | .end(); 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | @Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/alert/MailProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.alert; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.mail.javamail.JavaMailSender; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Created by Dilip on 1/20/18. 15 | */ 16 | //@Component 17 | @Slf4j 18 | public class MailProcessor implements Processor { 19 | 20 | @Autowired 21 | public JavaMailSender emailSender; 22 | 23 | @Autowired 24 | Environment environment; 25 | 26 | @Override 27 | public void process(Exchange exchange) throws Exception { 28 | 29 | Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 30 | log.info("Error Message in MailProcessor : " + e.getMessage()); 31 | 32 | String messageBody = "Exception happened in the route and the exception is " + e.getMessage(); 33 | 34 | SimpleMailMessage message = new SimpleMailMessage(); 35 | message.setFrom(environment.getProperty("mailFrom")); 36 | message.setTo(environment.getProperty("mailto")); 37 | message.setSubject("Exception in Camel Route"); 38 | message.setText(messageBody); 39 | 40 | emailSender.send(message); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/routes/HealthCheckRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.processor.HealthCheckProcessor; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Predicate; 7 | import org.apache.camel.builder.RouteBuilder; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * Created by Dilip on 2/10/18. 13 | */ 14 | @Component 15 | public class HealthCheckRoute extends RouteBuilder{ 16 | 17 | 18 | @Autowired 19 | HealthCheckProcessor healthCheckProcessor; 20 | 21 | @Autowired 22 | MailProcessor mailProcessor; 23 | 24 | Predicate isNotDev = header("env").isNotEqualTo("mock"); 25 | 26 | 27 | @Override 28 | public void configure() throws Exception { 29 | 30 | from("{{healthRoute}}").routeId("healthRoute") 31 | .choice() // Content based EIP 32 | .when(isNotDev) // not dev check 33 | .pollEnrich("http://localhost:8081/health") 34 | .end() 35 | .process(healthCheckProcessor) 36 | .choice() 37 | .when(header("error").isEqualTo(true)) 38 | .choice() 39 | .when(isNotDev) 40 | .process(mailProcessor) 41 | .end() 42 | .end(); 43 | 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/domain/Item.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.domain; 2 | 3 | 4 | import java.math.BigDecimal; 5 | 6 | /** 7 | * Created by Dilip on 2/1/18. 8 | */ 9 | public class Item { 10 | 11 | private String transactionType; 12 | 13 | private String sku; 14 | 15 | private String itemDescription; 16 | 17 | private BigDecimal price; 18 | 19 | public String getTransactionType() { 20 | return transactionType; 21 | } 22 | 23 | public void setTransactionType(String transactionType) { 24 | this.transactionType = transactionType; 25 | } 26 | 27 | public String getSku() { 28 | return sku; 29 | } 30 | 31 | public void setSku(String sku) { 32 | this.sku = sku; 33 | } 34 | 35 | public String getItemDescription() { 36 | return itemDescription; 37 | } 38 | 39 | public void setItemDescription(String itemDescription) { 40 | this.itemDescription = itemDescription; 41 | } 42 | 43 | public BigDecimal getPrice() { 44 | return price; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Item{" + 50 | "transactionType='" + transactionType + '\'' + 51 | ", sku='" + sku + '\'' + 52 | ", itemDescription='" + itemDescription + '\'' + 53 | ", price=" + price + 54 | '}'; 55 | } 56 | 57 | public void setPrice(BigDecimal price) { 58 | this.price = price; 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/domain/Item.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.domain; 2 | 3 | 4 | import java.math.BigDecimal; 5 | 6 | /** 7 | * Created by Dilip on 2/1/18. 8 | */ 9 | public class Item { 10 | 11 | private String transactionType; 12 | 13 | private String sku; 14 | 15 | private String itemDescription; 16 | 17 | private BigDecimal price; 18 | 19 | public String getTransactionType() { 20 | return transactionType; 21 | } 22 | 23 | public void setTransactionType(String transactionType) { 24 | this.transactionType = transactionType; 25 | } 26 | 27 | public String getSku() { 28 | return sku; 29 | } 30 | 31 | public void setSku(String sku) { 32 | this.sku = sku; 33 | } 34 | 35 | public String getItemDescription() { 36 | return itemDescription; 37 | } 38 | 39 | public void setItemDescription(String itemDescription) { 40 | this.itemDescription = itemDescription; 41 | } 42 | 43 | public BigDecimal getPrice() { 44 | return price; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Item{" + 50 | "transactionType='" + transactionType + '\'' + 51 | ", sku='" + sku + '\'' + 52 | ", itemDescription='" + itemDescription + '\'' + 53 | ", price=" + price + 54 | '}'; 55 | } 56 | 57 | public void setPrice(BigDecimal price) { 58 | this.price = price; 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/processor/BuildSQLProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Item; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.Exchange; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by Dilip on 2/3/18. 10 | */ 11 | @Component 12 | @Slf4j 13 | public class BuildSQLProcessor implements org.apache.camel.Processor { 14 | @Override 15 | public void process(Exchange exchange) throws Exception { 16 | 17 | Item item = (Item) exchange.getIn().getBody(); 18 | log.info(" Item in BuildSQLProcessor is : " + item); 19 | String tableName ="ITEMS"; 20 | StringBuilder query = new StringBuilder(); 21 | 22 | if(item.getTransactionType().equals("ADD")){ 23 | query.append("INSERT INTO "+tableName+ " (SKU, ITEM_DESCRIPTION,PRICE) VALUES ('"); 24 | query.append(item.getSku()+"','"+item.getItemDescription()+"',"+item.getPrice()+");"); 25 | 26 | }else if(item.getTransactionType().equals("UPDATE")){ 27 | query.append("UPDATE "+tableName+" SET PRICE ="); 28 | query.append(item.getPrice()+" where SKU = '"+item.getSku()+"'"); 29 | 30 | }else if(item.getTransactionType().equals("DELETE")){ 31 | query.append("DELETE FROM " + tableName + " where SKU = '"+item.getSku()+"'"); 32 | } 33 | log.info("Final Query is : " + query); 34 | exchange.getIn().setBody(query.toString()); 35 | exchange.getIn().setHeader("skuId", item.getSku()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/processor/RequestXMLBuildProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.camel.Exchange; 5 | import org.apache.camel.Processor; 6 | import org.apache.camel.component.spring.ws.SpringWebserviceConstants; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | import java.util.Random; 12 | 13 | @Component 14 | @Slf4j 15 | public class RequestXMLBuildProcessor implements Processor{ 16 | 17 | List countryList = Arrays.asList("US","IN", "GB","CN","JP"); 18 | 19 | String countryWebServiceUri = "http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"; 20 | 21 | @Override 22 | public void process(Exchange exchange) throws Exception { 23 | 24 | Random random = new Random(); 25 | String countryCode = countryList.get(random.nextInt(countryList.size()-1)); 26 | 27 | String inputXML = buildXmlString().replace("ABC",countryCode); 28 | 29 | log.info("Input XML is : " + inputXML ); 30 | 31 | exchange.getIn().setBody(inputXML); 32 | exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, countryWebServiceUri); 33 | 34 | 35 | 36 | } 37 | 38 | private String buildXmlString(){ 39 | 40 | return " \n" + 41 | " ABC\n" + 42 | " "; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/routes/SimpleCamelRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.exception.DataException; 5 | import org.apache.camel.LoggingLevel; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.postgresql.util.PSQLException; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.beans.factory.annotation.Qualifier; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.stereotype.Component; 12 | 13 | import javax.sql.DataSource; 14 | 15 | /** 16 | * Created by Dilip on 1/3/18. 17 | */ 18 | @Component 19 | public class SimpleCamelRoute extends RouteBuilder{ 20 | 21 | @Autowired 22 | Environment environment; 23 | 24 | @Qualifier("dataSource") 25 | @Autowired 26 | DataSource dataSource; 27 | 28 | @Autowired 29 | MailProcessor mailProcessor; 30 | 31 | 32 | @Override 33 | public void configure() throws Exception { 34 | 35 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 36 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 37 | 38 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 39 | .process(mailProcessor); 40 | 41 | 42 | from("{{fromRoute}}") 43 | .log("Current Environment is "+ environment.getProperty("message")) 44 | .to("{{toRoute}}"); 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /simple-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.learnspringboot 7 | simple-rest-api 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | simple-rest-api 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/processor/BuildSQLProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Item; 4 | import com.learncamel.exception.DataException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.util.ObjectUtils; 9 | 10 | /** 11 | * Created by Dilip on 2/3/18. 12 | */ 13 | @Component 14 | @Slf4j 15 | public class BuildSQLProcessor implements org.apache.camel.Processor { 16 | @Override 17 | public void process(Exchange exchange) throws Exception { 18 | 19 | Item item = (Item) exchange.getIn().getBody(); 20 | log.info(" Item in BuildSQLProcessor is : " + item); 21 | String tableName ="ITEMS"; 22 | StringBuilder query = new StringBuilder(); 23 | 24 | if(item.getTransactionType().equals("ADD")){ 25 | query.append("INSERT INTO "+tableName+ " (SKU, ITEM_DESCRIPTION,PRICE) VALUES ('"); 26 | query.append(item.getSku()+"','"+item.getItemDescription()+"',"+item.getPrice()+");"); 27 | 28 | }else if(item.getTransactionType().equals("UPDATE")){ 29 | query.append("UPDATE "+tableName+" SET PRICE ="); 30 | query.append(item.getPrice()+" where SKU = '"+item.getSku()+"'"); 31 | 32 | }else if(item.getTransactionType().equals("DELETE")){ 33 | query.append("DELETE FROM " + tableName + " where SKU = '"+item.getSku()+"'"); 34 | } 35 | log.info("Final Query is : " + query); 36 | exchange.getIn().setBody(query.toString()); 37 | exchange.getIn().setHeader("skuId", item.getSku()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | StringBuilder builder = null; 28 | 29 | for(String key : map.keySet()){ 30 | 31 | if(map.get(key).toString().contains("DOWN")){ 32 | 33 | if(builder==null) 34 | builder = new StringBuilder(); 35 | 36 | builder.append(key+ " component in the route is Down\n"); 37 | } 38 | } 39 | 40 | if(builder!=null){ 41 | log.info("Exception Message is" + builder.toString()); 42 | exchange.getIn().setHeader("error", true); 43 | exchange.getIn().setBody(builder.toString()); 44 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 45 | } 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | // log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | StringBuilder builder = null; 28 | 29 | for(String key : map.keySet()){ 30 | 31 | if(map.get(key).toString().contains("DOWN")){ 32 | 33 | if(builder==null) 34 | builder = new StringBuilder(); 35 | 36 | builder.append(key+ " component in the route is Down\n"); 37 | } 38 | } 39 | 40 | if(builder!=null){ 41 | log.info("Exception Message is" + builder.toString()); 42 | exchange.getIn().setHeader("error", true); 43 | exchange.getIn().setBody(builder.toString()); 44 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 45 | } 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | StringBuilder builder = null; 28 | 29 | for(String key : map.keySet()){ 30 | 31 | if(map.get(key).toString().contains("DOWN")){ 32 | 33 | if(builder==null) 34 | builder = new StringBuilder(); 35 | 36 | builder.append(key+ " component in the route is Down\n"); 37 | } 38 | } 39 | 40 | if(builder!=null){ 41 | log.info("Exception Message is" + builder.toString()); 42 | exchange.getIn().setHeader("error", true); 43 | exchange.getIn().setBody(builder.toString()); 44 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 45 | } 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | StringBuilder builder = null; 28 | 29 | for(String key : map.keySet()){ 30 | 31 | if(map.get(key).toString().contains("DOWN")){ 32 | 33 | if(builder==null) 34 | builder = new StringBuilder(); 35 | 36 | builder.append(key+ " component in the route is Down\n"); 37 | } 38 | } 39 | 40 | if(builder!=null){ 41 | log.info("Exception Message is" + builder.toString()); 42 | exchange.getIn().setHeader("error", true); 43 | exchange.getIn().setBody(builder.toString()); 44 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 45 | } 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | StringBuilder builder = null; 28 | 29 | for(String key : map.keySet()){ 30 | 31 | if(map.get(key).toString().contains("DOWN")){ 32 | 33 | if(builder==null) 34 | builder = new StringBuilder(); 35 | 36 | builder.append(key+ " component in the route is Down\n"); 37 | } 38 | } 39 | 40 | if(builder!=null){ 41 | log.info("Exception Message is" + builder.toString()); 42 | exchange.getIn().setHeader("error", true); 43 | exchange.getIn().setBody(builder.toString()); 44 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 45 | } 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | StringBuilder builder = null; 28 | 29 | for(String key : map.keySet()){ 30 | 31 | if(map.get(key).toString().contains("DOWN")){ 32 | 33 | if(builder==null) 34 | builder = new StringBuilder(); 35 | 36 | builder.append(key+ " component in the route is Down\n"); 37 | } 38 | } 39 | 40 | if(builder!=null){ 41 | log.info("Exception Message is" + builder.toString()); 42 | exchange.getIn().setHeader("error", true); 43 | exchange.getIn().setBody(builder.toString()); 44 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 45 | } 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/processor/BuildSQLProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.learncamel.domain.Item; 4 | import com.learncamel.exception.DataException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.util.ObjectUtils; 9 | 10 | /** 11 | * Created by Dilip on 1/17/18. 12 | */ 13 | @Component 14 | @Slf4j 15 | public class BuildSQLProcessor implements org.apache.camel.Processor { 16 | 17 | String tableName ="ITEMS"; 18 | @Override 19 | public void process(Exchange exchange) throws Exception { 20 | Item item = (Item) exchange.getIn().getBody(); 21 | 22 | System.out.println("Inside Processor : " + item); 23 | StringBuilder query = new StringBuilder(); 24 | if(ObjectUtils.isEmpty(item.getSku())){ 25 | throw new DataException("Sku is null for " + item.getItemDescription()); 26 | } 27 | if(item.getTransactionType().equals("ADD")){ 28 | query.append("INSERT INTO "+tableName+" (SKU, ITEM_DESCRIPTION,PRICE) VALUES ('"); 29 | query.append(item.getSku()+"','" + item.getItemDescription()+"',"+ item.getPrice()+" );"); 30 | }else if(item.getTransactionType().equals("UPDATE")){ 31 | query.append("UPDATE "+tableName+" SET PRICE ="); 32 | query.append(item.getPrice()+" where SKU ='"+item.getSku()+"'"); 33 | }else if(item.getTransactionType().equals("DELETE")){ 34 | query.append("DELETE FROM "+tableName+" WHERE SKU ='"+item.getSku()+"'"); 35 | } 36 | log.info("Query is : " + query); 37 | 38 | exchange.getIn().setBody(query.toString()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/processor/HealthCheckProcessor.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.processor; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.Processor; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Dilip on 2/10/18. 14 | */ 15 | @Component 16 | @Slf4j 17 | public class HealthCheckProcessor implements Processor { 18 | 19 | @Override 20 | public void process(Exchange exchange) throws Exception { 21 | 22 | String healthCheckResult = (String) exchange.getIn().getBody(String.class); 23 | 24 | log.info("Health String of the APP is" + healthCheckResult); 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | Map map = objectMapper.readValue(healthCheckResult, new TypeReference>(){}); 27 | System.out.println("Map : " + map); 28 | StringBuilder builder = null; 29 | 30 | for(String key : map.keySet()){ 31 | 32 | if(map.get(key).toString().contains("DOWN")){ 33 | 34 | if(builder==null) 35 | builder = new StringBuilder(); 36 | 37 | builder.append(key+ " component in the route is Down\n"); 38 | } 39 | } 40 | 41 | if(builder!=null){ 42 | log.info("Exception Message is" + builder.toString()); 43 | exchange.getIn().setHeader("error", true); 44 | exchange.getIn().setBody(builder.toString()); 45 | exchange.setProperty(Exchange.EXCEPTION_CAUGHT,builder.toString()); 46 | } 47 | 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/test/java/com/learncamel/routes/SimpleCamelRouteMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import org.apache.camel.*; 4 | import org.apache.camel.builder.RouteBuilder; 5 | import org.apache.camel.test.junit4.CamelTestSupport; 6 | import org.apache.camel.test.spring.CamelSpringBootRunner; 7 | import org.apache.camel.test.spring.DisableJmx; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.core.env.Environment; 14 | import org.springframework.test.annotation.DirtiesContext; 15 | import org.springframework.test.context.ActiveProfiles; 16 | 17 | /** 18 | * Created by Dilip on 1/13/18. 19 | */ 20 | @ActiveProfiles("mock") 21 | @RunWith(CamelSpringBootRunner.class) 22 | @SpringBootTest 23 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 24 | @DisableJmx(true) 25 | public class SimpleCamelRouteMockTest extends CamelTestSupport{ 26 | 27 | 28 | @Autowired 29 | private CamelContext context; 30 | 31 | @Autowired 32 | protected CamelContext createCamelContext() { 33 | return context; 34 | } 35 | 36 | @Autowired 37 | private ProducerTemplate producerTemplate; 38 | 39 | @Autowired 40 | private ConsumerTemplate consumerTemplate; 41 | 42 | @Override 43 | protected RouteBuilder createRouteBuilder(){ 44 | return new RestCamelRoute(); 45 | } 46 | 47 | @Autowired 48 | Environment environment; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | } 54 | 55 | @Test 56 | public void simpleTestCase(){ 57 | assertTrue(true); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/test/java/com/learncamel/routes/SimpleCamelRouteMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import org.apache.camel.*; 4 | import org.apache.camel.builder.RouteBuilder; 5 | import org.apache.camel.test.junit4.CamelTestSupport; 6 | import org.apache.camel.test.spring.CamelSpringBootRunner; 7 | import org.apache.camel.test.spring.DisableJmx; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.core.env.Environment; 14 | import org.springframework.test.annotation.DirtiesContext; 15 | import org.springframework.test.context.ActiveProfiles; 16 | 17 | /** 18 | * Created by Dilip on 1/13/18. 19 | */ 20 | @ActiveProfiles("mock") 21 | @RunWith(CamelSpringBootRunner.class) 22 | @SpringBootTest 23 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 24 | @DisableJmx(true) 25 | public class SimpleCamelRouteMockTest extends CamelTestSupport{ 26 | 27 | 28 | @Autowired 29 | private CamelContext context; 30 | 31 | @Autowired 32 | protected CamelContext createCamelContext() { 33 | return context; 34 | } 35 | 36 | @Autowired 37 | private ProducerTemplate producerTemplate; 38 | 39 | @Autowired 40 | private ConsumerTemplate consumerTemplate; 41 | 42 | @Override 43 | protected RouteBuilder createRouteBuilder(){ 44 | return new RestCamelRoute(); 45 | } 46 | 47 | @Autowired 48 | Environment environment; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | } 54 | 55 | @Test 56 | public void simpleTestCase(){ 57 | assertTrue(true); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/main/java/com/learncamel/domain/Item.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.domain; 2 | 3 | import org.apache.camel.dataformat.bindy.annotation.CsvRecord; 4 | import org.apache.camel.dataformat.bindy.annotation.DataField; 5 | 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * Created by Dilip on 1/15/18. 10 | */ 11 | @CsvRecord( separator = ",",skipFirstLine=true) 12 | public class Item { 13 | 14 | @DataField(pos = 1) 15 | private String transactionType; 16 | 17 | @DataField(pos = 2) 18 | private String sku; 19 | 20 | @DataField(pos = 3) 21 | private String itemDescription; 22 | 23 | @DataField(pos = 4,precision = 2) 24 | private BigDecimal price; 25 | 26 | public String getTransactionType() { 27 | return transactionType; 28 | } 29 | 30 | public void setTransactionType(String transactionType) { 31 | this.transactionType = transactionType; 32 | } 33 | 34 | public String getSku() { 35 | return sku; 36 | } 37 | 38 | public void setSku(String sku) { 39 | this.sku = sku; 40 | } 41 | 42 | public String getItemDescription() { 43 | return itemDescription; 44 | } 45 | 46 | public void setItemDescription(String itemDescription) { 47 | this.itemDescription = itemDescription; 48 | } 49 | 50 | public BigDecimal getPrice() { 51 | return price; 52 | } 53 | 54 | public void setPrice(BigDecimal price) { 55 | this.price = price; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "Item{" + 61 | "transactionType='" + transactionType + '\'' + 62 | ", sku='" + sku + '\'' + 63 | ", itemDescription='" + itemDescription + '\'' + 64 | ", price=" + price + 65 | '}'; 66 | } 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetISD.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "countryName" 33 | }) 34 | @XmlRootElement(name = "GetISD") 35 | public class GetISD { 36 | 37 | @XmlElement(name = "CountryName") 38 | protected String countryName; 39 | 40 | /** 41 | * Gets the value of the countryName property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCountryName() { 49 | return countryName; 50 | } 51 | 52 | /** 53 | * Sets the value of the countryName property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCountryName(String value) { 61 | this.countryName = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetGMTbyCountry.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "countryName" 33 | }) 34 | @XmlRootElement(name = "GetGMTbyCountry") 35 | public class GetGMTbyCountry { 36 | 37 | @XmlElement(name = "CountryName") 38 | protected String countryName; 39 | 40 | /** 41 | * Gets the value of the countryName property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCountryName() { 49 | return countryName; 50 | } 51 | 52 | /** 53 | * Sets the value of the countryName property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCountryName(String value) { 61 | this.countryName = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetISDResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetISDResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getISDResult" 33 | }) 34 | @XmlRootElement(name = "GetISDResponse") 35 | public class GetISDResponse { 36 | 37 | @XmlElement(name = "GetISDResult") 38 | protected String getISDResult; 39 | 40 | /** 41 | * Gets the value of the getISDResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetISDResult() { 49 | return getISDResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getISDResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetISDResult(String value) { 61 | this.getISDResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/test/java/com/learncamel/routes/SimpleCamelRouteMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.exception.DataException; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.camel.CamelContext; 6 | import org.apache.camel.CamelExecutionException; 7 | import org.apache.camel.EndpointInject; 8 | import org.apache.camel.ProducerTemplate; 9 | import org.apache.camel.component.mock.MockEndpoint; 10 | import org.apache.camel.test.junit4.CamelTestSupport; 11 | import org.apache.camel.test.spring.CamelSpringBootRunner; 12 | import org.apache.camel.test.spring.DisableJmx; 13 | import org.apache.commons.io.FileUtils; 14 | import org.junit.BeforeClass; 15 | import org.junit.Test; 16 | import org.junit.runner.RunWith; 17 | import org.mockito.Mock; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | import org.springframework.core.env.Environment; 21 | import org.springframework.test.annotation.DirtiesContext; 22 | import org.springframework.test.context.ActiveProfiles; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.nio.file.Files; 27 | import java.nio.file.Paths; 28 | 29 | /** 30 | * Created by Dilip on 1/13/18. 31 | */ 32 | @ActiveProfiles("mock") 33 | @RunWith(CamelSpringBootRunner.class) 34 | @SpringBootTest 35 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 36 | @Slf4j 37 | public class SimpleCamelRouteMockTest extends CamelTestSupport{ 38 | 39 | 40 | @Autowired 41 | private CamelContext context; 42 | 43 | @Autowired 44 | Environment environment; 45 | 46 | @Autowired 47 | protected CamelContext createCamelContext() { 48 | return context; 49 | } 50 | 51 | @Test 52 | public void simpleTestCase(){ 53 | assertTrue(true); 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencyByCountry.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "countryName" 33 | }) 34 | @XmlRootElement(name = "GetCurrencyByCountry") 35 | public class GetCurrencyByCountry { 36 | 37 | @XmlElement(name = "CountryName") 38 | protected String countryName; 39 | 40 | /** 41 | * Gets the value of the countryName property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCountryName() { 49 | return countryName; 50 | } 51 | 52 | /** 53 | * Sets the value of the countryName property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCountryName(String value) { 61 | this.countryName = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCountryByCountryCode.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CountryCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "countrycode" 33 | }) 34 | @XmlRootElement(name = "GetCountryByCountryCode") 35 | public class GetCountryByCountryCode { 36 | 37 | @XmlElement(name = "CountryCode") 38 | protected String countryCode; 39 | 40 | /** 41 | * Gets the value of the countrycode property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCountryCode() { 49 | return countryCode; 50 | } 51 | 52 | /** 53 | * Sets the value of the countrycode property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCountryCode(String value) { 61 | this.countryCode = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCountryByCurrencyCode.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CurrencyCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "currencyCode" 33 | }) 34 | @XmlRootElement(name = "GetCountryByCurrencyCode") 35 | public class GetCountryByCurrencyCode { 36 | 37 | @XmlElement(name = "CurrencyCode") 38 | protected String currencyCode; 39 | 40 | /** 41 | * Gets the value of the currencyCode property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCurrencyCode() { 49 | return currencyCode; 50 | } 51 | 52 | /** 53 | * Sets the value of the currencyCode property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCurrencyCode(String value) { 61 | this.currencyCode = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetISOCountryCodeByCountyName.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "countryName" 33 | }) 34 | @XmlRootElement(name = "GetISOCountryCodeByCountyName") 35 | public class GetISOCountryCodeByCountyName { 36 | 37 | @XmlElement(name = "CountryName") 38 | protected String countryName; 39 | 40 | /** 41 | * Gets the value of the countryName property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCountryName() { 49 | return countryName; 50 | } 51 | 52 | /** 53 | * Sets the value of the countryName property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCountryName(String value) { 61 | this.countryName = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencyCodeByCurrencyName.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="CurrencyName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "currencyName" 33 | }) 34 | @XmlRootElement(name = "GetCurrencyCodeByCurrencyName") 35 | public class GetCurrencyCodeByCurrencyName { 36 | 37 | @XmlElement(name = "CurrencyName") 38 | protected String currencyName; 39 | 40 | /** 41 | * Gets the value of the currencyName property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getCurrencyName() { 49 | return currencyName; 50 | } 51 | 52 | /** 53 | * Sets the value of the currencyName property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setCurrencyName(String value) { 61 | this.currencyName = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/test/java/com/learncamel/routes/SimpleCamelRouteTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import org.apache.camel.CamelContext; 4 | import org.apache.camel.ConsumerTemplate; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | import static org.junit.Assert.assertNotNull; 20 | import static org.junit.Assert.assertTrue; 21 | 22 | /** 23 | * Created by Dilip on 1/4/18. 24 | */ 25 | @ActiveProfiles("dev") 26 | @RunWith(CamelSpringBootRunner.class) 27 | @SpringBootTest 28 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 29 | public class SimpleCamelRouteTest extends CamelTestSupport { 30 | 31 | @Autowired 32 | private CamelContext context; 33 | 34 | @Autowired 35 | protected CamelContext createCamelContext() { 36 | return context; 37 | } 38 | 39 | @Autowired 40 | private ProducerTemplate producerTemplate; 41 | 42 | @Autowired 43 | private ConsumerTemplate consumerTemplate; 44 | 45 | @Override 46 | protected RouteBuilder createRouteBuilder(){ 47 | return new RestCamelRoute(); 48 | } 49 | 50 | @Autowired 51 | Environment environment; 52 | 53 | @Before 54 | public void setUp(){ 55 | 56 | } 57 | 58 | @Test 59 | public void simpleTestCase(){ 60 | assertTrue(true); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/test/java/com/learncamel/routes/SimpleCamelRouteTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import org.apache.camel.CamelContext; 4 | import org.apache.camel.ConsumerTemplate; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | import static org.junit.Assert.assertNotNull; 20 | import static org.junit.Assert.assertTrue; 21 | 22 | /** 23 | * Created by Dilip on 1/4/18. 24 | */ 25 | @ActiveProfiles("dev") 26 | @RunWith(CamelSpringBootRunner.class) 27 | @SpringBootTest 28 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 29 | public class SimpleCamelRouteTest extends CamelTestSupport { 30 | 31 | @Autowired 32 | private CamelContext context; 33 | 34 | @Autowired 35 | protected CamelContext createCamelContext() { 36 | return context; 37 | } 38 | 39 | @Autowired 40 | private ProducerTemplate producerTemplate; 41 | 42 | @Autowired 43 | private ConsumerTemplate consumerTemplate; 44 | 45 | @Override 46 | protected RouteBuilder createRouteBuilder(){ 47 | return new RestCamelRoute(); 48 | } 49 | 50 | @Autowired 51 | Environment environment; 52 | 53 | @Before 54 | public void setUp(){ 55 | 56 | } 57 | 58 | @Test 59 | public void simpleTestCase(){ 60 | assertTrue(true); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCountriesResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCountriesResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCountriesResult" 33 | }) 34 | @XmlRootElement(name = "GetCountriesResponse") 35 | public class GetCountriesResponse { 36 | 37 | @XmlElement(name = "GetCountriesResult") 38 | protected String getCountriesResult; 39 | 40 | /** 41 | * Gets the value of the getCountriesResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCountriesResult() { 49 | return getCountriesResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCountriesResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCountriesResult(String value) { 61 | this.getCountriesResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrenciesResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCurrenciesResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCurrenciesResult" 33 | }) 34 | @XmlRootElement(name = "GetCurrenciesResponse") 35 | public class GetCurrenciesResponse { 36 | 37 | @XmlElement(name = "GetCurrenciesResult") 38 | protected String getCurrenciesResult; 39 | 40 | /** 41 | * Gets the value of the getCurrenciesResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCurrenciesResult() { 49 | return getCurrenciesResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCurrenciesResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCurrenciesResult(String value) { 61 | this.getCurrenciesResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /set-up/How-to-install-Postgres-in-Mac.md: -------------------------------------------------------------------------------- 1 | # PostGresSql 2 | 3 | ## How to install PostGres? 4 | 5 | Run the below command : 6 | 7 | ``` 8 | brew install postgres 9 | 10 | ``` 11 | 12 | How to check the postgres version? 13 | 14 | ``` 15 | postgres --version 16 | ``` 17 | 18 | How to Start PostGres? 19 | 20 | ``` 21 | brew services start postgresql 22 | ``` 23 | 24 | How to Stop PostGres? 25 | 26 | ``` 27 | brew services stop postgresql 28 | ``` 29 | 30 | #### How to create a user in Postgres via command line? 31 | 32 | ``` 33 | createuser postgres -s 34 | ``` 35 | 36 | 37 | #### How to create a DB in Postgres via command line? 38 | 39 | **Apporach 1:** 40 | 41 | https://www.postgresql.org/docs/9.1/static/app-createdb.html 42 | 43 | ``` 44 | createdb -p 5432 -h localhost -e localDB 45 | 46 | ``` 47 | 48 | **Apporach 2:** 49 | 50 | - Running the create DataBase command the postgres client. 51 | 52 | ``` 53 | CREATE DATABASE lusiadas; 54 | 55 | ``` 56 | 57 | ## How to connect to Postgres DB server from Terminal: 58 | 59 | ``` 60 | psql -h -U -W "sslmode=require" 61 | ``` 62 | 63 | By Default user id postgres will be created. 64 | 65 | Conmmand to connect to Localhost: 66 | 67 | ``` 68 | psql localDB localhost -U postgres 69 | ``` 70 | 71 | ## How to connect to Postgres from Intellij: 72 | 73 | Step 1: 74 | 75 | **Mac :** 76 | 77 | ``` 78 | Intellij IDEA -> Preferences -> Plugins 79 | ``` 80 | 81 | **Windows:** 82 | 83 | ``` 84 | File -> Settings-> Plugins 85 | ``` 86 | 87 | Below steps are the same for windows and Mac. 88 | Step 2: 89 | 90 | Search for **DataBase Navigator**. 91 | 92 | Step 3: 93 | 94 | Install the plugin and restart the Intellij. 95 | 96 | Step 4: 97 | 98 | There will be a **Database Navigator** in the Menu bar. 99 | 100 | Step 5: 101 | 102 | Click on **DataBase Navigator**. 103 | 104 | Click on **Open SQL Console**. 105 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencyCodeResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCurrencyCodeResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCurrencyCodeResult" 33 | }) 34 | @XmlRootElement(name = "GetCurrencyCodeResponse") 35 | public class GetCurrencyCodeResponse { 36 | 37 | @XmlElement(name = "GetCurrencyCodeResult") 38 | protected String getCurrencyCodeResult; 39 | 40 | /** 41 | * Gets the value of the getCurrencyCodeResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCurrencyCodeResult() { 49 | return getCurrencyCodeResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCurrencyCodeResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCurrencyCodeResult(String value) { 61 | this.getCurrencyCodeResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetGMTbyCountryResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetGMTbyCountryResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getGMTbyCountryResult" 33 | }) 34 | @XmlRootElement(name = "GetGMTbyCountryResponse") 35 | public class GetGMTbyCountryResponse { 36 | 37 | @XmlElement(name = "GetGMTbyCountryResult") 38 | protected String getGMTbyCountryResult; 39 | 40 | /** 41 | * Gets the value of the getGMTbyCountryResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetGMTbyCountryResult() { 49 | return getGMTbyCountryResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getGMTbyCountryResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetGMTbyCountryResult(String value) { 61 | this.getGMTbyCountryResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/test/java/com/learncamel/routes/SimpleCamelRouteMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.exception.DataException; 4 | import org.apache.camel.*; 5 | import org.apache.camel.builder.RouteBuilder; 6 | import org.apache.camel.component.mock.MockEndpoint; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.apache.camel.test.spring.DisableJmx; 10 | import org.apache.commons.io.FileUtils; 11 | import org.junit.Before; 12 | import org.junit.BeforeClass; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.mockito.Mock; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.boot.test.context.SpringBootTest; 18 | import org.springframework.core.env.Environment; 19 | import org.springframework.test.annotation.DirtiesContext; 20 | import org.springframework.test.context.ActiveProfiles; 21 | 22 | import java.io.File; 23 | import java.io.IOException; 24 | import java.nio.file.Files; 25 | import java.nio.file.Paths; 26 | 27 | /** 28 | * Created by Dilip on 1/13/18. 29 | */ 30 | @ActiveProfiles("mock") 31 | @RunWith(CamelSpringBootRunner.class) 32 | @SpringBootTest 33 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 34 | @DisableJmx(true) 35 | public class SimpleCamelRouteMockTest extends CamelTestSupport{ 36 | 37 | 38 | @Autowired 39 | private CamelContext context; 40 | 41 | @Autowired 42 | protected CamelContext createCamelContext() { 43 | return context; 44 | } 45 | 46 | @Autowired 47 | private ProducerTemplate producerTemplate; 48 | 49 | @Autowired 50 | private ConsumerTemplate consumerTemplate; 51 | 52 | @Override 53 | protected RouteBuilder createRouteBuilder(){ 54 | return new SimpleCamelRoute(); 55 | } 56 | 57 | @Autowired 58 | Environment environment; 59 | 60 | @Before 61 | public void setUp(){ 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencyByCountryResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCurrencyByCountryResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCurrencyByCountryResult" 33 | }) 34 | @XmlRootElement(name = "GetCurrencyByCountryResponse") 35 | public class GetCurrencyByCountryResponse { 36 | 37 | @XmlElement(name = "GetCurrencyByCountryResult") 38 | protected String getCurrencyByCountryResult; 39 | 40 | /** 41 | * Gets the value of the getCurrencyByCountryResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCurrencyByCountryResult() { 49 | return getCurrencyByCountryResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCurrencyByCountryResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCurrencyByCountryResult(String value) { 61 | this.getCurrencyByCountryResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCountryByCountryCodeResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCountryByCountryCodeResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCountryByCountryCodeResult" 33 | }) 34 | @XmlRootElement(name = "GetCountryByCountryCodeResponse") 35 | public class GetCountryByCountryCodeResponse { 36 | 37 | @XmlElement(name = "GetCountryByCountryCodeResult") 38 | protected String getCountryByCountryCodeResult; 39 | 40 | /** 41 | * Gets the value of the getCountryByCountryCodeResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCountryByCountryCodeResult() { 49 | return getCountryByCountryCodeResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCountryByCountryCodeResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCountryByCountryCodeResult(String value) { 61 | this.getCountryByCountryCodeResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCountryByCurrencyCodeResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCountryByCurrencyCodeResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCountryByCurrencyCodeResult" 33 | }) 34 | @XmlRootElement(name = "GetCountryByCurrencyCodeResponse") 35 | public class GetCountryByCurrencyCodeResponse { 36 | 37 | @XmlElement(name = "GetCountryByCurrencyCodeResult") 38 | protected String getCountryByCurrencyCodeResult; 39 | 40 | /** 41 | * Gets the value of the getCountryByCurrencyCodeResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCountryByCurrencyCodeResult() { 49 | return getCountryByCurrencyCodeResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCountryByCurrencyCodeResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCountryByCurrencyCodeResult(String value) { 61 | this.getCountryByCurrencyCodeResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetCurrencyCodeByCurrencyNameResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetCurrencyCodeByCurrencyNameResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getCurrencyCodeByCurrencyNameResult" 33 | }) 34 | @XmlRootElement(name = "GetCurrencyCodeByCurrencyNameResponse") 35 | public class GetCurrencyCodeByCurrencyNameResponse { 36 | 37 | @XmlElement(name = "GetCurrencyCodeByCurrencyNameResult") 38 | protected String getCurrencyCodeByCurrencyNameResult; 39 | 40 | /** 41 | * Gets the value of the getCurrencyCodeByCurrencyNameResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetCurrencyCodeByCurrencyNameResult() { 49 | return getCurrencyCodeByCurrencyNameResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getCurrencyCodeByCurrencyNameResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetCurrencyCodeByCurrencyNameResult(String value) { 61 | this.getCurrencyCodeByCurrencyNameResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/main/java/net/webservicex/GetISOCountryCodeByCountyNameResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package net.webservicex; 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import javax.xml.bind.annotation.XmlRootElement; 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | 11 | /** 12 | *

Java class for anonymous complex type. 13 | * 14 | *

The following schema fragment specifies the expected content contained within this class. 15 | * 16 | *

17 |  * <complexType>
18 |  *   <complexContent>
19 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
20 |  *       <sequence>
21 |  *         <element name="GetISOCountryCodeByCountyNameResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22 |  *       </sequence>
23 |  *     </restriction>
24 |  *   </complexContent>
25 |  * </complexType>
26 |  * 
27 | * 28 | * 29 | */ 30 | @XmlAccessorType(XmlAccessType.FIELD) 31 | @XmlType(name = "", propOrder = { 32 | "getISOCountryCodeByCountyNameResult" 33 | }) 34 | @XmlRootElement(name = "GetISOCountryCodeByCountyNameResponse") 35 | public class GetISOCountryCodeByCountyNameResponse { 36 | 37 | @XmlElement(name = "GetISOCountryCodeByCountyNameResult") 38 | protected String getISOCountryCodeByCountyNameResult; 39 | 40 | /** 41 | * Gets the value of the getISOCountryCodeByCountyNameResult property. 42 | * 43 | * @return 44 | * possible object is 45 | * {@link String } 46 | * 47 | */ 48 | public String getGetISOCountryCodeByCountyNameResult() { 49 | return getISOCountryCodeByCountyNameResult; 50 | } 51 | 52 | /** 53 | * Sets the value of the getISOCountryCodeByCountyNameResult property. 54 | * 55 | * @param value 56 | * allowed object is 57 | * {@link String } 58 | * 59 | */ 60 | public void setGetISOCountryCodeByCountyNameResult(String value) { 61 | this.getISOCountryCodeByCountyNameResult = value; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/routes/RestCamelRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.exception.DataException; 5 | import com.learncamel.processor.BuildSQLProcessor; 6 | import com.learncamel.processor.CountrySelectProcessor; 7 | import org.apache.camel.Exchange; 8 | import org.apache.camel.LoggingLevel; 9 | import org.apache.camel.builder.RouteBuilder; 10 | import org.postgresql.util.PSQLException; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.core.env.Environment; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * Created by Dilip on 1/3/18. 17 | */ 18 | @Component 19 | public class RestCamelRoute extends RouteBuilder{ 20 | 21 | @Autowired 22 | Environment environment; 23 | 24 | 25 | 26 | @Autowired 27 | MailProcessor mailProcessor; 28 | 29 | @Autowired 30 | CountrySelectProcessor countrySelect; 31 | 32 | 33 | @Override 34 | public void configure() throws Exception { 35 | 36 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 37 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 38 | 39 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 40 | .process(mailProcessor); 41 | 42 | from("{{fromRoute}}") 43 | .process(countrySelect) 44 | .setHeader(Exchange.HTTP_METHOD, constant("GET")) 45 | .setHeader(Exchange.HTTP_URI, simple("http://restcountries.eu/rest/v2/alpha/${header.countryId}")) 46 | .log("Headers are : ${headers}") 47 | .to("https://restcountries.eu/rest/v2/alpha/us").convertBodyTo(String.class) 48 | .log("The REST API resopnse is : ${body}") 49 | .removeHeader(Exchange.HTTP_URI) 50 | .setHeader(Exchange.HTTP_METHOD, constant("POST")) 51 | .to("{{toRoute}}"); 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/routes/RestCamelRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.exception.DataException; 5 | import com.learncamel.processor.BuildSQLProcessor; 6 | import com.learncamel.processor.CountrySelectProcessor; 7 | import org.apache.camel.Exchange; 8 | import org.apache.camel.LoggingLevel; 9 | import org.apache.camel.builder.RouteBuilder; 10 | import org.postgresql.util.PSQLException; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.core.env.Environment; 13 | import org.springframework.stereotype.Component; 14 | 15 | /** 16 | * Created by Dilip on 1/3/18. 17 | */ 18 | @Component 19 | public class RestCamelRoute extends RouteBuilder{ 20 | 21 | @Autowired 22 | Environment environment; 23 | 24 | 25 | 26 | @Autowired 27 | MailProcessor mailProcessor; 28 | 29 | @Autowired 30 | CountrySelectProcessor countrySelect; 31 | 32 | 33 | @Override 34 | public void configure() throws Exception { 35 | 36 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 37 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 38 | 39 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 40 | .process(mailProcessor); 41 | 42 | from("{{fromRoute}}") 43 | .process(countrySelect) 44 | .setHeader(Exchange.HTTP_METHOD, constant("GET")) 45 | .setHeader(Exchange.HTTP_URI, simple("http://restcountries.eu/rest/v2/alpha/${header.countryId}")) 46 | .log("Headers are : ${headers}") 47 | .to("https://restcountries.eu/rest/v2/alpha/us").convertBodyTo(String.class) 48 | .log("The REST API resopnse is : ${body}") 49 | .removeHeader(Exchange.HTTP_URI) 50 | .setHeader(Exchange.HTTP_METHOD, constant("POST")) 51 | .to("{{toRoute}}"); 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/test/java/com/learncamel/routes/SimpleCamelRouteTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import org.apache.camel.CamelContext; 4 | import org.apache.camel.ConsumerTemplate; 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.ProducerTemplate; 7 | import org.apache.camel.builder.RouteBuilder; 8 | import org.apache.camel.test.junit4.CamelTestSupport; 9 | import org.apache.camel.test.spring.CamelSpringBootRunner; 10 | import org.apache.camel.test.spring.DisableJmx; 11 | import org.apache.commons.io.FileUtils; 12 | import org.junit.AfterClass; 13 | import org.junit.Before; 14 | import org.junit.BeforeClass; 15 | import org.junit.Test; 16 | import org.junit.runner.RunWith; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | import org.springframework.core.env.Environment; 20 | import org.springframework.test.annotation.DirtiesContext; 21 | import org.springframework.test.context.ActiveProfiles; 22 | 23 | import java.io.File; 24 | import java.io.IOException; 25 | import java.nio.file.Files; 26 | import java.nio.file.Paths; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | import static org.junit.Assert.assertNotNull; 30 | import static org.junit.Assert.assertTrue; 31 | 32 | /** 33 | * Created by Dilip on 1/4/18. 34 | */ 35 | @ActiveProfiles("dev") 36 | @RunWith(CamelSpringBootRunner.class) 37 | @SpringBootTest 38 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 39 | public class SimpleCamelRouteTest extends CamelTestSupport { 40 | 41 | @Autowired 42 | private CamelContext context; 43 | 44 | @Autowired 45 | protected CamelContext createCamelContext() { 46 | return context; 47 | } 48 | 49 | @Autowired 50 | private ProducerTemplate producerTemplate; 51 | 52 | @Autowired 53 | private ConsumerTemplate consumerTemplate; 54 | 55 | @Override 56 | protected RouteBuilder createRouteBuilder(){ 57 | return new SimpleCamelRoute(); 58 | } 59 | 60 | @Autowired 61 | Environment environment; 62 | 63 | @Before 64 | public void setUp(){ 65 | 66 | } 67 | 68 | @Test 69 | public void simpleTestCase(){ 70 | assertTrue(true); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/java/com/learncamel/routes/CountryRestRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.domain.Country; 5 | import com.learncamel.exception.DataException; 6 | import com.learncamel.processor.BuildSQLProcessor; 7 | import com.learncamel.service.CountryService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.camel.LoggingLevel; 10 | import org.apache.camel.builder.RouteBuilder; 11 | import org.apache.camel.component.gson.GsonDataFormat; 12 | import org.postgresql.util.PSQLException; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.beans.factory.annotation.Qualifier; 15 | import org.springframework.stereotype.Component; 16 | 17 | import javax.sql.DataSource; 18 | import java.util.ArrayList; 19 | 20 | @Component 21 | @Slf4j 22 | public class CountryRestRoute extends RouteBuilder { 23 | 24 | 25 | @Autowired 26 | CountryService countryService; 27 | 28 | @Qualifier("dataSource") 29 | @Autowired 30 | DataSource dataSource; 31 | 32 | @Autowired 33 | BuildSQLProcessor buildSQLProcessor; 34 | 35 | @Autowired 36 | MailProcessor mailProcessor; 37 | 38 | @Override 39 | public void configure() throws Exception { 40 | 41 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 42 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 43 | 44 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 45 | .process(mailProcessor); 46 | 47 | GsonDataFormat countryDataFormat = new GsonDataFormat(Country.class); 48 | 49 | log.info("Inside the Country Rest Route"); 50 | 51 | from("restlet:http://localhost:8081/getCurrentTime?restletMethods=GET") 52 | .bean("countryService", "getCurrentDateTime()"); 53 | 54 | from("restlet:http://localhost:8081/country?restletMethods=POST").routeId("countryPostRoute") 55 | .log("Recived Body is ${body}") 56 | .convertBodyTo(String.class) 57 | .unmarshal(countryDataFormat) 58 | .process(buildSQLProcessor) 59 | .to("{{dbNode}}") 60 | .to("{{selectNode}}") 61 | .convertBodyTo(String.class) 62 | .log("Inserted Country is : ${body}" ); 63 | 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TeachApacheCamel-Spring-Boot 2 | 3 | - This codebase has the complete code for this course 4 | 5 | 6 | ## Run the app in Java 11 ? 7 | 8 | - Go to the below link which has the complete working code with **java11**. 9 | 10 | - [camel-springboot-course-java11](https://github.com/dilipsundarraj1/TeachApacheCamel-Spring-Boot/tree/java11) 11 | 12 | ## Code Changes to Run in Java 11 13 | 14 | - Follow the steps mentioned below to run the app in **Java 11**. 15 | 16 | ### Pom.xml 17 | 18 | - Update the Java version to 11 19 | 20 | ```$xslt 21 | 11 22 | 1.18.4 23 | ``` 24 | 25 | - Add the below latest **lombok** dependency. 26 | 27 | ``` 28 | 29 | 30 | org.projectlombok 31 | lombok 32 | ${lombok.version} 33 | 34 | ``` 35 | 36 | - Add the **JAXB** related dependecies. 37 | 38 | ``` 39 | 40 | 41 | javax.xml.bind 42 | jaxb-api 43 | 2.2.11 44 | 45 | 46 | com.sun.xml.bind 47 | jaxb-core 48 | 2.2.11 49 | 50 | 51 | com.sun.xml.bind 52 | jaxb-impl 53 | 2.2.11 54 | 55 | 56 | javax.activation 57 | javax.activation-api 58 | 1.2.0 59 | 60 | 61 | ``` 62 | 63 | - Add the below plugin to support maven in Java 11. 64 | 65 | ``` 66 | 67 | org.apache.maven.plugins 68 | maven-compiler-plugin 69 | 3.7.0 70 | 71 | 11 72 | 11 73 | 74 | 11 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-jar-plugin 81 | 3.0.2 82 | 83 | ``` 84 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/main/java/com/learncamel/routes/CountryRestRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.domain.Country; 5 | import com.learncamel.exception.DataException; 6 | import com.learncamel.processor.BuildSQLProcessor; 7 | import com.learncamel.service.CountryService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.camel.LoggingLevel; 10 | import org.apache.camel.builder.RouteBuilder; 11 | import org.apache.camel.component.gson.GsonDataFormat; 12 | import org.postgresql.util.PSQLException; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.beans.factory.annotation.Qualifier; 15 | import org.springframework.stereotype.Component; 16 | 17 | import javax.sql.DataSource; 18 | import java.util.ArrayList; 19 | 20 | @Component 21 | @Slf4j 22 | public class CountryRestRoute extends RouteBuilder { 23 | 24 | 25 | @Autowired 26 | CountryService countryService; 27 | 28 | @Qualifier("dataSource") 29 | @Autowired 30 | DataSource dataSource; 31 | 32 | @Autowired 33 | BuildSQLProcessor buildSQLProcessor; 34 | 35 | @Autowired 36 | MailProcessor mailProcessor; 37 | 38 | @Override 39 | public void configure() throws Exception { 40 | 41 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 42 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 43 | 44 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 45 | .process(mailProcessor); 46 | 47 | GsonDataFormat countryDataFormat = new GsonDataFormat(Country.class); 48 | 49 | log.info("Inside the Country Rest Route"); 50 | 51 | from("restlet:http://localhost:8081/getCurrentTime?restletMethods=GET") 52 | .bean("countryService", "getCurrentDateTime()"); 53 | 54 | from("restlet:http://localhost:8081/country?restletMethods=POST").routeId("countryPostRoute") 55 | .log("Recived Body is ${body}") 56 | .convertBodyTo(String.class) 57 | .unmarshal(countryDataFormat) 58 | .process(buildSQLProcessor) 59 | .to("{{dbNode}}") 60 | .to("{{selectNode}}") 61 | .convertBodyTo(String.class) 62 | .log("Inserted Country is : ${body}" ); 63 | 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/main/java/com/learncamel/routes/ActiveMQRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.domain.Item; 5 | import com.learncamel.exception.DataException; 6 | import com.learncamel.processor.BuildSQLProcessor; 7 | import com.learncamel.processor.ValidateDataProcessor; 8 | import org.apache.camel.LoggingLevel; 9 | import org.apache.camel.Predicate; 10 | import org.apache.camel.builder.RouteBuilder; 11 | import org.apache.camel.component.gson.GsonDataFormat; 12 | import org.postgresql.util.PSQLException; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.beans.factory.annotation.Qualifier; 15 | import org.springframework.core.env.Environment; 16 | import org.springframework.stereotype.Component; 17 | 18 | import javax.sql.DataSource; 19 | 20 | /** 21 | * Created by Dilip on 1/3/18. 22 | */ 23 | @Component 24 | public class ActiveMQRoute extends RouteBuilder{ 25 | 26 | @Autowired 27 | Environment environment; 28 | 29 | @Qualifier("dataSource") 30 | @Autowired 31 | DataSource dataSource; 32 | 33 | @Autowired 34 | MailProcessor mailProcessor; 35 | 36 | @Autowired 37 | ValidateDataProcessor validateProcessor; 38 | 39 | @Autowired 40 | BuildSQLProcessor sqlProcessor; 41 | 42 | 43 | 44 | @Override 45 | public void configure() throws Exception { 46 | 47 | Predicate isNotMock = header("env").isNotEqualTo("mock"); 48 | 49 | GsonDataFormat itemFormat = new GsonDataFormat(Item.class); 50 | 51 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 52 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 53 | 54 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 55 | .choice() 56 | .when(isNotMock) 57 | .process(mailProcessor) 58 | .end() 59 | .log("Body in Exception Block is ${body}") 60 | .setBody(constant(body())) 61 | .to("{{errorRoute}}"); 62 | 63 | 64 | 65 | from("{{fromRoute}}") 66 | .log("Read Message from ActiveMQ ${body}") 67 | .unmarshal(itemFormat) 68 | .log("UnMarshaled Message is ${body}") 69 | .process(validateProcessor) 70 | .process(sqlProcessor) 71 | .to("{{toRoute}}") 72 | .to("{{selectNode}}") 73 | .log("Result from the db table is ${body}");; 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/main/java/com/learncamel/routes/KafkaRoute.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.alert.MailProcessor; 4 | import com.learncamel.domain.Item; 5 | import com.learncamel.exception.DataException; 6 | import com.learncamel.processor.BuildSQLProcessor; 7 | import com.learncamel.processor.ValidateDataProcessor; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.camel.LoggingLevel; 10 | import org.apache.camel.Predicate; 11 | import org.apache.camel.builder.RouteBuilder; 12 | import org.apache.camel.component.gson.GsonDataFormat; 13 | import org.postgresql.util.PSQLException; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.beans.factory.annotation.Qualifier; 16 | import org.springframework.core.env.Environment; 17 | import org.springframework.stereotype.Component; 18 | 19 | import javax.sql.DataSource; 20 | 21 | /** 22 | * Created by Dilip on 1/3/18. 23 | */ 24 | @Component 25 | @Slf4j 26 | public class KafkaRoute extends RouteBuilder{ 27 | 28 | @Autowired 29 | Environment environment; 30 | 31 | @Qualifier("dataSource") 32 | @Autowired 33 | DataSource dataSource; 34 | 35 | @Autowired 36 | BuildSQLProcessor sqlProcessor; 37 | 38 | @Autowired 39 | MailProcessor mailProcessor; 40 | 41 | @Autowired 42 | ValidateDataProcessor validateProcessor; 43 | 44 | @Override 45 | public void configure() throws Exception { 46 | 47 | Predicate isNotMock = header("env").isNotEqualTo("mock"); 48 | 49 | GsonDataFormat itemFormat = new GsonDataFormat(Item.class); 50 | 51 | onException(PSQLException.class).log(LoggingLevel.ERROR,"PSQLException in the route ${body}") 52 | .maximumRedeliveries(3).redeliveryDelay(3000).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.ERROR); 53 | 54 | onException(DataException.class,RuntimeException.class).log(LoggingLevel.ERROR, "DataException in the route ${body}") 55 | .choice() 56 | .when(isNotMock) 57 | .process(mailProcessor) 58 | .end() 59 | .log("Body in Exception Block is ${body}"); 60 | // .to("{{errorRoute}}"); 61 | 62 | 63 | 64 | from("{{fromRoute}}") 65 | .log("Read Message from Kafka ${body} , parition : ${headers[kafka.PARTITION]} , offset : ${headers[kafka.OFFSET]}") 66 | .unmarshal(itemFormat) 67 | .log("UnMarshaled Message is ${body}") 68 | .process(validateProcessor) 69 | .process(sqlProcessor) 70 | /*.to("{{toRoute}}") 71 | .to("{{selectNode}}") 72 | */.log("Result from the db table is ${body}"); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/test/java/com/learncamel/routes/SoapCamelRouteTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import org.apache.camel.CamelContext; 4 | import org.apache.camel.ConsumerTemplate; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.component.spring.ws.SpringWebserviceConstants; 8 | import org.apache.camel.test.junit4.CamelTestSupport; 9 | import org.apache.camel.test.spring.CamelSpringBootRunner; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.core.env.Environment; 16 | import org.springframework.test.annotation.DirtiesContext; 17 | import org.springframework.test.context.ActiveProfiles; 18 | 19 | import javax.xml.transform.dom.DOMSource; 20 | 21 | import static org.junit.Assert.assertEquals; 22 | import static org.junit.Assert.assertNotNull; 23 | import static org.junit.Assert.assertTrue; 24 | 25 | /** 26 | * Created by Dilip on 1/4/18. 27 | */ 28 | @ActiveProfiles("dev") 29 | @RunWith(CamelSpringBootRunner.class) 30 | @SpringBootTest 31 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 32 | public class SoapCamelRouteTest extends CamelTestSupport { 33 | 34 | @Autowired 35 | private CamelContext context; 36 | 37 | @Autowired 38 | protected CamelContext createCamelContext() { 39 | return context; 40 | } 41 | 42 | @Autowired 43 | private ProducerTemplate producerTemplate; 44 | 45 | @Autowired 46 | private ConsumerTemplate consumerTemplate; 47 | 48 | /* @Override 49 | protected RouteBuilder createRouteBuilder(){ 50 | return new SoapCamelRoute(); 51 | } 52 | */ 53 | @Autowired 54 | Environment environment; 55 | 56 | @Before 57 | public void setUp(){ 58 | 59 | //System.setProperty("fromRoute", "direct:input"); 60 | 61 | } 62 | 63 | private String getCountrybyCountryCodeRequest = "\n" + 64 | " GB\n" + 65 | " "; 66 | 67 | private String countryWebServiceUri = "http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"; 68 | 69 | 70 | 71 | @Test 72 | public void countryNameByCountryCode() throws Exception { 73 | producerTemplate.sendBodyAndHeader(environment.getProperty("toRoute"), getCountrybyCountryCodeRequest, 74 | SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, countryWebServiceUri); 75 | 76 | 77 | // assertTrue(result.contains("Great Britain")); 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/test/java/com/learncamel/routes/ActiveMQRouteTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.camel.*; 5 | import org.apache.camel.builder.RouteBuilder; 6 | import org.apache.camel.test.junit4.CamelTestSupport; 7 | import org.apache.camel.test.spring.CamelSpringBootRunner; 8 | import org.apache.commons.io.FileUtils; 9 | import org.junit.AfterClass; 10 | import org.junit.Before; 11 | import org.junit.BeforeClass; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.test.context.SpringBootTest; 16 | import org.springframework.core.env.Environment; 17 | import org.springframework.test.annotation.DirtiesContext; 18 | import org.springframework.test.context.ActiveProfiles; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.nio.file.Files; 23 | import java.nio.file.Paths; 24 | import java.util.ArrayList; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | import static org.junit.Assert.assertNotNull; 28 | import static org.junit.Assert.assertTrue; 29 | 30 | /** 31 | * Created by Dilip on 1/4/18. 32 | */ 33 | @ActiveProfiles("dev") 34 | @RunWith(CamelSpringBootRunner.class) 35 | @SpringBootTest 36 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 37 | @Slf4j 38 | public class ActiveMQRouteTest extends CamelTestSupport{ 39 | 40 | 41 | @Autowired 42 | private CamelContext context; 43 | 44 | @Autowired 45 | protected CamelContext createCamelContext() { 46 | return context; 47 | } 48 | 49 | @Autowired 50 | private ProducerTemplate producerTemplate; 51 | 52 | @Autowired 53 | private ConsumerTemplate consumerTemplate; 54 | 55 | @Override 56 | protected RouteBuilder createRouteBuilder(){ 57 | return new ActiveMQRoute(); 58 | } 59 | 60 | @Autowired 61 | Environment environment; 62 | 63 | @Before 64 | public void setUp(){ 65 | 66 | } 67 | 68 | @Test 69 | public void activeMQRoute(){ 70 | String input = "{\"transactionType\":\"ADD\", \"sku\":\"200\", \"itemDescription\":\"SamsungTV\", \"price\":\"500\"}"; 71 | 72 | ArrayList response = (ArrayList) producerTemplate.requestBody("activemq:inputItemQueue",input); 73 | System.out.println("Response is : " + response); 74 | assertNotNull(response); 75 | 76 | } 77 | 78 | @Test(expected = CamelExecutionException.class) 79 | public void activeMQRoute_Exception(){ 80 | String input = "{\"transactionType\":\"ADD\", \"sku\":\"\", \"itemDescription\":\"SamsungTV\", \"price\":\"500\"}"; 81 | 82 | String response = (String) producerTemplate.requestBody("activemq:inputItemQueue",input); 83 | 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /learncamel-spring-boot/src/test/java/com/learncamel/routes/HealthRouteMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ConsumerTemplate; 6 | import org.apache.camel.Exchange; 7 | import org.apache.camel.ProducerTemplate; 8 | import org.apache.camel.builder.RouteBuilder; 9 | import org.apache.camel.component.mock.MockEndpoint; 10 | import org.apache.camel.test.junit4.CamelTestSupport; 11 | import org.apache.camel.test.spring.CamelSpringBootRunner; 12 | import org.junit.Before; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.boot.test.context.SpringBootTest; 17 | import org.springframework.core.env.Environment; 18 | import org.springframework.test.annotation.DirtiesContext; 19 | import org.springframework.test.context.ActiveProfiles; 20 | 21 | /** 22 | * Created by Dilip on 2/10/18. 23 | */ 24 | @ActiveProfiles("mock") 25 | @RunWith(CamelSpringBootRunner.class) 26 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 27 | @SpringBootTest 28 | public class HealthRouteMockTest extends CamelTestSupport { 29 | 30 | @Autowired 31 | protected RouteBuilder createRouteBuilder() { 32 | return new HealthCheckRoute(); 33 | } 34 | 35 | @Autowired 36 | private ProducerTemplate producerTemplate; 37 | 38 | @Autowired 39 | private ConsumerTemplate consumerTemplate; 40 | 41 | @Autowired 42 | private CamelContext context; 43 | 44 | @Autowired 45 | Environment environment; 46 | 47 | @Autowired 48 | protected CamelContext createCamelContext() { 49 | return context; 50 | } 51 | 52 | @Autowired 53 | HealthCheckProcessor healthCheckProcessor; 54 | 55 | @Before 56 | public void setUp(){ 57 | 58 | // System.setProperty("healthRoute","direct:health"); 59 | } 60 | 61 | @Test 62 | public void healthRouteTest() throws InterruptedException { 63 | 64 | String input ="{\"status\":\"UP\",\"camel\":{\"status\":\"DOWN\",\"name\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:timerRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192335450112,\"threshold\":10485760},\"db\":{\"status\":\"UP\",\"database\":\"PostgreSQL\",\"hello\":1}}"; 65 | 66 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"),input, 67 | "env" , environment.getProperty("spring.profiles.active")); 68 | 69 | //assertMockEndpointsSatisfied(); 70 | String expectedMessage = "camel component in the route is Down\n"; 71 | assertEquals(expectedMessage,response); 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/test/java/com/learncamel/routes/HealthCheckMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | /** 19 | * Created by Dilip on 2/11/18. 20 | */ 21 | @ActiveProfiles("mock") 22 | @RunWith(CamelSpringBootRunner.class) 23 | @SpringBootTest 24 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 25 | public class HealthCheckMockTest extends CamelTestSupport{ 26 | 27 | @Override 28 | public RouteBuilder createRouteBuilder(){ 29 | return new HealthCheckRoute(); 30 | } 31 | 32 | @Autowired 33 | CamelContext context; 34 | 35 | @Autowired 36 | Environment environment; 37 | 38 | @Autowired 39 | protected CamelContext createCamelContext(){ 40 | 41 | return context; 42 | } 43 | 44 | @Autowired 45 | ProducerTemplate producerTemplate; 46 | 47 | @Autowired 48 | HealthCheckProcessor healthCheckProcessor; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | 54 | } 55 | 56 | 57 | 58 | @Test 59 | public void healthRouteTest(){ 60 | 61 | String input =" {\"status\":\"DOWN\",\"camel\":{\"status\":\"UP\",\"name\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:mainRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192566607872,\"threshold\":10485760},\"db\":{\"status\":\"DOWN\",\"error\":\"org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to localhost:54321 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.\"}}"; 62 | 63 | 64 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"), input,"env", environment.getProperty("spring.profiles.active")); 65 | 66 | System.out.println("Response : " + response); 67 | 68 | String expectedMessae = "status component in the route is Down\n" + 69 | "db component in the route is Down\n"; 70 | 71 | assertEquals(expectedMessae,response); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /activemq-learncamel-spring-boot/src/test/java/com/learncamel/routes/HealthCheckMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | /** 19 | * Created by Dilip on 2/11/18. 20 | */ 21 | @ActiveProfiles("mock") 22 | @RunWith(CamelSpringBootRunner.class) 23 | @SpringBootTest 24 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 25 | public class HealthCheckMockTest extends CamelTestSupport{ 26 | 27 | @Override 28 | public RouteBuilder createRouteBuilder(){ 29 | return new HealthCheckRoute(); 30 | } 31 | 32 | @Autowired 33 | CamelContext context; 34 | 35 | @Autowired 36 | Environment environment; 37 | 38 | @Autowired 39 | protected CamelContext createCamelContext(){ 40 | 41 | return context; 42 | } 43 | 44 | @Autowired 45 | ProducerTemplate producerTemplate; 46 | 47 | @Autowired 48 | HealthCheckProcessor healthCheckProcessor; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | 54 | } 55 | 56 | 57 | 58 | @Test 59 | public void healthRouteTest(){ 60 | 61 | String input =" {\"status\":\"DOWN\",\"camel\":{\"status\":\"UP\",\"name\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:mainRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192566607872,\"threshold\":10485760},\"db\":{\"status\":\"DOWN\",\"error\":\"org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to localhost:54321 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.\"}}"; 62 | 63 | 64 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"), input,"env", environment.getProperty("spring.profiles.active")); 65 | 66 | System.out.println("Response : " + response); 67 | 68 | String expectedMessae = "status component in the route is Down\n" + 69 | "db component in the route is Down\n"; 70 | 71 | assertEquals(expectedMessae,response); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/test/java/com/learncamel/routes/HealthCheckMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | /** 19 | * Created by Dilip on 2/11/18. 20 | */ 21 | @ActiveProfiles("mock") 22 | @RunWith(CamelSpringBootRunner.class) 23 | @SpringBootTest 24 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 25 | public class HealthCheckMockTest extends CamelTestSupport{ 26 | 27 | @Override 28 | public RouteBuilder createRouteBuilder(){ 29 | return new HealthCheckRoute(); 30 | } 31 | 32 | @Autowired 33 | CamelContext context; 34 | 35 | @Autowired 36 | Environment environment; 37 | 38 | @Autowired 39 | protected CamelContext createCamelContext(){ 40 | 41 | return context; 42 | } 43 | 44 | @Autowired 45 | ProducerTemplate producerTemplate; 46 | 47 | @Autowired 48 | HealthCheckProcessor healthCheckProcessor; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | 54 | } 55 | 56 | 57 | 58 | @Test 59 | public void healthRouteTest(){ 60 | 61 | String input =" {\"status\":\"DOWN\",\"camel\":{\"status\":\"UP\",\"name\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:mainRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192566607872,\"threshold\":10485760},\"db\":{\"status\":\"DOWN\",\"error\":\"org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to localhost:54321 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.\"}}"; 62 | 63 | 64 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"), input,"env", environment.getProperty("spring.profiles.active")); 65 | 66 | System.out.println("Response : " + response); 67 | 68 | String expectedMessae = "status component in the route is Down\n" + 69 | "db component in the route is Down\n"; 70 | 71 | assertEquals(expectedMessae,response); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/test/java/com/learncamel/routes/HealthCheckMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | /** 19 | * Created by Dilip on 2/11/18. 20 | */ 21 | @ActiveProfiles("mock") 22 | @RunWith(CamelSpringBootRunner.class) 23 | @SpringBootTest 24 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 25 | public class HealthCheckMockTest extends CamelTestSupport{ 26 | 27 | @Override 28 | public RouteBuilder createRouteBuilder(){ 29 | return new HealthCheckRoute(); 30 | } 31 | 32 | @Autowired 33 | CamelContext context; 34 | 35 | @Autowired 36 | Environment environment; 37 | 38 | @Autowired 39 | protected CamelContext createCamelContext(){ 40 | 41 | return context; 42 | } 43 | 44 | @Autowired 45 | ProducerTemplate producerTemplate; 46 | 47 | @Autowired 48 | HealthCheckProcessor healthCheckProcessor; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | 54 | } 55 | 56 | 57 | 58 | @Test 59 | public void healthRouteTest(){ 60 | 61 | String input =" {\"status\":\"DOWN\",\"camel\":{\"status\":\"UP\",\"name\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:mainRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192566607872,\"threshold\":10485760},\"db\":{\"status\":\"DOWN\",\"error\":\"org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to localhost:54321 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.\"}}"; 62 | 63 | 64 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"), input,"env", environment.getProperty("spring.profiles.active")); 65 | 66 | System.out.println("Response : " + response); 67 | 68 | String expectedMessae = "status component in the route is Down\n" + 69 | "db component in the route is Down\n"; 70 | 71 | assertEquals(expectedMessae,response); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /soap-springws-learncamel-spring-boot/src/test/java/com/learncamel/routes/HealthCheckMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | /** 19 | * Created by Dilip on 2/11/18. 20 | */ 21 | @ActiveProfiles("mock") 22 | @RunWith(CamelSpringBootRunner.class) 23 | @SpringBootTest 24 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 25 | public class HealthCheckMockTest extends CamelTestSupport{ 26 | 27 | @Override 28 | public RouteBuilder createRouteBuilder(){ 29 | return new HealthCheckRoute(); 30 | } 31 | 32 | @Autowired 33 | CamelContext context; 34 | 35 | @Autowired 36 | Environment environment; 37 | 38 | @Autowired 39 | protected CamelContext createCamelContext(){ 40 | 41 | return context; 42 | } 43 | 44 | @Autowired 45 | ProducerTemplate producerTemplate; 46 | 47 | @Autowired 48 | HealthCheckProcessor healthCheckProcessor; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | 54 | } 55 | 56 | 57 | 58 | @Test 59 | public void healthRouteTest(){ 60 | 61 | String input =" {\"status\":\"DOWN\",\"camel\":{\"status\":\"UP\",\"sName\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:mainRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192566607872,\"threshold\":10485760},\"db\":{\"status\":\"DOWN\",\"error\":\"org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to localhost:54321 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.\"}}"; 62 | 63 | 64 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"), input,"env", environment.getProperty("spring.profiles.active")); 65 | 66 | System.out.println("Response : " + response); 67 | 68 | String expectedMessae = "status component in the route is Down\n" + 69 | "db component in the route is Down\n"; 70 | 71 | assertEquals(expectedMessae,response); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/test/java/com/learncamel/routes/HealthCheckMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.processor.HealthCheckProcessor; 4 | import org.apache.camel.CamelContext; 5 | import org.apache.camel.ProducerTemplate; 6 | import org.apache.camel.builder.RouteBuilder; 7 | import org.apache.camel.test.junit4.CamelTestSupport; 8 | import org.apache.camel.test.spring.CamelSpringBootRunner; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.core.env.Environment; 15 | import org.springframework.test.annotation.DirtiesContext; 16 | import org.springframework.test.context.ActiveProfiles; 17 | 18 | /** 19 | * Created by Dilip on 2/11/18. 20 | */ 21 | @ActiveProfiles("mock") 22 | @RunWith(CamelSpringBootRunner.class) 23 | @SpringBootTest 24 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 25 | public class HealthCheckMockTest extends CamelTestSupport{ 26 | 27 | @Override 28 | public RouteBuilder createRouteBuilder(){ 29 | return new HealthCheckRoute(); 30 | } 31 | 32 | @Autowired 33 | CamelContext context; 34 | 35 | @Autowired 36 | Environment environment; 37 | 38 | @Autowired 39 | protected CamelContext createCamelContext(){ 40 | 41 | return context; 42 | } 43 | 44 | @Autowired 45 | ProducerTemplate producerTemplate; 46 | 47 | @Autowired 48 | HealthCheckProcessor healthCheckProcessor; 49 | 50 | @Before 51 | public void setUp(){ 52 | 53 | 54 | } 55 | 56 | 57 | 58 | @Test 59 | public void healthRouteTest(){ 60 | 61 | String input =" {\"status\":\"DOWN\",\"camel\":{\"status\":\"UP\",\"name\":\"camel-1\",\"version\":\"2.20.1\",\"contextStatus\":\"Started\"},\"camel-health-checks\":{\"status\":\"UP\",\"route:healthRoute\":\"UP\",\"route:mainRoute\":\"UP\"},\"mail\":{\"status\":\"UP\",\"location\":\"smtp.gmail.com:587\"},\"diskSpace\":{\"status\":\"UP\",\"total\":499071844352,\"free\":192566607872,\"threshold\":10485760},\"db\":{\"status\":\"DOWN\",\"error\":\"org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to localhost:54321 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.\"}}"; 62 | 63 | 64 | String response = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("healthRoute"), input,"env", environment.getProperty("spring.profiles.active")); 65 | 66 | System.out.println("Response : " + response); 67 | 68 | String expectedMessae = "status component in the route is Down\n" + 69 | "db component in the route is Down\n"; 70 | 71 | assertEquals(expectedMessae,response); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot-with-mockito/src/test/java/com/learncamel/routes/service/CountriesMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes.service; 2 | 3 | import com.learncamel.service.CountryService; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.mockito.InjectMocks; 8 | import org.mockito.Mock; 9 | import org.mockito.runners.MockitoJUnitRunner; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.web.client.RestTemplate; 14 | 15 | import static org.junit.Assert.assertNotNull; 16 | import static org.mockito.Mockito.when; 17 | 18 | @RunWith(MockitoJUnitRunner.class) 19 | public class CountriesMockTest { 20 | 21 | @InjectMocks 22 | CountryService countryService; 23 | 24 | @Mock 25 | RestTemplate restTemplate; 26 | 27 | String countryCode,countriesUrl; 28 | 29 | @Before 30 | public void setUp(){ 31 | countryCode ="us"; 32 | countriesUrl = "https://restcountries.eu/rest/v2/alpha/".concat(countryCode); 33 | } 34 | 35 | 36 | @Test 37 | public void getCountryDetails(){ 38 | 39 | String responseBody = "{\"name\":\"United States of America\",\"topLevelDomain\":[\".us\"],\"alpha2Code\":\"US\",\"alpha3Code\":\"USA\",\"callingCodes\":[\"1\"],\"capital\":\"Washington, D.C.\",\"altSpellings\":[\"US\",\"USA\",\"United States of America\"],\"region\":\"Americas\",\"subregion\":\"Northern America\",\"population\":323947000,\"latlng\":[38.0,-97.0],\"demonym\":\"American\",\"area\":9629091.0,\"gini\":48.0,\"timezones\":[\"UTC-12:00\",\"UTC-11:00\",\"UTC-10:00\",\"UTC-09:00\",\"UTC-08:00\",\"UTC-07:00\",\"UTC-06:00\",\"UTC-05:00\",\"UTC-04:00\",\"UTC+10:00\",\"UTC+12:00\"],\"borders\":[\"CAN\",\"MEX\"],\"nativeName\":\"United States\",\"numericCode\":\"840\",\"currencies\":[{\"code\":\"USD\",\"name\":\"United States dollar\",\"symbol\":\"$\"}],\"languages\":[{\"iso639_1\":\"en\",\"iso639_2\":\"eng\",\"name\":\"English\",\"nativeName\":\"English\"}],\"translations\":{\"de\":\"Vereinigte Staaten von Amerika\",\"es\":\"Estados Unidos\",\"fr\":\"États-Unis\",\"ja\":\"アメリカ合衆国\",\"it\":\"Stati Uniti D'America\",\"br\":\"Estados Unidos\",\"pt\":\"Estados Unidos\",\"nl\":\"Verenigde Staten\",\"hr\":\"Sjedinjene Američke Države\",\"fa\":\"ایالات متحده آمریکا\"},\"flag\":\"https://restcountries.eu/data/usa.svg\",\"regionalBlocs\":[{\"acronym\":\"NAFTA\",\"name\":\"North American Free Trade Agreement\",\"otherAcronyms\":[],\"otherNames\":[\"Tratado de Libre Comercio de América del Norte\",\"Accord de Libre-échange Nord-Américain\"]}],\"cioc\":\"USA\"}"; 40 | ResponseEntity responseEntity = new ResponseEntity(responseBody,HttpStatus.OK); 41 | 42 | when(restTemplate.getForEntity(countriesUrl,String.class)).thenReturn(responseEntity); 43 | String response =countryService.getCountryDetails(countryCode); 44 | assertNotNull(response); 45 | 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /camel-spring-boot-boiler-plate/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | camel: 5 | springboot: 6 | shutdownTimeout: 1 7 | health.indicator.enabled: true 8 | management.security.enabled: false 9 | 10 | info.app.name: Spring boiler plate 11 | info.app.description: This is a Spring boot boiler plate code. 12 | info.app.version: 1.0.0 13 | 14 | --- 15 | 16 | spring: 17 | profiles: mock 18 | datasource: 19 | driver-class-name: org.postgresql.Driver 20 | url: jdbc:postgresql://localhost:5432/localDB 21 | username: postgres 22 | password: postgres 23 | mail: 24 | host: smtp.gmail.com 25 | port: 587 26 | username: xyz@gmail.com 27 | password: 28 | properties.mail.smtp.auth: true 29 | properties.mail.smtp.starttls.enable: true 30 | 31 | mail.smtp.starttls.enable: true 32 | 33 | mailto: xyz@gmail.com 34 | mailFrom: xyz@gmail.com 35 | 36 | message: Hello from MOCK Profile 37 | fromRoute: direct:input 38 | toRoute: mock:output 39 | healthRoute: direct:health 40 | 41 | --- 42 | 43 | spring: 44 | profiles: dev 45 | datasource: 46 | driver-class-name: org.postgresql.Driver 47 | url: jdbc:postgresql://localhost:5432/localDB 48 | username: postgres 49 | password: postgres 50 | mail: 51 | host: smtp.gmail.com 52 | port: 587 53 | username: xyz@gmail.com 54 | password: 55 | properties.mail.smtp.auth: true 56 | properties.mail.smtp.starttls.enable: true 57 | 58 | mailto: xyz@gmail.com 59 | mailFrom: xyz@gmail.com 60 | message: Hello from DEV Profile 61 | fromRoute: timer:health?period=10s 62 | toRoute: log:?level=INFO&showBody=true 63 | healthRoute: timer:health?period=10s 64 | 65 | --- 66 | 67 | spring: 68 | profiles: stage 69 | datasource: 70 | driver-class-name: org.postgresql.Driver 71 | url: jdbc:postgresql://localhost:5432/localDB 72 | username: postgres 73 | password: postgres 74 | mail: 75 | host: smtp.gmail.com 76 | port: 587 77 | username: xyz@gmail.com 78 | password: 79 | properties.mail.smtp.auth: true 80 | properties.mail.smtp.starttls.enable: true 81 | 82 | mailto: xyz@gmail.com 83 | mailFrom: xyz@gmail.com 84 | message: Hello from STAGE Profile 85 | 86 | fromRoute: timer:health?period=10s 87 | toRoute: log:?level=INFO&showBody=true 88 | healthRoute: timer:health?period=10s 89 | 90 | 91 | --- 92 | 93 | spring: 94 | profiles: prod 95 | datasource: 96 | driver-class-name: org.postgresql.Driver 97 | url: jdbc:postgresql://localhost:5432/localDB 98 | username: postgres 99 | password: postgres 100 | mail: 101 | host: smtp.gmail.com 102 | port: 587 103 | username: xyz@gmail.com 104 | password: 105 | properties.mail.smtp.auth: true 106 | properties.mail.smtp.starttls.enable: true 107 | 108 | mailto: xyz@gmail.com 109 | mailFrom: xyz@gmail.com 110 | 111 | message: Hello from PROD Profile 112 | 113 | fromRoute: timer:health?period=10s 114 | toRoute: log:?level=INFO&showBody=true 115 | healthRoute: timer:health?period=10s 116 | 117 | 118 | --- -------------------------------------------------------------------------------- /kafka-learncamel-spring-boot/src/test/java/com/learncamel/routes/KafkaRouteMockTest.java: -------------------------------------------------------------------------------- 1 | package com.learncamel.routes; 2 | 3 | import com.learncamel.domain.Item; 4 | import com.learncamel.exception.DataException; 5 | import org.apache.camel.CamelContext; 6 | import org.apache.camel.CamelExecutionException; 7 | import org.apache.camel.EndpointInject; 8 | import org.apache.camel.ProducerTemplate; 9 | import org.apache.camel.builder.RouteBuilder; 10 | import org.apache.camel.component.mock.MockEndpoint; 11 | import org.apache.camel.test.junit4.CamelTestSupport; 12 | import org.apache.camel.test.spring.CamelSpringBootRunner; 13 | import org.apache.camel.test.spring.DisableJmx; 14 | import org.apache.commons.io.FileUtils; 15 | import org.junit.Before; 16 | import org.junit.BeforeClass; 17 | import org.junit.Ignore; 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.mockito.Mock; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.boot.test.context.SpringBootTest; 23 | import org.springframework.core.env.Environment; 24 | import org.springframework.test.annotation.DirtiesContext; 25 | import org.springframework.test.context.ActiveProfiles; 26 | 27 | import java.io.File; 28 | import java.io.IOException; 29 | import java.nio.file.Files; 30 | import java.nio.file.Paths; 31 | import java.util.ArrayList; 32 | 33 | /** 34 | * Created by Dilip on 1/13/18. 35 | */ 36 | @ActiveProfiles("mock") 37 | @RunWith(CamelSpringBootRunner.class) 38 | @SpringBootTest 39 | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) 40 | @DisableJmx(true) 41 | public class KafkaRouteMockTest extends CamelTestSupport{ 42 | 43 | 44 | @Autowired 45 | private CamelContext context; 46 | 47 | @Autowired 48 | Environment environment; 49 | 50 | 51 | @Autowired 52 | protected CamelContext createCamelContext() { 53 | return context; 54 | } 55 | 56 | @Autowired 57 | private ProducerTemplate producerTemplate; 58 | 59 | @Override 60 | protected RouteBuilder createRouteBuilder(){ 61 | return new KafkaRoute(); 62 | } 63 | 64 | @Before 65 | public void setUp(){ 66 | 67 | } 68 | 69 | /** 70 | * Invalid because the body is changes with query 71 | * @throws InterruptedException 72 | */ 73 | @Test 74 | public void unMarshalItem_success() throws InterruptedException { 75 | String input = "{\"transactionType\":\"ADD\", \"sku\":\"100\", \"itemDescription\":\"SamsungTV\", \"price\":\"500\"}"; 76 | 77 | String output = "INSERT INTO ITEMS (SKU, ITEM_DESCRIPTION,PRICE) VALUES ('100','SamsungTV',500);"; 78 | String item = (String) producerTemplate.requestBodyAndHeader(environment.getProperty("fromRoute"),input 79 | ,"env","mock"); 80 | 81 | assertEquals(output,item); 82 | 83 | 84 | 85 | } 86 | 87 | @Test(expected = CamelExecutionException.class) 88 | @Ignore 89 | public void unMarshalItem_failure() throws InterruptedException { 90 | String input = "{\"transactionType\":\"ADD\", \"sku\":\"\", \"itemDescription\":\"SamsungTV\", \"price\":\"500\"}"; 91 | 92 | 93 | Item item = (Item) producerTemplate.requestBodyAndHeader(environment.getProperty("fromRoute"),input,"env","mock"); 94 | 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /rest-learncamel-spring-boot/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | camel: 5 | springboot: 6 | shutdownTimeout: 1 7 | health.indicator.enabled: true 8 | management.security.enabled: false 9 | 10 | info.app.name: Spring boiler plate 11 | info.app.description: This is a Spring boot boiler plate code. 12 | info.app.version: 1.0.0 13 | 14 | --- 15 | 16 | spring: 17 | profiles: mock 18 | datasource: 19 | driver-class-name: org.postgresql.Driver 20 | url: jdbc:postgresql://localhost:5432/localDB 21 | username: postgres 22 | password: postgres 23 | mail: 24 | host: smtp.gmail.com 25 | port: 587 26 | username: xyz@gmail.com 27 | password: 28 | properties.mail.smtp.auth: true 29 | properties.mail.smtp.starttls.enable: true 30 | 31 | mail.smtp.starttls.enable: true 32 | 33 | mailto: xyz@gmail.com 34 | mailFrom: xyz@gmail.com 35 | 36 | message: Hello from MOCK Profile 37 | fromRoute: direct:input 38 | toRoute: mock:output 39 | dbNode: mock:output1 40 | selectNode: mock:output2 41 | healthRoute: direct:health 42 | 43 | --- 44 | 45 | spring: 46 | profiles: dev 47 | datasource: 48 | driver-class-name: org.postgresql.Driver 49 | url: jdbc:postgresql://localhost:5432/localDB 50 | username: postgres 51 | password: postgres 52 | mail: 53 | host: smtp.gmail.com 54 | port: 587 55 | username: alertsdilip@gmail.com 56 | password: alertsdilip123 57 | properties.mail.smtp.auth: true 58 | properties.mail.smtp.starttls.enable: true 59 | 60 | mailto: alertsdilip@gmail.com 61 | mailFrom: alertsdilip@gmail.com 62 | message: Hello from DEV Profile 63 | fromRoute: timer:health?period=10s 64 | toRoute: http://localhost:8081/country 65 | dbNode: jdbc:dataSource 66 | healthRoute: timer:health?period=10s 67 | selectNode: sql:select * from country where COUNTRY_CODE = :#countryCode?dataSource=#dataSource 68 | 69 | 70 | --- 71 | 72 | spring: 73 | profiles: stage 74 | datasource: 75 | driver-class-name: org.postgresql.Driver 76 | url: jdbc:postgresql://localhost:5432/localDB 77 | username: postgres 78 | password: postgres 79 | mail: 80 | host: smtp.gmail.com 81 | port: 587 82 | username: xyz@gmail.com 83 | password: 84 | properties.mail.smtp.auth: true 85 | properties.mail.smtp.starttls.enable: true 86 | 87 | mailto: xyz@gmail.com 88 | mailFrom: xyz@gmail.com 89 | message: Hello from STAGE Profile 90 | 91 | fromRoute: timer:health?period=10s 92 | toRoute: log:?level=INFO&showBody=true 93 | healthRoute: timer:health?period=10s 94 | 95 | 96 | --- 97 | 98 | spring: 99 | profiles: prod 100 | datasource: 101 | driver-class-name: org.postgresql.Driver 102 | url: jdbc:postgresql://localhost:5432/localDB 103 | username: postgres 104 | password: postgres 105 | mail: 106 | host: smtp.gmail.com 107 | port: 587 108 | username: xyz@gmail.com 109 | password: 110 | properties.mail.smtp.auth: true 111 | properties.mail.smtp.starttls.enable: true 112 | 113 | mailto: xyz@gmail.com 114 | mailFrom: xyz@gmail.com 115 | 116 | message: Hello from PROD Profile 117 | 118 | fromRoute: timer:health?period=10s 119 | toRoute: log:?level=INFO&showBody=true 120 | healthRoute: timer:health?period=10s 121 | 122 | 123 | --- --------------------------------------------------------------------------------