Mastering Microservices with Java-Packt Publishing(2016) 读书笔记

Mastering Microservices with Java-Packt Publishing(2016)-ReadingNotes.md

A Solution Approach

  • ignite v. 点燃 ~ your mind as a solution architect
  • monolithic n. 单一的,整个的 (vs isomorphic)

开发环境配置

  • NetBeans IDE(如果用NodeJS的话根本不必用什么IDE,Sublime或者VSCode足够了)
  • Spring Boot
    • “It is better to make Jar, not War.” //我估计这都是跟Go语言学的?
    • Maven pom.xml(这个就像是NodeJS里面的package.json)
    • Jetty允许从jar中读取key或trusted stores内容(Tomcat不行吗?)
    • resource model类 in POJO(Java这种静态编译类型语言就这么个不好的地方!)
    • 针对controller类的annotation://太繁琐了
      • @RestController = @Controller + @ResponseBody
      • @RequestMapping //定义url路由?
        • @RequestParam 把url查询参数映射到controller的方法参数
        • @PathVariable 动态映射?基于正则表达式?
    • app类的标注:
      • @SpringBootApplication,其他:
        • @Configuration
        • @EnableAutoConfiguration
        • @EnableWebMvc:激活DispatcherServlet
        • @ComponentScan
    • 标注(但仍然是侵入式的):没有xml配置,甚至不需要web.xml!
    • 运行app:
      • pom.xml目标:spring-boot:run
      • mvn clean生成jar

DDD

  • Artifacts of domain-driven design
    • 实体(具有ID的)—— 意味着在ORM里与数据库持久层是bind的?有必要吗
    • 值对象(VO):immutable
    • 服务:提供行为,没有内部状态(意味着只是个接口类?)
    • Aggregates(聚合)
      • aggregate root(controller类?)
      • Relationships, constraints, and invariants bring a complexity that requires an efficient handling in code.
    • Repository:与基础架构层(文件系统/数据库)交互
    • Factory:创建复杂对象
    • Modules
  • Strategic design and principles(管理大型企业models)
    • Bounded context(注意:系统的不同角色用户看到的是不同上下文视图)
    • Continuous integration
    • Context map(同样的名称可能出现在不同的context里,但它们本质上是不同的models,概念细分)
      • Shared kernel(共享)
      • Customer-supplier(输入输出依赖)
      • Conformist(团队之间有上下游关系?什么鬼)
      • Anticorruption layer(隔离外部/遗留系统)
      • Separate ways(大集成?)
      • Open host service(当外部系统被多个submodels使用时,创建一个单独的转换层)
      • Distillation(过滤出无用信息,只保留必需的code domain concept)
  • DDD:既不是自顶向下地先做UI,也不是自底向上地先做DB设计(!)—— 我觉得这其实是在做细化的需求分析而已
    • 一开始的DDD是基于interface,而不是*Impl的吗?
  • 实现
    • 使用in-memory仓库来做mock测试?

实现一个微服务(OTRS?这么喜欢用缩略语?zb)

  • controller类:构建服务endpoints
    • API版本化(*)
    • 服务类
     @Service("restaurantService")
     public class RestaurantServiceImpl extends BaseService<Restaurant, String>
         implements RestaurantService {
         ...
    
    • Repository类实现:使用JPA
  • 服务注册与发现(SOA术语)
    • Spring Cloud provides state-of-the-art support to Netflix Eureka, a service registry and discovery tool.
  • 测试
    • RestaurantControllerTests
     @RunWith(SpringJUnit4ClassRunner.class)
     @SpringApplicationConfiguration(classes = RestaurantApp.class)
     public class RestaurantControllerIntegrationTests extends
         AbstractRestaurantControllerTests {
         ...
     }
    

部署与测试

“Spring took the opportunity to integrate many Netflix OSS projects, such as Zuul, Ribbon(客户端LB), Hystrix, Eureka Server(服务注册), and Turbine, into Spring Cloud.”

Ribbon用于微服务之间通信:

1. restTemplate,或:
2. @FeignClient ?

服务器端LB:“Zuul is a JVM-based router and server-side load balancer.”

* 在pom.xml中定义好依赖,然后app类上使用`@EnableZuulProxy`
	* zuul:application.yml ?

Hystrix as a circuit breaker

Monitoring:Turbine,通过RabbitMQ连接到Hystrix

部署到容器:

* 4G内存:docker-machine create -d virtualbox --virtualbox-memory 4096 default
* Building Docker images with Maven(略)

安全:OAuth 2.0

  • 启用TLS(HTTPS)
  • OAuth 1.0 relies on security certificates and channel binding.
    • 而 2.0 “works completely on Transport Security Layer (TSL).”
  • OAuth 2.0 4种角色:
    • Resource owner(用户自己)
    • Resource server(第3方)
    • Client(当前需要授权的页面)
    • Authorization server(提供access tokens和refresh tokens)
  • grant types:略
  • OAuth implementation using Spring Security

消费微服务:WebApp

  • AngularJS(哈哈,哈)
  • 为什么这本书里还是用的Gulp?

最佳实践与公共原则

  • Reliability monitoring service – Simian Army(各种Monkeys)
    • “Janitor Monkey: Janitor Monkey is a service which runs in the AWS cloud looking for unused resources to clean up.”(这里似乎不如部署Kubernetes算了)
  • Scheduler for Apache Mesos – Fenzo

故障排除指南

  • ELK
  • Use of correlation ID for service calls
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Master the art of implementing scalable and reactive microservices in your production environment with Java 11 Microservices are key to designing scalable, easy-to-maintain applications. This latest edition of Mastering Microservices with Java, works on Java 11. It covers a wide range of exciting new developments in the world of microservices, including microservices patterns, interprocess communication with gRPC, and service orchestration. This book will help you understand how to implement microservice-based systems from scratch. You’ll start off by understanding the core concepts and framework, before focusing on the high-level design of large software projects. You’ll then use Spring Security to secure microservices and test them effectively using REST Java clients and other tools. You will also gain experience of using the Netflix OSS suite, comprising the API Gateway, service discovery and registration, and Circuit Breaker. Additionally, you’ll be introduced to the best patterns, practices, and common principles of microservice design that will help you to understand how to troubleshoot and debug the issues faced during development. By the end of this book, you’ll have learned how to build smaller, lighter, and faster services that can be implemented easily in a production environment. What you will learn Use domain-driven designs to develop and implement microservices Understand how to implement microservices using Spring Boot Explore service orchestration and distributed transactions using the Sagas Discover interprocess communication using REpresentational State Transfer (REST) and events Gain knowledge of how to implement and design reactive microservices Deploy and test various microservices contents 1 A Solution Approach 2 Environment Setup 3 Domain-Driven Design 4 Implementing a Microservice 5 Microservice Patterns – Part 1 6 Microservice Patterns – Part 2 7 Securing Microservices 8 Consuming Services Using the Angular App 9 Inter-Process Communication Using REST 10 Inter-Process Communication Using gRPC 11 Inter-Process Communication Using Events 12 Transaction Management 13 Service Orchestration 14 Troubleshooting Guide 15 Best Practices and Common Principles 16 Converting a Monolithic App to a Microservice-Based App
Mastering Microservices with Java, 3rd Edition: Master the art of implementing scalable and reactive microservices in your production environment with Java 11 Microservices are key to designing scalable, easy-to-maintain applications. This Mastering Microservices with Java, Third Edition, works on Java 11. It covers a wide range of exciting new developments in the world of microservices, including microservices patterns, interprocess communication with gRPC, and service orchestration. This book will help you understand how to implement microservice-based systems from scratch. You’ll start off by understanding the core concepts and framework, before focusing on the high-level design of large software projects. You’ll then use Spring Security to secure microservices and test them effectively using REST Java clients and other tools. You will also gain experience of using the Netflix OSS suite, comprising the API Gateway, service discovery and registration, and Circuit Breaker. Additionally, you’ll be introduced to the best patterns, practices, and common principles of microservice design that will help you to understand how to troubleshoot and debug the issues faced during development. What You Will Learn Use domain-driven designs to develop and implement microservices Understand how to implement microservices using Spring Boot Explore service orchestration and distributed transactions using the Sagas Discover interprocess communication using REpresentational State Transfer (REST) and events Gain knowledge of how to implement and design reactive microservices Deploy and test various microservices By the end of this book, you’ll have learned how to build smaller, lighter, and faster services that can be implemented easily in a production environment.
Big data – that was our motivation to explore the world of machine learning with Spark a couple of years ago. We wanted to build machine learning applications that would leverag models trained on large amounts of data, but the beginning was not easy. Spark was still evolving, it did not contain a powerful machine learning library, and we were still trying to figure out what it means to build a machine learning application. But, step by step, we started to explore different corners of the Spark ecosystem and followed Spark’s evolution. For us, the crucial part was a powerful machine learning library, which would provide features such as R or Python libraries did. This was an easy task for us, since we are actively involved in the development of H2O’s machine learning library and its branch called Sparkling Water, which enables the use of the H2O library from Spark applications. However, model training is just the tip of the machine learning iceberg. We still had to explore how to connect Sparkling Water to Spark RDDs, DataFrames, and DataSets, how to connect Spark to different data sources and read data, or how to export models and reuse them in different applications. During our journey, Spark evolved as well. Originally, being a pure Scala project, it started to expose Python and, later, R interfaces. It also took its Spark API on a long journey from low-level RDDs to a high-level DataSet, exposing a SQL-like interface. Furthermore, Spark also introduced the concept of machine learning pipelines, adopted from the scikit-learn library known from Python. All these improvements made Spark a great tool for data transformation and data processing. Based on this experience, we decided to share our knowledge with the rest of the world via this book. Its intention is simple: to demonstrate different aspects of building Spark machine learning applications on examples, and show how to use not only the latest Spark features, but also low-level Spark interfaces. On our journey
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值