├── eureka ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ ├── application.yml │ │ │ └── logback-spring.xml │ │ └── java │ │ │ └── de │ │ │ └── michlb │ │ │ └── sample │ │ │ └── rabbit │ │ │ └── EurekaApplication.java │ └── test │ │ └── java │ │ └── de │ │ └── michlb │ │ └── sample │ │ └── rabbit │ │ └── EurekaApplicationTests.java └── pom.xml ├── data-care ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ ├── application.yml │ │ │ ├── templates │ │ │ │ ├── message.html │ │ │ │ └── product.html │ │ │ └── logback-spring.xml │ │ └── java │ │ │ └── de │ │ │ └── michlb │ │ │ └── sample │ │ │ └── rabbit │ │ │ ├── web │ │ │ ├── bean │ │ │ │ ├── MessageForm.java │ │ │ │ └── ProductForm.java │ │ │ └── controller │ │ │ │ ├── MessageController.java │ │ │ │ └── ProductCareController.java │ │ │ ├── DataCareApplication.java │ │ │ └── service │ │ │ ├── MessageService.java │ │ │ └── ProductMessageService.java │ └── test │ │ └── java │ │ └── de │ │ └── michlb │ │ └── sample │ │ └── rabbit │ │ └── DataCareApplicationTests.java ├── README.md └── pom.xml ├── data-backend ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ ├── application.yml │ │ │ ├── logback-spring.xml │ │ │ └── templates │ │ │ │ └── messageLog.html │ │ └── java │ │ │ └── de │ │ │ └── michlb │ │ │ └── sample │ │ │ └── rabbit │ │ │ ├── repositories │ │ │ ├── ProductRepository.java │ │ │ └── MessageLogRepository.java │ │ │ ├── domain │ │ │ ├── Product.java │ │ │ └── MessageLog.java │ │ │ ├── web │ │ │ └── controller │ │ │ │ └── MessageLogController.kt │ │ │ ├── api │ │ │ └── controller │ │ │ │ └── ProductApiController.kt │ │ │ ├── message │ │ │ └── controller │ │ │ │ ├── SimpleMessageController.java │ │ │ │ └── ProductMessageController.java │ │ │ ├── DataBackendApplication.java │ │ │ └── config │ │ │ └── RabbitMqConfig.java │ └── test │ │ └── java │ │ └── de │ │ └── michlb │ │ └── sample │ │ └── rabbit │ │ └── DataBackendApplicationTests.java ├── README.md └── pom.xml ├── data-presentation ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ ├── application.yml │ │ │ ├── templates │ │ │ │ └── index.html │ │ │ └── logback-spring.xml │ │ └── java │ │ │ └── de │ │ │ └── michlb │ │ │ └── sample │ │ │ └── rabbit │ │ │ ├── web │ │ │ ├── bean │ │ │ │ └── MessageForm.java │ │ │ ├── feign │ │ │ │ └── ProductOperations.java │ │ │ └── controller │ │ │ │ └── IndexController.java │ │ │ ├── dto │ │ │ └── Product.java │ │ │ └── DataPresentationApplication.java │ └── test │ │ └── java │ │ └── de │ │ └── michlb │ │ └── sample │ │ └── rabbit │ │ └── DataCareApplicationTests.java ├── README.md └── pom.xml ├── spring-boot-admin ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ ├── application.yml │ │ │ └── logback-spring.xml │ │ └── java │ │ │ └── de │ │ │ └── michlb │ │ │ └── sampe │ │ │ └── rabbit │ │ │ └── SpringBootAdminApplication.java │ └── test │ │ └── java │ │ └── de │ │ └── michlb │ │ └── sampe │ │ └── rabbit │ │ └── SpringBootAdminApplicationTests.java └── pom.xml ├── docs └── spring-bootdockerrabbitmq.png ├── .gitignore ├── README.md ├── docker-compose.yml ├── pom.xml └── LICENSE /eureka/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: eureka 4 | -------------------------------------------------------------------------------- /data-care/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: data-care 4 | -------------------------------------------------------------------------------- /data-backend/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: data-backend 4 | -------------------------------------------------------------------------------- /data-presentation/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: data-presentation 4 | -------------------------------------------------------------------------------- /spring-boot-admin/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: spring-boot-admin 4 | -------------------------------------------------------------------------------- /docs/spring-bootdockerrabbitmq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michl-b/spring-boot-docker-rabbitmq-sample/HEAD/docs/spring-bootdockerrabbitmq.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | .idea/ 6 | target/ 7 | 8 | # Package Files # 9 | *.jar 10 | *.war 11 | *.ear 12 | *.log 13 | *.iml 14 | 15 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 16 | hs_err_pid* 17 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/web/bean/MessageForm.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.bean; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Form definition Bean for web presentation view 7 | * 8 | * @author Michael Bartsch 9 | */ 10 | @Data 11 | public class MessageForm { 12 | private String message; 13 | } 14 | -------------------------------------------------------------------------------- /data-presentation/src/main/java/de/michlb/sample/rabbit/web/bean/MessageForm.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.bean; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Form definition Bean for web presentation view 7 | * 8 | * @author Michael Bartsch 9 | */ 10 | @Data 11 | public class MessageForm { 12 | private String message; 13 | } 14 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/web/bean/ProductForm.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.bean; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Form definition Bean for product input view 7 | * 8 | * @author Michael Bartsch 9 | */ 10 | @Data 11 | public class ProductForm { 12 | private String name; 13 | private String pictureUrl; 14 | private Double price; 15 | } 16 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/repositories/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.repositories; 2 | 3 | import de.michlb.sample.rabbit.domain.Product; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | /** 7 | * JPA repository for MessageLog entities 8 | * 9 | * @author Michael Bartsch 10 | */ 11 | public interface ProductRepository extends JpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/repositories/MessageLogRepository.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.repositories; 2 | 3 | import de.michlb.sample.rabbit.domain.MessageLog; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | /** 7 | * JPA repository for MessageLog entities 8 | * 9 | * @author Michael Bartsch 10 | */ 11 | public interface MessageLogRepository extends JpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /data-presentation/README.md: -------------------------------------------------------------------------------- 1 | # data-presentation 2 | 3 | I am a Spring Boot Service displays data received via REST from a data backend service 4 | 5 | ## tech 6 | 7 | - Java 8 8 | - Kotlin 9 | - Spring Boot 10 | - DevTools 11 | - Actuator 12 | - Docker Plugin 13 | - Maven 14 | - Thymeleaf 15 | - Bootstrap 4 alpha 16 | - Eureka Service Discovery 17 | 18 | ## build docker image 19 | ```bash 20 | mvn package docker:build -DpushImage=false 21 | ``` 22 | -------------------------------------------------------------------------------- /data-presentation/src/main/java/de/michlb/sample/rabbit/dto/Product.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * Created by admin on 12.11.16. 9 | */ 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class Product { 14 | private Long id; 15 | private String name; 16 | private String pictureUrl; 17 | private Double price; 18 | } 19 | -------------------------------------------------------------------------------- /eureka/src/test/java/de/michlb/sample/rabbit/EurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 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 EurekaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-care/README.md: -------------------------------------------------------------------------------- 1 | # data-care 2 | 3 | I am a Spring Boot Service which allows you to send messages via RabbitMQ. 4 | 5 | You can send messages at /message view. 6 | 7 | ## tech 8 | 9 | - Java 8 10 | - Kotlin 11 | - Spring Boot 12 | - DevTools 13 | - Actuator 14 | - Docker Plugin 15 | - Maven 16 | - Thymeleaf 17 | - Bootstrap 4 alpha 18 | - RabbitMQ 19 | - Eureka Service Discovery 20 | 21 | ## build docker image 22 | ```bash 23 | mvn package docker:build -DpushImage=false 24 | ``` 25 | -------------------------------------------------------------------------------- /data-care/src/test/java/de/michlb/sample/rabbit/DataCareApplicationTests.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 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 DataCareApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-backend/src/test/java/de/michlb/sample/rabbit/DataBackendApplicationTests.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 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 DataBackendApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-presentation/src/test/java/de/michlb/sample/rabbit/DataCareApplicationTests.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 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 DataCareApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-admin/src/test/java/de/michlb/sampe/rabbit/SpringBootAdminApplicationTests.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sampe.rabbit; 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 SpringBootAdminApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /eureka/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | eureka: 5 | instance: 6 | hostname: localhost 7 | preferIpAddress: true 8 | client: 9 | registerWithEureka: false 10 | fetchRegistry: false 11 | serviceUrl: 12 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ 13 | 14 | logging: 15 | config: 16 | classpath: "logback-spring.xml" 17 | file: eureka.log 18 | 19 | info.app.name: '@project.name@' 20 | info.app.version: '@project.version@' 21 | 22 | -------------------------------------------------------------------------------- /data-presentation/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | info.app.name: '@project.name@' 2 | info.app.version: '@project.version@' 3 | 4 | server: 5 | port: 8084 6 | 7 | logging: 8 | config: 9 | classpath: "logback-spring.xml" 10 | file: data-presentation.log 11 | 12 | eureka: 13 | client: 14 | serviceUrl: 15 | defaultZone: ${EUREKA_CLIENT_SERVICEURL_DEFAULTZONE:http://localhost:8761/eureka/} 16 | healthcheck: 17 | enabled: true 18 | instance: 19 | appname: '@project.name@' 20 | preferIpAddress: true 21 | -------------------------------------------------------------------------------- /spring-boot-admin/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | info.app.name: '@project.name@' 2 | info.app.version: '@project.version@' 3 | 4 | logging: 5 | config: 6 | classpath: "logback-spring.xml" 7 | file: spring-boot-admin.log 8 | 9 | server: 10 | port: 8083 11 | 12 | eureka: 13 | client: 14 | serviceUrl: 15 | defaultZone: ${EUREKA_CLIENT_SERVICEURL_DEFAULTZONE:http://localhost:8761/eureka/} 16 | enabled: true 17 | healthcheck: 18 | enabled: true 19 | instance: 20 | appname: '@project.name@' 21 | preferIpAddress: true -------------------------------------------------------------------------------- /data-backend/README.md: -------------------------------------------------------------------------------- 1 | # data-backend 2 | 3 | I am a Spring Boot Service which connects to a RabbitMQ queue and send itself a message via queue called "spring-boot" 4 | 5 | You can display all received messages at /messages view. 6 | 7 | ## tech 8 | 9 | - Java 8 10 | - Kotlin 11 | - Spring Boot 12 | - DevTools 13 | - Actuator 14 | - Docker Plugin 15 | - Maven 16 | - H2 DB 17 | - Thymeleaf 18 | - Bootstrap 4 alpha 19 | - RabbitMQ 20 | - Eureka Service Discovery 21 | 22 | ## build docker image 23 | ```bash 24 | mvn package docker:build -DpushImage=false 25 | ``` 26 | -------------------------------------------------------------------------------- /data-presentation/src/main/java/de/michlb/sample/rabbit/web/feign/ProductOperations.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.feign; 2 | 3 | import de.michlb.sample.rabbit.dto.Product; 4 | import org.springframework.cloud.netflix.feign.FeignClient; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by admin on 12.11.16. 11 | */ 12 | @FeignClient("data-backend") 13 | public interface ProductOperations { 14 | 15 | @RequestMapping("/api/product/list") 16 | public List getList(); 17 | } 18 | -------------------------------------------------------------------------------- /data-care/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | info.app.name: '@project.name@' 2 | info.app.version: '@project.version@' 3 | 4 | logging: 5 | config: 6 | classpath: "logback-spring.xml" 7 | file: data-care.log 8 | 9 | server: 10 | port: 8082 11 | 12 | spring: 13 | rabbitmq: 14 | host: ${RABBIT_HOST:localhost} 15 | 16 | eureka: 17 | client: 18 | enabled: true 19 | healthcheck: 20 | enabled: true 21 | serviceUrl: 22 | defaultZone: ${EUREKA_CLIENT_SERVICEURL_DEFAULTZONE:http://localhost:8761/eureka/} 23 | instance: 24 | appname: '@project.name@' 25 | preferIpAddress: true -------------------------------------------------------------------------------- /data-backend/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | info.app.name: '@project.name@' 2 | info.app.version: '@project.version@' 3 | 4 | logging: 5 | config: 6 | classpath: "logback-spring.xml" 7 | file: data-backend.log 8 | 9 | server: 10 | port: 8081 11 | 12 | spring: 13 | rabbitmq: 14 | host: ${RABBIT_HOST:localhost} 15 | 16 | spring.jpa.hibernate.ddl-auto: create-drop 17 | 18 | spring.h2.console.enabled: true 19 | 20 | eureka: 21 | client: 22 | enabled: true 23 | healthcheck: 24 | enabled: true 25 | serviceUrl: 26 | defaultZone: ${EUREKA_CLIENT_SERVICEURL_DEFAULTZONE:http://localhost:8761/eureka/} 27 | instance: 28 | appname: '@project.name@' 29 | preferIpAddress: true -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/domain/Product.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import javax.persistence.Entity; 11 | import javax.persistence.GeneratedValue; 12 | import javax.persistence.Id; 13 | import javax.persistence.Table; 14 | 15 | /** 16 | * Created by admin on 12.11.16. 17 | */ 18 | @Entity 19 | @Table( name = "PRODUCTS" ) 20 | @Data 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class Product { 24 | @Id 25 | @GeneratedValue 26 | private Long id; 27 | private String name; 28 | private String pictureUrl; 29 | private Double price; 30 | } 31 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/web/controller/MessageLogController.kt: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.controller 2 | 3 | import de.michlb.sample.rabbit.repositories.MessageLogRepository 4 | import org.springframework.beans.factory.annotation.Autowired 5 | import org.springframework.stereotype.Controller 6 | import org.springframework.ui.Model 7 | import org.springframework.web.bind.annotation.GetMapping 8 | 9 | /** 10 | * Web controller in Kotlin for MessageLog display 11 | * @author Michael Bartsch 12 | */ 13 | @Controller 14 | class MessageLogController { 15 | 16 | @Autowired 17 | lateinit var messageLogrepository: MessageLogRepository 18 | 19 | @GetMapping("/messages") 20 | fun showLog(model: Model): String { 21 | val logMessages = messageLogrepository.findAll().reversed() 22 | model.addAttribute("logMessages", logMessages) 23 | return "messageLog" 24 | } 25 | } -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/api/controller/ProductApiController.kt: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.api.controller 2 | 3 | import de.michlb.sample.rabbit.domain.Product 4 | import de.michlb.sample.rabbit.repositories.MessageLogRepository 5 | import de.michlb.sample.rabbit.repositories.ProductRepository 6 | import org.springframework.beans.factory.annotation.Autowired 7 | import org.springframework.web.bind.annotation.GetMapping 8 | import org.springframework.web.bind.annotation.RequestMapping 9 | import org.springframework.web.bind.annotation.RestController 10 | 11 | /** 12 | * Created by admin on 12.11.16. 13 | */ 14 | @RestController 15 | @RequestMapping("api/product/") 16 | class ProductApiController { 17 | 18 | @Autowired 19 | lateinit var productRepository: ProductRepository 20 | 21 | 22 | @GetMapping("list") 23 | fun list() : List { 24 | return productRepository.findAll(); 25 | } 26 | } -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/domain/MessageLog.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.domain; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * Domain Entity for Queue message logging 14 | * 15 | * @author Michael Bartsch 16 | */ 17 | @Entity 18 | @Table(name = "MESSAGE_LOG") 19 | @Data 20 | @NoArgsConstructor 21 | public class MessageLog { 22 | 23 | @Id 24 | @GeneratedValue 25 | private Long id; 26 | 27 | private String queue; 28 | private String message; 29 | 30 | private LocalDateTime timestamp = LocalDateTime.now(); 31 | 32 | public MessageLog(String queue, String message) { 33 | this.message = message; 34 | timestamp = LocalDateTime.now(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /data-presentation/src/main/java/de/michlb/sample/rabbit/web/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.controller; 2 | 3 | import de.michlb.sample.rabbit.dto.Product; 4 | import de.michlb.sample.rabbit.web.feign.ProductOperations; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author Michael Bartsch 16 | */ 17 | @Controller 18 | public class IndexController { 19 | private static final Logger LOGGER = LoggerFactory.getLogger(IndexController.class); 20 | 21 | @Autowired 22 | private ProductOperations productOperations; 23 | 24 | @GetMapping("/") 25 | public String show(Model model) { 26 | List productList = productOperations.getList(); 27 | model.addAttribute("products", productList); 28 | return "index"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /data-care/src/main/resources/templates/message.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sender: Message 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Send Queue Message

12 | 13 | 14 |
15 |
16 | 17 | 19 |
20 | 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/message/controller/SimpleMessageController.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.message.controller; 2 | 3 | import de.michlb.sample.rabbit.domain.MessageLog; 4 | import de.michlb.sample.rabbit.domain.Product; 5 | import de.michlb.sample.rabbit.repositories.MessageLogRepository; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * Created by admin on 12.11.16. 14 | */ 15 | @Component 16 | public class SimpleMessageController { 17 | private static final Logger LOGGER = LoggerFactory.getLogger(SimpleMessageController.class); 18 | 19 | @Autowired 20 | private MessageLogRepository messageLogRepository = null; 21 | 22 | @RabbitListener(queues = ("data-queue")) 23 | public void receiveProduct(String message ) { 24 | LOGGER.info( String.format("received simple message [%s]", message) ); 25 | messageLogRepository.save(new MessageLog("data-queue", message)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /data-presentation/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Presentation: View 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Backend Data

12 | 13 | 14 |
15 |
16 | 17 |
18 |

Card title

19 |

Some quick example text to build on the card title and make up the bulk of the card's content.

20 |
21 |
22 |
23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /eureka/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | ${FILE_LOG_PATTERN} 12 | 13 | ${LOG_FILE}.log 14 | 15 | ${LOG_FILE}.%d{yyyy-MM-dd}.log 16 | 10 17 | 18 | 19 | 20 | 21 | 22 | ${CONSOLE_LOG_PATTERN} 23 | utf8 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /data-backend/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | ${FILE_LOG_PATTERN} 12 | 13 | ${LOG_FILE}.log 14 | 15 | ${LOG_FILE}.%d{yyyy-MM-dd}.log 16 | 10 17 | 18 | 19 | 20 | 21 | 22 | ${CONSOLE_LOG_PATTERN} 23 | utf8 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /data-care/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | ${FILE_LOG_PATTERN} 12 | 13 | ${LOG_FILE}.log 14 | 15 | ${LOG_FILE}.%d{yyyy-MM-dd}.log 16 | 10 17 | 18 | 19 | 20 | 21 | 22 | ${CONSOLE_LOG_PATTERN} 23 | utf8 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /data-presentation/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | ${FILE_LOG_PATTERN} 12 | 13 | ${LOG_FILE}.log 14 | 15 | ${LOG_FILE}.%d{yyyy-MM-dd}.log 16 | 10 17 | 18 | 19 | 20 | 21 | 22 | ${CONSOLE_LOG_PATTERN} 23 | utf8 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /spring-boot-admin/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | ${FILE_LOG_PATTERN} 12 | 13 | ${LOG_FILE}.log 14 | 15 | ${LOG_FILE}.%d{yyyy-MM-dd}.log 16 | 10 17 | 18 | 19 | 20 | 21 | 22 | ${CONSOLE_LOG_PATTERN} 23 | utf8 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /data-backend/src/main/resources/templates/messageLog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Receiver: MessageLog 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Message Log

12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Messages
IdTimeMessage
?--
32 |
33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /eureka/src/main/java/de/michlb/sample/rabbit/EurekaApplication.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 9 | 10 | import javax.annotation.PostConstruct; 11 | 12 | @SpringBootApplication 13 | @EnableEurekaServer 14 | public class EurekaApplication { 15 | private static Logger LOGGER = LoggerFactory.getLogger(EurekaApplication.class); 16 | 17 | @Value("${info.app.version}") 18 | private String appVersion = null; 19 | 20 | @Value("${info.app.name}") 21 | private String appName = null; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(EurekaApplication.class, args); 25 | } 26 | 27 | @PostConstruct 28 | public void writeInfos() { 29 | LOGGER.info("############################################"); 30 | LOGGER.info(" STARTUP"); 31 | LOGGER.info("############################################"); 32 | LOGGER.info("Application Name: " + appName); 33 | LOGGER.info("Application Version: " + appVersion); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-docker-rabbitmq-sample 2 | 3 | [Slides](http://slides.com/michlb/spring-bootdockerrabbitmq-924be2fc-567e-4d98-925f-39eedd37c762) 4 | 5 | - RabbitMQ 6 | - Spring Boot Apps 7 | - Spring Cloud - Eureka 8 | - Spring Boot Admin by codecentric 9 | - Docker compose 10 | 11 | ![System Image](docs/spring-bootdockerrabbitmq.png) 12 | 13 | 14 | ## RabbitMQ 15 | for Management Console 16 | 17 | default user: guest 18 | 19 | default password: guest 20 | 21 | ## build 22 | ```bash 23 | mvn clean install 24 | ``` 25 | in this step, also the docker images will be created (see docker-maven-plugin) 26 | 27 | ## run with docker-compose 28 | ### run... 29 | ```bash 30 | docker-compose up -d 31 | ``` 32 | Queue System [http://localhost:15672/](http://localhost:15672/) 33 | 34 | Eureka Server [http://localhost:8761/](http://localhost:8761/) 35 | 36 | Backend [http://localhost:8081/api/product/list](http://localhost:8081/api/product/list) 37 | 38 | Care [http://localhost:8082/product](http://localhost:8082/product) 39 | 40 | Presentation [http://localhost:8084/](http://localhost:8084/) 41 | 42 | Spring Boot Admin [http://localhost:8083/](http://localhost:8083/) 43 | 44 | ### stop! 45 | ```bash 46 | docker-compose stop 47 | ``` 48 | ### cleanup 49 | ```bash 50 | docker-compose rm 51 | ``` 52 | ### check 53 | ```bash 54 | docker-compose ps 55 | ``` 56 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/DataCareApplication.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 9 | 10 | import javax.annotation.PostConstruct; 11 | 12 | @SpringBootApplication 13 | @EnableEurekaClient 14 | public class DataCareApplication { 15 | private static Logger LOGGER = LoggerFactory.getLogger(DataCareApplication.class); 16 | 17 | @Value("${info.app.version}") 18 | private String appVersion = null; 19 | 20 | @Value("${info.app.name}") 21 | private String appName = null; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(DataCareApplication.class, args); 25 | } 26 | 27 | @PostConstruct 28 | public void writeInfos() { 29 | LOGGER.info("############################################"); 30 | LOGGER.info(" STARTUP"); 31 | LOGGER.info("############################################"); 32 | LOGGER.info("Application Name: " + appName); 33 | LOGGER.info("Application Version: " + appVersion); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/service/MessageService.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.service; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * Service for handling rabbit queue communication 11 | * 12 | * @author Michael Bartsch 13 | */ 14 | @Service 15 | public class MessageService { 16 | private static final Logger LOGGER = LoggerFactory.getLogger(MessageService.class); 17 | 18 | @Autowired 19 | private RabbitTemplate rabbitTemplate = null; 20 | 21 | /** 22 | * push message to the queue 23 | * @param queueName name of target queue 24 | * @param message message to be sent 25 | * @return true if successful, otherwise false 26 | */ 27 | public boolean sendQueueMessage(String queueName, String message) { 28 | try { 29 | LOGGER.info(String.format("send message [%s] to queue [%s]", message, queueName)); 30 | rabbitTemplate.convertAndSend(queueName, message); 31 | LOGGER.error("done!"); 32 | return true; 33 | } catch (Exception e) { 34 | LOGGER.error("failed!", e); 35 | return false; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-boot-admin/src/main/java/de/michlb/sampe/rabbit/SpringBootAdminApplication.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sampe.rabbit; 2 | 3 | import de.codecentric.boot.admin.config.EnableAdminServer; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 10 | 11 | import javax.annotation.PostConstruct; 12 | 13 | @SpringBootApplication 14 | @EnableEurekaClient 15 | @EnableAdminServer 16 | public class SpringBootAdminApplication { 17 | private static Logger LOGGER = LoggerFactory.getLogger(SpringBootAdminApplication.class); 18 | 19 | @Value("${info.app.version}") 20 | private String appVersion = null; 21 | 22 | @Value("${info.app.name}") 23 | private String appName = null; 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(SpringBootAdminApplication.class, args); 27 | } 28 | 29 | @PostConstruct 30 | public void writeInfos() { 31 | LOGGER.info("############################################"); 32 | LOGGER.info(" STARTUP"); 33 | LOGGER.info("############################################"); 34 | LOGGER.info("Application Name: " + appName); 35 | LOGGER.info("Application Version: " + appVersion); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /data-presentation/src/main/java/de/michlb/sample/rabbit/DataPresentationApplication.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 9 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 10 | 11 | import javax.annotation.PostConstruct; 12 | 13 | @SpringBootApplication 14 | @EnableEurekaClient 15 | @EnableFeignClients 16 | public class DataPresentationApplication { 17 | private static Logger LOGGER = LoggerFactory.getLogger(DataPresentationApplication.class); 18 | 19 | @Value("${info.app.version}") 20 | private String appVersion = null; 21 | 22 | @Value("${info.app.name}") 23 | private String appName = null; 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(DataPresentationApplication.class, args); 27 | } 28 | 29 | @PostConstruct 30 | public void writeInfos() { 31 | LOGGER.info("############################################"); 32 | LOGGER.info(" STARTUP"); 33 | LOGGER.info("############################################"); 34 | LOGGER.info("Application Name: " + appName); 35 | LOGGER.info("Application Version: " + appVersion); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/service/ProductMessageService.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.service; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import de.michlb.sample.rabbit.web.bean.ProductForm; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | * Service for handling rabbit queue communication 13 | * 14 | * @author Michael Bartsch 15 | */ 16 | @Service 17 | public class ProductMessageService { 18 | private static final Logger LOGGER = LoggerFactory.getLogger(ProductMessageService.class); 19 | 20 | @Autowired 21 | private ObjectMapper objectMapper = null; 22 | 23 | @Autowired 24 | private MessageService messageService = null; 25 | 26 | /** 27 | * convert product to json and send it to product-queue 28 | * @param product ProductForm object to send 29 | * @return true if success, otherwise false 30 | * @throws JsonProcessingException when error occurs in amqp process 31 | */ 32 | public boolean sendQueueMessage(ProductForm product) throws JsonProcessingException { 33 | String queueName = "product-queue"; 34 | 35 | String jsonMessage = objectMapper.writeValueAsString(product); 36 | 37 | return messageService.sendQueueMessage(queueName, jsonMessage); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/DataBackendApplication.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.rabbit.annotation.EnableRabbit; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 10 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 11 | 12 | import javax.annotation.PostConstruct; 13 | 14 | @SpringBootApplication 15 | @EnableEurekaClient 16 | @EnableJpaRepositories 17 | @EnableRabbit 18 | public class DataBackendApplication { 19 | private static Logger LOGGER = LoggerFactory.getLogger(DataBackendApplication.class); 20 | 21 | @Value("${info.app.version}") 22 | private String appVersion = null; 23 | 24 | @Value("${info.app.name}") 25 | private String appName = null; 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(DataBackendApplication.class, args); 29 | } 30 | 31 | @PostConstruct 32 | public void writeInfos() { 33 | LOGGER.info("############################################"); 34 | LOGGER.info(" STARTUP"); 35 | LOGGER.info("############################################"); 36 | LOGGER.info("Application Name: " + appName); 37 | LOGGER.info("Application Version: " + appVersion); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/web/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.controller; 2 | 3 | import de.michlb.sample.rabbit.service.MessageService; 4 | import de.michlb.sample.rabbit.web.bean.MessageForm; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.ModelAttribute; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | 14 | /** 15 | * @author Michael Bartsch 16 | */ 17 | @Controller 18 | public class MessageController { 19 | private static final Logger LOGGER = LoggerFactory.getLogger(MessageController.class); 20 | 21 | @Autowired 22 | private MessageService messageService = null; 23 | 24 | @GetMapping("/message") 25 | public String show(Model model) { 26 | 27 | model.addAttribute("messageForm", new MessageForm()); 28 | 29 | return "message"; 30 | } 31 | 32 | @PostMapping("/message") 33 | public String sendMessage(@ModelAttribute MessageForm messageForm, Model model) { 34 | LOGGER.error(String.format("received MessageForm: [%s]", messageForm.toString())); 35 | 36 | messageService.sendQueueMessage("data-queue", messageForm.getMessage()); 37 | 38 | model.addAttribute("messageForm", messageForm); 39 | return "message"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | rabbitmq: 2 | image: rabbitmq:management 3 | ports: 4 | - "5672:5672" #JMS Port 5 | - "15672:15672" #Management Port - default user:pass = guest:guest 6 | 7 | eureka: 8 | image: de.michlb.sample.rabbit/eureka 9 | ports: 10 | # local : container expose 11 | - "8761:8761" 12 | environment: 13 | eureka.instance.hostname: eureka 14 | 15 | spring-boot-admin: 16 | image: de.michlb.sample.rabbit/spring-boot-admin 17 | links: 18 | - eureka 19 | ports: 20 | # local : container expose 21 | - "8083:8080" 22 | environment: 23 | EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/ 24 | 25 | data-backend: 26 | image: de.michlb.sample.rabbit/data-backend 27 | links: 28 | - rabbitmq 29 | - eureka 30 | ports: 31 | # local : container expose 32 | - "8081:8080" 33 | environment: 34 | RABBIT_HOST: rabbitmq 35 | EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/ 36 | 37 | data-care: 38 | image: de.michlb.sample.rabbit/data-care 39 | links: 40 | - rabbitmq 41 | - eureka 42 | ports: 43 | # local : container expose 44 | - "8082:8080" 45 | environment: 46 | RABBIT_HOST: rabbitmq 47 | EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/ 48 | 49 | data-presentation: 50 | image: de.michlb.sample.rabbit/data-presentation 51 | links: 52 | - eureka 53 | - data-backend 54 | ports: 55 | # local : container expose 56 | - "8084:8080" 57 | environment: 58 | EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/ 59 | -------------------------------------------------------------------------------- /data-care/src/main/resources/templates/product.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sender: Product 5 | 6 | 7 | 8 | 9 |

Send Product as Message

10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 | 18 | 20 |
21 |
22 | 23 | 25 |
26 |
27 | 28 | 30 |
31 | 32 |
33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/message/controller/ProductMessageController.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.message.controller; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import de.michlb.sample.rabbit.domain.MessageLog; 5 | import de.michlb.sample.rabbit.domain.Product; 6 | import de.michlb.sample.rabbit.repositories.MessageLogRepository; 7 | import de.michlb.sample.rabbit.repositories.ProductRepository; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * Created by admin on 12.11.16. 16 | */ 17 | @Component 18 | public class ProductMessageController { 19 | private static final Logger LOGGER = LoggerFactory.getLogger(ProductMessageController.class); 20 | 21 | @Autowired 22 | private ProductRepository productRepository = null; 23 | 24 | @Autowired 25 | private ObjectMapper objectMapper = null; 26 | 27 | @Autowired 28 | private MessageLogRepository messageLogRepository = null; 29 | 30 | @RabbitListener(queues = "product-queue") 31 | public void receiveProduct(String productString) { 32 | LOGGER.info(String.format("received Product [%s]", productString)); 33 | messageLogRepository.save(new MessageLog("product-queue", productString)); 34 | 35 | try { 36 | Product newProduct = objectMapper.readValue(productString, Product.class); 37 | productRepository.save(newProduct); 38 | } catch (Exception e) { 39 | LOGGER.error("could not read Product from message", e); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data-care/src/main/java/de/michlb/sample/rabbit/web/controller/ProductCareController.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.web.controller; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import de.michlb.sample.rabbit.service.ProductMessageService; 5 | import de.michlb.sample.rabbit.web.bean.ProductForm; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.ModelAttribute; 13 | import org.springframework.web.bind.annotation.PostMapping; 14 | 15 | /** 16 | * @author Michael Bartsch 17 | */ 18 | @Controller 19 | public class ProductCareController { 20 | private static final Logger LOGGER = LoggerFactory.getLogger(ProductCareController.class); 21 | 22 | @Autowired 23 | private ProductMessageService ProductMessageService = null; 24 | 25 | @GetMapping("/product") 26 | public String show(Model model) { 27 | 28 | model.addAttribute("productForm", new ProductForm()); 29 | 30 | return "product"; 31 | } 32 | 33 | @PostMapping("/product") 34 | public String sendMessage(@ModelAttribute ProductForm productForm, Model model) { 35 | LOGGER.error(String.format("received ProductForm: [%s]", productForm.toString())); 36 | 37 | try { 38 | ProductMessageService.sendQueueMessage(productForm); 39 | } catch (JsonProcessingException e) { 40 | model.addAttribute("error", "message could not be sent: " + e.getMessage()); 41 | LOGGER.error("transfer of object failed", e); 42 | } 43 | 44 | model.addAttribute("productForm", productForm); 45 | return "product"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /data-backend/src/main/java/de/michlb/sample/rabbit/config/RabbitMqConfig.java: -------------------------------------------------------------------------------- 1 | package de.michlb.sample.rabbit.config; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.Queue; 6 | import org.springframework.amqp.core.TopicExchange; 7 | import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer; 8 | import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar; 9 | import org.springframework.beans.factory.annotation.Qualifier; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.messaging.converter.MappingJackson2MessageConverter; 13 | import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; 14 | 15 | /** 16 | * Configuration of RabbitMQ handling 17 | * 18 | * @author Michael Bartsch 19 | */ 20 | @Configuration 21 | public class RabbitMqConfig implements RabbitListenerConfigurer { 22 | 23 | @Bean 24 | Queue dataQueue() { 25 | return new Queue("data-queue", false); 26 | } 27 | 28 | @Bean 29 | Queue productQueue() { 30 | return new Queue("product-queue", false); 31 | } 32 | 33 | @Bean 34 | TopicExchange exchange() { 35 | return new TopicExchange("michlb-sample-exchange:sample"); 36 | } 37 | 38 | @Bean 39 | Binding dataBinding(@Qualifier("dataQueue") Queue queue, TopicExchange exchange) { 40 | return BindingBuilder.bind(queue).to(exchange).with("data"); 41 | } 42 | 43 | @Bean 44 | Binding productBinding(@Qualifier("productQueue") Queue queue, TopicExchange exchange) { 45 | return BindingBuilder.bind(queue).to(exchange).with("product"); 46 | } 47 | 48 | @Bean 49 | MappingJackson2MessageConverter jackson2Converter() { 50 | MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); 51 | return converter; 52 | } 53 | 54 | /** 55 | * give Jackson ObjetMapper to RabbitMq for JSON Mapping 56 | * 57 | * @return 58 | */ 59 | @Bean 60 | DefaultMessageHandlerMethodFactory jsonMessageHandlerMethod() { 61 | DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory(); 62 | factory.setMessageConverter(jackson2Converter()); 63 | 64 | return factory; 65 | } 66 | 67 | @Override 68 | public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) { 69 | rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(jsonMessageHandlerMethod()); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /eureka/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | eureka 7 | jar 8 | eureka 9 | Eureka Server 10 | 11 | 12 | de.michlb.sample.rabbit 13 | sample-parent 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-eureka-server 21 | 22 | 23 | 24 | org.jolokia 25 | jolokia-core 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-maven-plugin 34 | 35 | 36 | 37 | com.spotify 38 | docker-maven-plugin 39 | 0.4.13 40 | 41 | ${project.groupId}/${project.artifactId} 42 | frolvlad/alpine-oraclejdk8:slim 43 | ["java", "-Dserver.port=8761", "-jar", "/${project.build.finalName}.jar"] 44 | 45 | 46 | / 47 | ${project.build.directory} 48 | ${project.build.finalName}.jar 49 | 50 | 51 | 52 | 8761 53 | 54 | 55 | 56 | 57 | build-image 58 | package 59 | 60 | build 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | de.michlb.sample.rabbit 7 | sample-parent 8 | 1.0.0-SNAPSHOT 9 | pom 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.4.2.RELEASE 15 | 16 | 17 | 18 | 19 | UTF-8 20 | UTF-8 21 | 1.8 22 | 1.0.5 23 | de.michlb.sample.rabbit 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-devtools 35 | 36 | 37 | 38 | org.projectlombok 39 | lombok 40 | 41 | 42 | 43 | org.jolokia 44 | jolokia-core 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.cloud 58 | spring-cloud-dependencies 59 | Camden.SR2 60 | pom 61 | import 62 | 63 | 64 | 65 | 66 | 67 | eureka 68 | spring-boot-admin 69 | data-care 70 | data-presentation 71 | data-backend 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /spring-boot-admin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | spring-boot-admin 7 | jar 8 | spring-boot-admin 9 | Spring Boot Admin Server 10 | 11 | 12 | de.michlb.sample.rabbit 13 | sample-parent 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-eureka 21 | 22 | 23 | 24 | org.jolokia 25 | jolokia-core 26 | 27 | 28 | 29 | de.codecentric 30 | spring-boot-admin-server 31 | 1.4.3 32 | 33 | 34 | de.codecentric 35 | spring-boot-admin-server-ui 36 | 1.4.3 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | com.spotify 49 | docker-maven-plugin 50 | 0.4.13 51 | 52 | ${project.groupId}/${project.artifactId} 53 | frolvlad/alpine-oraclejdk8:slim 54 | ["java", "-Dserver.port=8080", "-jar", "/${project.build.finalName}.jar"] 55 | 56 | 57 | / 58 | ${project.build.directory} 59 | ${project.build.finalName}.jar 60 | 61 | 62 | 63 | 8080 64 | 65 | 66 | 67 | 68 | build-image 69 | package 70 | 71 | build 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /data-presentation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | data-presentation 7 | jar 8 | data-presentation 9 | date presentation web ui with spring boot 10 | 11 | 12 | de.michlb.sample.rabbit 13 | sample-parent 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-eureka 21 | 22 | 23 | org.springframework.cloud 24 | spring-cloud-starter-feign 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-ribbon 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-thymeleaf 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.jolokia 41 | jolokia-core 42 | 43 | 44 | 45 | org.webjars 46 | bootstrap 47 | 4.0.0-alpha.5 48 | 49 | 50 | org.webjars 51 | jquery 52 | 3.1.1 53 | 54 | 55 | 56 | org.jetbrains.kotlin 57 | kotlin-stdlib 58 | ${kotlin.version} 59 | 60 | 61 | org.jetbrains.kotlin 62 | kotlin-test 63 | ${kotlin.version} 64 | test 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | org.jetbrains.kotlin 76 | kotlin-maven-plugin 77 | ${kotlin.version} 78 | 79 | 80 | compile 81 | process-sources 82 | 83 | compile 84 | 85 | 86 | 87 | test-compile 88 | process-test-sources 89 | 90 | test-compile 91 | 92 | 93 | 94 | 95 | 96 | 97 | com.spotify 98 | docker-maven-plugin 99 | 0.4.13 100 | 101 | ${project.groupId}/${project.artifactId} 102 | frolvlad/alpine-oraclejdk8:slim 103 | ["java", "-Dserver.port=8080", "-jar", "/${project.build.finalName}.jar"] 104 | 105 | 106 | / 107 | ${project.build.directory} 108 | ${project.build.finalName}.jar 109 | 110 | 111 | 112 | 8080 113 | 114 | 115 | 116 | 117 | build-image 118 | package 119 | 120 | build 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /data-care/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | data-care 7 | jar 8 | data-care 9 | date care web ui with spring boot 10 | 11 | 12 | de.michlb.sample.rabbit 13 | sample-parent 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-eureka 21 | 22 | 23 | org.springframework.cloud 24 | spring-cloud-starter-feign 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-ribbon 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter-stream-rabbit 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-thymeleaf 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | 44 | org.jolokia 45 | jolokia-core 46 | 47 | 48 | 49 | org.webjars 50 | bootstrap 51 | 4.0.0-alpha.5 52 | 53 | 54 | org.webjars 55 | jquery 56 | 3.1.1 57 | 58 | 59 | 60 | org.jetbrains.kotlin 61 | kotlin-stdlib 62 | ${kotlin.version} 63 | 64 | 65 | org.jetbrains.kotlin 66 | kotlin-test 67 | ${kotlin.version} 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | org.jetbrains.kotlin 80 | kotlin-maven-plugin 81 | ${kotlin.version} 82 | 83 | 84 | compile 85 | process-sources 86 | 87 | compile 88 | 89 | 90 | 91 | test-compile 92 | process-test-sources 93 | 94 | test-compile 95 | 96 | 97 | 98 | 99 | 100 | 101 | com.spotify 102 | docker-maven-plugin 103 | 0.4.13 104 | 105 | ${project.groupId}/${project.artifactId} 106 | frolvlad/alpine-oraclejdk8:slim 107 | ["java", "-Dserver.port=8080", "-jar", "/${project.build.finalName}.jar"] 108 | 109 | 110 | / 111 | ${project.build.directory} 112 | ${project.build.finalName}.jar 113 | 114 | 115 | 116 | 8080 117 | 118 | 119 | 120 | 121 | build-image 122 | package 123 | 124 | build 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /data-backend/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | data-backend 7 | jar 8 | data-backend 9 | RESTful service to import and store data via RabbitMQ 10 | 11 | 12 | de.michlb.sample.rabbit 13 | sample-parent 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-eureka 21 | 22 | 23 | org.springframework.cloud 24 | spring-cloud-starter-feign 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-ribbon 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter-stream-rabbit 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-jpa 37 | 38 | 39 | 40 | org.jolokia 41 | jolokia-core 42 | 43 | 44 | 45 | org.webjars 46 | bootstrap 47 | 4.0.0-alpha.5 48 | 49 | 50 | org.webjars 51 | jquery 52 | 3.1.1 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-thymeleaf 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-web 62 | 63 | 64 | 65 | com.h2database 66 | h2 67 | runtime 68 | 69 | 70 | 71 | org.jetbrains.kotlin 72 | kotlin-stdlib 73 | ${kotlin.version} 74 | 75 | 76 | org.jetbrains.kotlin 77 | kotlin-test 78 | ${kotlin.version} 79 | test 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | 90 | 91 | org.jetbrains.kotlin 92 | kotlin-maven-plugin 93 | ${kotlin.version} 94 | 95 | 96 | compile 97 | process-sources 98 | 99 | compile 100 | 101 | 102 | 103 | test-compile 104 | process-test-sources 105 | 106 | test-compile 107 | 108 | 109 | 110 | 111 | 112 | 113 | com.spotify 114 | docker-maven-plugin 115 | 0.4.13 116 | 117 | ${project.groupId}/${project.artifactId} 118 | frolvlad/alpine-oraclejdk8:slim 119 | ["java", "-Dserver.port=8080", "-jar", "/${project.build.finalName}.jar"] 120 | 121 | 122 | / 123 | ${project.build.directory} 124 | ${project.build.finalName}.jar 125 | 126 | 127 | 128 | 8080 129 | 130 | 131 | 132 | 133 | build-image 134 | package 135 | 136 | build 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------