diff --git a/config-server/Dockerfile b/config-server/Dockerfile
new file mode 100644
index 0000000..82503c7
--- /dev/null
+++ b/config-server/Dockerfile
@@ -0,0 +1,9 @@
+FROM openjdk:8
+
+VOLUME /tmp
+RUN mkdir /microservice
+WORKDIR /microservice
+COPY ./target/config-server.jar ./config-server.jar
+RUN bash -c 'touch config-server.jar'
+
+CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "config-server.jar"]
\ No newline at end of file
diff --git a/config-server/pom.xml b/config-server/pom.xml
new file mode 100644
index 0000000..191a9f8
--- /dev/null
+++ b/config-server/pom.xml
@@ -0,0 +1,89 @@
+
+
+ 4.0.0
+
+ br.com.dodz
+ config-server
+ 0.0.1-SNAPSHOT
+ jar
+
+ config-server
+ Spring Cloud Config Server
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.6.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Dalston.SR2
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-config-server
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bus-amqp
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+ ${project.name}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
diff --git a/config-server/src/main/java/br/com/dodz/configserver/ConfigServerApplication.java b/config-server/src/main/java/br/com/dodz/configserver/ConfigServerApplication.java
new file mode 100644
index 0000000..e58d0ec
--- /dev/null
+++ b/config-server/src/main/java/br/com/dodz/configserver/ConfigServerApplication.java
@@ -0,0 +1,14 @@
+package br.com.dodz.configserver;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.cloud.client.SpringCloudApplication;
+import org.springframework.cloud.config.server.EnableConfigServer;
+
+@EnableConfigServer
+@SpringCloudApplication
+public class ConfigServerApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ConfigServerApplication.class, args);
+ }
+}
diff --git a/config-server/src/main/resources/banner.txt b/config-server/src/main/resources/banner.txt
new file mode 100644
index 0000000..78856d9
--- /dev/null
+++ b/config-server/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+ ______ ______ .__ __. _______ __ _______ _______. _______ .______ ____ ____ _______ .______
+ / | / __ \ | \ | | | ____|| | / _____| / || ____|| _ \ \ \ / / | ____|| _ \
+| ,----'| | | | | \| | | |__ | | | | __ | (----`| |__ | |_) | \ \/ / | |__ | |_) |
+| | | | | | | . ` | | __| | | | | |_ | \ \ | __| | / \ / | __| | /
+| `----.| `--' | | |\ | | | | | | |__| | .----) | | |____ | |\ \----. \ / | |____ | |\ \----.
+ \______| \______/ |__| \__| |__| |__| \______| |_______/ |_______|| _| `._____| \__/ |_______|| _| `._____|
+
\ No newline at end of file
diff --git a/config-server/src/main/resources/bootstrap.yml b/config-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..6448afa
--- /dev/null
+++ b/config-server/src/main/resources/bootstrap.yml
@@ -0,0 +1,10 @@
+server.port: 8888
+
+spring:
+ application:
+ name: config-server
+ index: ${random.int}
+ cloud.config:
+ server:
+ git.uri: https://github.com/chavesrodolfo/poc-microservices-config.git
+ bootstrap: true
diff --git a/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/FeignClientTwo.java b/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/FeignEurekaClientTwo.java
similarity index 69%
rename from eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/FeignClientTwo.java
rename to eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/FeignEurekaClientTwo.java
index bb8ff0e..164e0af 100644
--- a/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/FeignClientTwo.java
+++ b/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/FeignEurekaClientTwo.java
@@ -1,12 +1,12 @@
-package br.com.dodz.eurekaclientone;
-
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-@FeignClient(value = "client-two")
-public interface FeignClientTwo {
-
- @RequestMapping(value = "/api/hi", method = RequestMethod.GET)
- String sayHiByClientTwo();
-}
+package br.com.dodz.eurekaclientone;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@FeignClient(value = "eureka-client-two")
+public interface FeignEurekaClientTwo {
+
+ @RequestMapping(value = "/api/hi", method = RequestMethod.GET)
+ String sayHiByEurekaClientTwo();
+}
diff --git a/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/RestService.java b/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/RestService.java
index 442aad6..d07e89e 100644
--- a/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/RestService.java
+++ b/eureka-client-one/src/main/java/br/com/dodz/eurekaclientone/RestService.java
@@ -1,27 +1,27 @@
-package br.com.dodz.eurekaclientone;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequestMapping("/api")
-public class RestService {
-
- @Autowired
- private FeignClientTwo feignClientTwo;
-
- @RequestMapping(value = "/hi", method = RequestMethod.GET)
- public ResponseEntity sayHi() {
- return new ResponseEntity<>("Hi From Cliente One!", HttpStatus.OK);
- }
-
- @RequestMapping(value = "/hy", method = RequestMethod.GET)
- public ResponseEntity sayHiUsingClientTwo() {
- return new ResponseEntity<>(feignClientTwo.sayHiByClientTwo() + " using Hystrix.", HttpStatus.OK);
- }
-
-}
+package br.com.dodz.eurekaclientone;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api")
+public class RestService {
+
+ @Autowired
+ private FeignEurekaClientTwo feignEurekaClientTwo;
+
+ @RequestMapping(value = "/hi", method = RequestMethod.GET)
+ public ResponseEntity sayHi() {
+ return new ResponseEntity<>("Hi From Cliente One!", HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/hy", method = RequestMethod.GET)
+ public ResponseEntity sayHiUsingClientTwo() {
+ return new ResponseEntity<>(feignEurekaClientTwo.sayHiByEurekaClientTwo() + " using Feign.", HttpStatus.OK);
+ }
+
+}
diff --git a/eureka-client-one/src/main/resources/application.properties b/eureka-client-one/src/main/resources/application.properties
deleted file mode 100644
index f569a4f..0000000
--- a/eureka-client-one/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-spring.application.name=client-one
-server.port=8081
\ No newline at end of file
diff --git a/eureka-client-one/src/main/resources/banner.txt b/eureka-client-one/src/main/resources/banner.txt
new file mode 100644
index 0000000..1d0b6f0
--- /dev/null
+++ b/eureka-client-one/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+.___ ___. __ ______ .______ ______ _______. _______ .______ ____ ____ __ ______ _______
+| \/ | | | / || _ \ / __ \ / || ____|| _ \ \ \ / / | | / || ____|
+| \ / | | | | ,----'| |_) | | | | | | (----`| |__ | |_) | \ \/ / | | | ,----'| |__
+| |\/| | | | | | | / | | | | \ \ | __| | / \ / | | | | | __|
+| | | | | | | `----.| |\ \----.| `--' | .----) | | |____ | |\ \----. \ / | | | `----.| |____
+|__| |__| |__| \______|| _| `._____| \______/ |_______/ |_______|| _| `._____| \__/ |__| \______||_______|
+
\ No newline at end of file
diff --git a/eureka-client-one/src/main/resources/bootstrap.yml b/eureka-client-one/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..300bfe9
--- /dev/null
+++ b/eureka-client-one/src/main/resources/bootstrap.yml
@@ -0,0 +1,12 @@
+CONFIG_SERVER_URL: http://127.0.0.1:8888
+
+server:
+ port: 8081
+
+spring:
+ application:
+ name: eureka-client-one
+ cloud:
+ config:
+ uri: ${CONFIG_SERVER_URL}
+ fail-fast: true
diff --git a/eureka-client-two/src/main/resources/application.properties b/eureka-client-two/src/main/resources/application.properties
deleted file mode 100644
index 14828c5..0000000
--- a/eureka-client-two/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-spring.application.name=client-two
-server.port=8082
\ No newline at end of file
diff --git a/eureka-client-two/src/main/resources/banner.txt b/eureka-client-two/src/main/resources/banner.txt
new file mode 100644
index 0000000..1d0b6f0
--- /dev/null
+++ b/eureka-client-two/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+.___ ___. __ ______ .______ ______ _______. _______ .______ ____ ____ __ ______ _______
+| \/ | | | / || _ \ / __ \ / || ____|| _ \ \ \ / / | | / || ____|
+| \ / | | | | ,----'| |_) | | | | | | (----`| |__ | |_) | \ \/ / | | | ,----'| |__
+| |\/| | | | | | | / | | | | \ \ | __| | / \ / | | | | | __|
+| | | | | | | `----.| |\ \----.| `--' | .----) | | |____ | |\ \----. \ / | | | `----.| |____
+|__| |__| |__| \______|| _| `._____| \______/ |_______/ |_______|| _| `._____| \__/ |__| \______||_______|
+
\ No newline at end of file
diff --git a/eureka-client-two/src/main/resources/bootstrap.yml b/eureka-client-two/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..de4920f
--- /dev/null
+++ b/eureka-client-two/src/main/resources/bootstrap.yml
@@ -0,0 +1,12 @@
+CONFIG_SERVER_URL: http://127.0.0.1:8888
+
+server:
+ port: 8082
+
+spring:
+ application:
+ name: eureka-client-two
+ cloud:
+ config:
+ uri: ${CONFIG_SERVER_URL}
+ fail-fast: true
diff --git a/eureka-server/pom.xml b/eureka-server/pom.xml
index e595e4e..93b1628 100644
--- a/eureka-server/pom.xml
+++ b/eureka-server/pom.xml
@@ -1,63 +1,73 @@
-
-
- 4.0.0
-
- br.com.dodz
- eureka-server
- 0.0.1-SNAPSHOT
- jar
-
- eureka-server
- Demo project for Spring Boot
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.6.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- 1.8
- Dalston.SR2
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka-server
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ br.com.dodz
+ eureka-server
+ 0.0.1-SNAPSHOT
+ jar
+
+ eureka-server
+ Spring Cloud Eureka Server
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.6.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Dalston.SR2
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka-server
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
diff --git a/eureka-server/src/main/resources/application.properties b/eureka-server/src/main/resources/application.properties
deleted file mode 100644
index 8c40bcd..0000000
--- a/eureka-server/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-server.port=8761
-eureka-client-register-with-eureka=false
\ No newline at end of file
diff --git a/eureka-server/src/main/resources/banner.txt b/eureka-server/src/main/resources/banner.txt
new file mode 100644
index 0000000..4863d6e
--- /dev/null
+++ b/eureka-server/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+ _______ __ __ .______ _______ __ ___ ___ _______. _______ .______ ____ ____ _______ .______
+| ____|| | | | | _ \ | ____|| |/ / / \ / || ____|| _ \ \ \ / / | ____|| _ \
+| |__ | | | | | |_) | | |__ | ' / / ^ \ | (----`| |__ | |_) | \ \/ / | |__ | |_) |
+| __| | | | | | / | __| | < / /_\ \ \ \ | __| | / \ / | __| | /
+| |____ | `--' | | |\ \----.| |____ | . \ / _____ \ .----) | | |____ | |\ \----. \ / | |____ | |\ \----.
+|_______| \______/ | _| `._____||_______||__|\__\ /__/ \__\ |_______/ |_______|| _| `._____| \__/ |_______|| _| `._____|
+
\ No newline at end of file
diff --git a/eureka-server/src/main/resources/bootstrap.yml b/eureka-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..650f287
--- /dev/null
+++ b/eureka-server/src/main/resources/bootstrap.yml
@@ -0,0 +1,8 @@
+server.port: 8761
+
+spring:
+ application:
+ name: eureka-server
+ index: ${random.int}
+ cloud.config:
+ uri: http://localhost:8888
\ No newline at end of file
diff --git a/jaimail-router/Dockerfile b/jaimail-router/Dockerfile
new file mode 100644
index 0000000..f76b494
--- /dev/null
+++ b/jaimail-router/Dockerfile
@@ -0,0 +1,9 @@
+FROM openjdk:8
+
+VOLUME /tmp
+RUN mkdir /msdemo
+WORKDIR /msdemo
+COPY ./target/jaimail-router.jar ./jaimail-router.jar
+RUN bash -c 'touch jaimail-router.jar'
+
+CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "jaimail-router.jar"]
\ No newline at end of file
diff --git a/jaimail-router/pom.xml b/jaimail-router/pom.xml
new file mode 100644
index 0000000..5bbf375
--- /dev/null
+++ b/jaimail-router/pom.xml
@@ -0,0 +1,157 @@
+
+
+ 4.0.0
+
+ jaimail-router
+ jaimail-router
+ Spring Cloud Microservices Demo
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.6.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.2.2.RELEASE
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ Dalston.SR2
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bus-amqp
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-feign
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-netflix-hystrix-amqp
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
+
+
+ org.springframework.cloud
+ spring-cloud-sleuth-stream
+
+
+ org.springframework.cloud
+ spring-cloud-stream-binder-rabbit
+
+
+
+
+ org.springframework.kafka
+ spring-kafka
+ ${spring-kafka.version}
+
+
+ org.springframework.kafka
+ spring-kafka-test
+ ${spring-kafka.version}
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ ${project.name}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+ com.spotify
+ docker-maven-plugin
+ 1.0.0
+
+ ${project.artifactId}
+ java:8
+ ["java", "-jar", "/${project.build.finalName}.jar"]
+
+
+
+ /
+ ${project.build.directory}
+ ${project.build.finalName}.jar
+
+
+
+
+
+ build-image
+ package
+
+ build
+
+
+
+
+
+
+
diff --git a/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/JaimailRouterApplication.java b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/JaimailRouterApplication.java
new file mode 100644
index 0000000..0d3ffa6
--- /dev/null
+++ b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/JaimailRouterApplication.java
@@ -0,0 +1,12 @@
+package br.com.dodz.jaimailrouter;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class JaimailRouterApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(JaimailRouterApplication.class, args);
+ }
+}
diff --git a/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/consumer/Receiver.java b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/consumer/Receiver.java
new file mode 100644
index 0000000..59f50e9
--- /dev/null
+++ b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/consumer/Receiver.java
@@ -0,0 +1,24 @@
+package br.com.dodz.jaimailrouter.kafka.consumer;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.kafka.annotation.KafkaListener;
+
+public class Receiver {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Receiver.class);
+
+ private CountDownLatch latch = new CountDownLatch(1);
+
+ public CountDownLatch getLatch() {
+ return latch;
+ }
+
+ @KafkaListener(topics = "${kafka.topic.helloworld}")
+ public void receive(String payload) {
+ LOGGER.info("received payload='{}'", payload);
+ latch.countDown();
+ }
+}
diff --git a/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/consumer/ReceiverConfig.java b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/consumer/ReceiverConfig.java
new file mode 100644
index 0000000..36ba5d7
--- /dev/null
+++ b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/consumer/ReceiverConfig.java
@@ -0,0 +1,54 @@
+package br.com.dodz.jaimailrouter.kafka.consumer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.annotation.EnableKafka;
+import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
+import org.springframework.kafka.core.ConsumerFactory;
+import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
+
+@Configuration
+@EnableKafka
+public class ReceiverConfig {
+
+ @Value("${kafka.bootstrap-servers}")
+ private String bootstrapServers;
+
+ @Bean
+ public Map consumerConfigs() {
+ Map props = new HashMap<>();
+ // list of host:port pairs used for establishing the initial connections to the Kakfa cluster
+ props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
+ props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+ props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+ // allows a pool of processes to divide the work of consuming and processing records
+ props.put(ConsumerConfig.GROUP_ID_CONFIG, "helloworld");
+
+ return props;
+ }
+
+ @Bean
+ public ConsumerFactory consumerFactory() {
+ return new DefaultKafkaConsumerFactory<>(consumerConfigs());
+ }
+
+ @Bean
+ public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() {
+ ConcurrentKafkaListenerContainerFactory factory =
+ new ConcurrentKafkaListenerContainerFactory<>();
+ factory.setConsumerFactory(consumerFactory());
+
+ return factory;
+ }
+
+ @Bean
+ public Receiver receiver() {
+ return new Receiver();
+ }
+}
diff --git a/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/producer/Sender.java b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/producer/Sender.java
new file mode 100644
index 0000000..e433840
--- /dev/null
+++ b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/producer/Sender.java
@@ -0,0 +1,19 @@
+package br.com.dodz.jaimailrouter.kafka.producer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.kafka.core.KafkaTemplate;
+
+public class Sender {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Sender.class);
+
+ @Autowired
+ private KafkaTemplate kafkaTemplate;
+
+ public void send(String topic, String payload) {
+ LOGGER.info("sending payload='{}' to topic='{}'", payload, topic);
+ kafkaTemplate.send(topic, payload);
+ }
+}
diff --git a/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/producer/SenderConfig.java b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/producer/SenderConfig.java
new file mode 100644
index 0000000..125710a
--- /dev/null
+++ b/jaimail-router/src/main/java/br/com/dodz/jaimailrouter/kafka/producer/SenderConfig.java
@@ -0,0 +1,46 @@
+package br.com.dodz.jaimailrouter.kafka.producer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.core.DefaultKafkaProducerFactory;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.kafka.core.ProducerFactory;
+
+@Configuration
+public class SenderConfig {
+
+ @Value("${kafka.bootstrap-servers}")
+ private String bootstrapServers;
+
+ @Bean
+ public Map producerConfigs() {
+ Map props = new HashMap<>();
+ // list of host:port pairs used for establishing the initial connections to the Kakfa cluster
+ props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
+ props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+ props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+
+ return props;
+ }
+
+ @Bean
+ public ProducerFactory producerFactory() {
+ return new DefaultKafkaProducerFactory<>(producerConfigs());
+ }
+
+ @Bean
+ public KafkaTemplate kafkaTemplate() {
+ return new KafkaTemplate<>(producerFactory());
+ }
+
+ @Bean
+ public Sender sender() {
+ return new Sender();
+ }
+}
diff --git a/jaimail-router/src/main/resources/application.yml b/jaimail-router/src/main/resources/application.yml
new file mode 100644
index 0000000..29d6bd0
--- /dev/null
+++ b/jaimail-router/src/main/resources/application.yml
@@ -0,0 +1,4 @@
+kafka:
+ bootstrap-servers: 192.168.99.100:9092
+ topic:
+ helloworld: helloworld.t
\ No newline at end of file
diff --git a/jaimail-router/src/main/resources/bootstrap.yml b/jaimail-router/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..cb7711d
--- /dev/null
+++ b/jaimail-router/src/main/resources/bootstrap.yml
@@ -0,0 +1,8 @@
+server.port: 9001
+
+spring:
+ application:
+ name: jaimail-router
+ index: ${random.int}
+ cloud.config:
+ uri: http://localhost:8888
\ No newline at end of file
diff --git a/jaimail-router/src/test/java/br/com/dodz/jaimailrouter/kafka/JaimailRouterApplicationTest.java b/jaimail-router/src/test/java/br/com/dodz/jaimailrouter/kafka/JaimailRouterApplicationTest.java
new file mode 100644
index 0000000..f8abf17
--- /dev/null
+++ b/jaimail-router/src/test/java/br/com/dodz/jaimailrouter/kafka/JaimailRouterApplicationTest.java
@@ -0,0 +1,57 @@
+package br.com.dodz.jaimailrouter.kafka;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.kafka.config.KafkaListenerEndpointRegistry;
+import org.springframework.kafka.listener.MessageListenerContainer;
+import org.springframework.kafka.test.rule.KafkaEmbedded;
+import org.springframework.kafka.test.utils.ContainerTestUtils;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import br.com.dodz.jaimailrouter.kafka.consumer.Receiver;
+import br.com.dodz.jaimailrouter.kafka.producer.Sender;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class JaimailRouterApplicationTest {
+
+ private static String HELLOWORLD_TOPIC = "helloworld.t";
+
+ @Autowired
+ private Sender sender;
+
+ @Autowired
+ private Receiver receiver;
+
+ @Autowired
+ private KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry;
+
+ @ClassRule
+ public static KafkaEmbedded embeddedKafka = new KafkaEmbedded(1, true, HELLOWORLD_TOPIC);
+
+ @Before
+ public void setUp() throws Exception {
+ // wait until the partitions are assigned
+ for (MessageListenerContainer messageListenerContainer : kafkaListenerEndpointRegistry
+ .getListenerContainers()) {
+ ContainerTestUtils.waitForAssignment(messageListenerContainer,
+ embeddedKafka.getPartitionsPerTopic());
+ }
+ }
+
+ @Test
+ public void testReceive() throws Exception {
+ sender.send(HELLOWORLD_TOPIC, "Hello Spring Kafka!");
+
+ receiver.getLatch().await(10000, TimeUnit.MILLISECONDS);
+ assertThat(receiver.getLatch().getCount()).isEqualTo(0);
+ }
+}
diff --git a/jaimail-router/src/test/resources/application.yml b/jaimail-router/src/test/resources/application.yml
new file mode 100644
index 0000000..0be2302
--- /dev/null
+++ b/jaimail-router/src/test/resources/application.yml
@@ -0,0 +1,4 @@
+kafka:
+ bootstrap-servers: ${spring.embedded.kafka.brokers}
+ topic:
+ helloworld: helloworld.t
diff --git a/security-server/pom.xml b/security-server/pom.xml
new file mode 100644
index 0000000..69fd74f
--- /dev/null
+++ b/security-server/pom.xml
@@ -0,0 +1,78 @@
+
+
+ 4.0.0
+
+ br.com.dodz
+ security-server
+ 0.0.1-SNAPSHOT
+ jar
+
+ security-server
+ Security Server
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.6.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Dalston.SR2
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+
+
+ org.springframework.cloud
+ spring-cloud-starter-oauth2
+
+
+ org.springframework.cloud
+ spring-cloud-starter-security
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/security-server/src/main/java/br/com/dodz/securityserver/SecurityServiceApplication.java b/security-server/src/main/java/br/com/dodz/securityserver/SecurityServiceApplication.java
new file mode 100644
index 0000000..d416c3e
--- /dev/null
+++ b/security-server/src/main/java/br/com/dodz/securityserver/SecurityServiceApplication.java
@@ -0,0 +1,33 @@
+package br.com.dodz.securityserver;
+
+import java.security.Principal;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.cloud.client.SpringCloudApplication;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * curl -w \\n bootiful:secret@localhost:8080/security/oauth/token -d "grant_type=client_credentials&scope=read%20write"
+ *
+ */
+@SpringCloudApplication
+public class SecurityServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SecurityServiceApplication.class, args);
+ }
+}
+
+@RestController
+class UserDetailsController {
+
+ @ResponseStatus(HttpStatus.OK)
+ @RequestMapping(value = "/user", method = RequestMethod.GET)
+ public Principal authenticatedUser(Principal user) {
+ return user;
+ }
+}
\ No newline at end of file
diff --git a/security-server/src/main/java/br/com/dodz/securityserver/config/AuthorizationServerConfiguration.java b/security-server/src/main/java/br/com/dodz/securityserver/config/AuthorizationServerConfiguration.java
new file mode 100644
index 0000000..07b6b31
--- /dev/null
+++ b/security-server/src/main/java/br/com/dodz/securityserver/config/AuthorizationServerConfiguration.java
@@ -0,0 +1,23 @@
+package br.com.dodz.securityserver.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
+
+@Configuration
+@EnableAuthorizationServer
+public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
+
+ @Override
+ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
+ clients.inMemory()
+ .withClient("bootiful")
+ .secret("secret")
+ .accessTokenValiditySeconds(300)
+ .authorities("CLIENT")
+ .authorizedGrantTypes("client_credentials")
+ .scopes("read", "write")
+ .resourceIds("restservice","oauth2-resource");
+ }
+}
diff --git a/security-server/src/main/java/br/com/dodz/securityserver/config/ResourceServerConfiguration.java b/security-server/src/main/java/br/com/dodz/securityserver/config/ResourceServerConfiguration.java
new file mode 100644
index 0000000..f8db1ff
--- /dev/null
+++ b/security-server/src/main/java/br/com/dodz/securityserver/config/ResourceServerConfiguration.java
@@ -0,0 +1,20 @@
+package br.com.dodz.securityserver.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+
+@Configuration
+@EnableResourceServer
+public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
+
+ @Override
+ public void configure(HttpSecurity http) throws Exception {
+ http.authorizeRequests()
+ .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
+ .antMatchers("/**").authenticated()
+ .antMatchers("/oauth/**").permitAll();
+ }
+}
diff --git a/security-server/src/main/resources/banner.txt b/security-server/src/main/resources/banner.txt
new file mode 100644
index 0000000..7d2dd89
--- /dev/null
+++ b/security-server/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+ _______. _______ ______ __ __ .______ __ .___________.____ ____ _______. _______ .______ ____ ____ _______ .______
+ / || ____| / || | | | | _ \ | | | |\ \ / / / || ____|| _ \ \ \ / / | ____|| _ \
+ | (----`| |__ | ,----'| | | | | |_) | | | `---| |----` \ \/ / | (----`| |__ | |_) | \ \/ / | |__ | |_) |
+ \ \ | __| | | | | | | | / | | | | \_ _/ \ \ | __| | / \ / | __| | /
+.----) | | |____ | `----.| `--' | | |\ \----.| | | | | | .----) | | |____ | |\ \----. \ / | |____ | |\ \----.
+|_______/ |_______| \______| \______/ | _| `._____||__| |__| |__| |_______/ |_______|| _| `._____| \__/ |_______|| _| `._____|
+
\ No newline at end of file
diff --git a/security-server/src/main/resources/bootstrap.yml b/security-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..b7423a1
--- /dev/null
+++ b/security-server/src/main/resources/bootstrap.yml
@@ -0,0 +1,8 @@
+server.port: 8443
+
+spring:
+ application:
+ name: security-server
+ index: ${random.int}
+ cloud.config:
+ uri: http://localhost:8888
\ No newline at end of file
diff --git a/zuul-server/pom.xml b/zuul-server/pom.xml
index 7fc347b..6442d31 100644
--- a/zuul-server/pom.xml
+++ b/zuul-server/pom.xml
@@ -1,67 +1,78 @@
-
-
- 4.0.0
-
- br.com.dodz
- zuul-server
- 0.0.1-SNAPSHOT
- jar
-
- zuul-server
- Demo project for Spring Boot
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.6.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- 1.8
- Dalston.SR2
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
- org.springframework.cloud
- spring-cloud-starter-zuul
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ br.com.dodz
+ zuul-server
+ 0.0.1-SNAPSHOT
+ jar
+
+ zuul-server
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.6.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Dalston.SR2
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+ org.springframework.cloud
+ spring-cloud-starter-zuul
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
diff --git a/zuul-server/src/main/resources/application.properties b/zuul-server/src/main/resources/application.properties
deleted file mode 100644
index 8060b35..0000000
--- a/zuul-server/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-spring.application.name=zuul
-#eureka.server.host=localhost
\ No newline at end of file
diff --git a/zuul-server/src/main/resources/banner.txt b/zuul-server/src/main/resources/banner.txt
new file mode 100644
index 0000000..012610c
--- /dev/null
+++ b/zuul-server/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+ ________ __ __ __ __ __ _______. _______ .______ ____ ____ _______ .______
+| / | | | | | | | | | | / || ____|| _ \ \ \ / / | ____|| _ \
+`---/ / | | | | | | | | | | | (----`| |__ | |_) | \ \/ / | |__ | |_) |
+ / / | | | | | | | | | | \ \ | __| | / \ / | __| | /
+ / /----.| `--' | | `--' | | `----. .----) | | |____ | |\ \----. \ / | |____ | |\ \----.
+ /________| \______/ \______/ |_______| |_______/ |_______|| _| `._____| \__/ |_______|| _| `._____|
+
\ No newline at end of file
diff --git a/zuul-server/src/main/resources/bootstrap.yml b/zuul-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..e482afc
--- /dev/null
+++ b/zuul-server/src/main/resources/bootstrap.yml
@@ -0,0 +1,12 @@
+CONFIG_SERVER_URL: http://127.0.0.1:8888
+
+server:
+ port: 8080
+
+spring:
+ application:
+ name: zuul-server
+ cloud:
+ config:
+ uri: ${CONFIG_SERVER_URL}
+ fail-fast: true