Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Spring Boot and Spring Cloud Inside NissanConnect at SPRING FEST '19

4,041 views

Published on

Example and tips about production microservices in NissanConnect with Spring Boot and Spring Cloud.

Published in: Engineering
  • Hi there! I just wanted to share a list of sites that helped me a lot during my studies: .................................................................................................................................... www.EssayWrite.best - Write an essay .................................................................................................................................... www.LitReview.xyz - Summary of books .................................................................................................................................... www.Coursework.best - Online coursework .................................................................................................................................... www.Dissertations.me - proquest dissertations .................................................................................................................................... www.ReMovie.club - Movies reviews .................................................................................................................................... www.WebSlides.vip - Best powerpoint presentations .................................................................................................................................... www.WritePaper.info - Write a research paper .................................................................................................................................... www.EddyHelp.com - Homework help online .................................................................................................................................... www.MyResumeHelp.net - Professional resume writing service .................................................................................................................................. www.HelpWriting.net - Help with writing any papers ......................................................................................................................................... Save so as not to lose
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • My whole life has changed. Your program has made a remarkable difference. My blood sugar level is normal. I have more energy than ever. I have lost weight. And, I am excited to be able to help others to achieve good health ... all this, because I decided to download your book. Saying thank you does not seem to be strong enough. But God bless you and your work, just begins to express my feelings. ♥♥♥ http://ishbv.com/matt1a/pdf
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Spring Boot and Spring Cloud Inside NissanConnect at SPRING FEST '19

  1. 1. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. , . 8 1/ L C 9 2 88 9 2 8 0 / 8 1 /1 DBL . 1 8 . , . 8 8 8 0
  2. 2. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n Java 20 Swing UI ) n Java n 2019 4 & n 2
  3. 3. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 3 e ea N 1 C .. 5 c 4 N3 2
  4. 4. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 4 e ea N 1 C .. 5 c 4 N3 2
  5. 5. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 5 n “CASE” – C (Connected) – A (Autonomous) – S (Shared & Services) – E (Electric)
  6. 6. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 6 https://www3.nissan.co.jp/connect/service_skyline/service.html
  7. 7. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n n to n n n push n n n 7 https://www3.nissan.co.jp/connect/service_skyline/service.html
  8. 8. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. https://www.amazon.co.jp/NISSAN-MOTOR-CO-LTD-LEAF/dp/B074KCT1SY • EV Alexa Skill • Alexa
  9. 9. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. https://play.google.com/store/apps/details?id=com.aqsmartphone.android.nissan_jp • • EV(Electric Vehicle) EV • NissanConnect
  10. 10. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. https://play.google.com/store/apps/details?id=jp.co.nissan.nissanconnect.ice • • ICE(Internal Combustion Engine) ICE • NissanConnect (
  11. 11. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n Web n n 11
  12. 12. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n – – – (E2E ) nWeb – – validation 12
  13. 13. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 13 e ea N 1 C .. 5 c 4 N3 2
  14. 14. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. System Overview (End to End) 14 Car GatewayService Layer Backends (IS/IT) Telematics Service Provider
  15. 15. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. System Overview (Cloud) 15 Car Gateway GenX Alliance Service Layer Backends ( Alliance Platform) Nissan Service Layer Backends Nissan Backend For Frontend Car Gateway GenY Car Gateway abstraction IS/IT TSP Integration
  16. 16. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. System Overview (Cloud) 16 Car Gateway GenX Alliance Service Layer Backends ( Alliance Platform) Nissan Service Layer Backends Nissan Backend For Frontend Car Gateway GenY Car Gateway abstraction IS/IT TSP Integration SpringSpring Spring
  17. 17. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. System Overview (Cloud) 17 Car Gateway GenX Alliance Service Layer Backends ( Alliance Platform) Nissan Service Layer Backends Nissan Backend For Frontend Car Gateway GenY Car Gateway abstraction IS/IT TSP Integration SpringSpring Spring
  18. 18. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n PaaS –Microsoft Azure(VM, Database, Monitor, CosmosDB) –Pivotal Cloud Foundry( PCF) –RabbitMQ –Jenkins(Build, Unit Test, Code Check, Deployment…) n Framework –Java/Spring Boot –Node.js/Express 18
  19. 19. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Spring nSpring Boot(Web, JPDA, Redis, RabbitMQ, Security, Actuator) nSpring Cloud Sleuth nSpring Cloud Stream nSpring Cloud Netflix Zuul nSpring Cloud Config, Spring Cloud Bus( ) nSpring Cloud Circuit Breaker( RC) 19
  20. 20. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 20 e ea N 1 C .. 5 c 4 N3 2
  21. 21. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect n – NissanConnect – 21
  22. 22. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 22
  23. 23. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n –Alliance Platform – –NissanConnect EV 23
  24. 24. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n –Alliance Platform – Car Gateway Alliance Platform –Java / Spring Boot 24
  25. 25. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) 25 Alliance Platform (many microservices) Car Gateway AdaptationModule Platform Spring Boot Microservices Car Gateway EV
  26. 26. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n –NissanConnect EV Alliance Platform – CarGateway Alliance Platform • contribution • Car Gateway –Alliance Platform • breaking change 26
  27. 27. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 27
  28. 28. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – –NissanConnect EV – ( IS/IT ) Integration – Car Gateway 28
  29. 29. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – IS/IT Integration –Java / Spring Boot – –Alliance Platform (bug, breaking change…) 29
  30. 30. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) 30 Alliance Platform (many microservices) Car Gateway ICE Nissan Backend (monolith) Zuul Proxy IS/IT Rest API Global Zuul Proxy Integration Spring Web /alliance proxy Spring Web /nissan
  31. 31. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) 31 IS/IT Spring Boot Application HandlerIntercepter Spring Web Controller ZuulFilter Zuul Proxy Spring Web Zuul
  32. 32. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – IS/IT backend – Spring Boot • Alliance Platform Zuul Proxy • API Spring Web 32
  33. 33. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Spring Cloud Netflix Zuul n – – API Gateway – https://cloud.spring.io/spring-cloud-netflix/reference/html/#router-and-filter-zuul n Maven dependency n application.properties 33 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId> </dependency> # zuul.routes.foo.path=/alliance/foo/v1/** # zuul.routes.foo.url=${foo.domain}/v1/**
  34. 34. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Spring Cloud Netflix Zuul n Spring Web Spring Cloud Netflix Zuul n Timeout 34 @EnableZuulProxy // Zuul Proxy @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } zuul.host.connect-timeout-millis=5000 zuul.host.socket-timeout-millis=65000
  35. 35. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Spring Cloud Netflix Zuul n – ZuulFilter ErrorController – “filterZuulException” 35 @RestController public class ZuulErrorController extends AbstractErrorController { @Value("${error.path:/error}") private String errorPath; @Override public String getErrorPath() { return errorPath; } @RequestMapping(value = "${error.path:/error}", produces = "application/vnd.api+json;charset=UTF-8") public ResponseEntity error(HttpServletRequest request) {
  36. 36. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Spring Cloud Netflix Zuul n 36 @Component public class AllianceErrorFilter extends ZuulFilter { @Override public String filterType() { return "post"; } @Override public boolean shouldFilter() { RequestContext ctx = RequestContext.getCurrentContext(); if(ctx.getRequest().getRequestURI().contains("/alliance") && ctx.getResponse().getStatus() != 200) { return true; } return false; } @Override public Object run() {
  37. 37. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 37
  38. 38. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – – 38
  39. 39. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – – – done →PJ 39
  40. 40. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) 40 Alliance Platform (many microservices) Car Gateway Nissan Backend For Frontend (BFF) Nissan Service Layer Backends (divided as microservice) Nissan Backend (monolith) ICE PJ IS/IT backend PJ microservice Spring Boot API Gateway Backend For Frontend( BFF) PJ
  41. 41. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – Backend For Frontend – Microservice – – 41
  42. 42. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 42
  43. 43. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – – – Alliance Platform • Alliance Platform 43
  44. 44. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – backend • IS/IT • Deploy • ( RR ) –Microservices • • 44
  45. 45. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Nissan Service Layer Backends (divided as microservice) Nissan Backend For Frontend (BFF) NissanConnect ( ) 45 Alliance Platform (many microservices) Car Gateway Nissan Backend For Frontend (BFF) Nissan Backend for IS/IT ICE PJ IS/IT Backend IS/IT BFF ICE BFF
  46. 46. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. NissanConnect ( ) n – RR Microservice – –Microservice • Spring Cloud Config • Spring Cloud Circuit Breaker + Rejilience4J 46
  47. 47. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n n n 47
  48. 48. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. e ea N 1 C .. 48 5 c 4 N3 2
  49. 49. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n – Microservices – • • • (on going) • PCF / Spring Boot Actuator 49
  50. 50. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n – Spring Boot slf4j + logback – Spring Boot Profile – Profile logback-spring.xml n – • • ( 1 ) – Azure Log Analytics • JSON • 1 ( 1 ) 50
  51. 51. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n logback-spring.xml – logback.xml – springProfile Profile 51 <?xml version="1.0"?> <configuration> <springProfile name = "prod"> <!-- prod --> </springProfile> <springProfile name="!(prod | local)"> <!– prod, local --> </springProfile> <springProfile name="local"> <!– local --> </springProfile> </configuration>
  52. 52. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n Microservice 52
  53. 53. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n Microservice 53 HTTP HTTP ServletFilter AutoConfiguration HTTP HTTP RestTemplate ClientInterceptor AutoConfiguration RabbitMQ RabbitTemplate Aspect AutoConfiguration RabbitMQ SimpleRabbitListenerContainerFactory Advice RabbitListener JavaConfig
  54. 54. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n – Microservice – Spring Cloud Sleuth – https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.2.0.RELEASE/reference/html/ n Maven dependency n Sample (logging) – traceId: The ID of the latency graph that contains the span. ( ) – spanId: The ID of a specific operation that took place. ( ) 54 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency> 2019-12-18 14:30:56.901 INFO [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23031 --- [nio-8081-exec-3] ... 2019-12-18 14:30:59.373 ERROR [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23031 --- [nio-8081-exec-3] ... 2016-12-18 14:31:02.939 INFO [bar,46ab0d418373cbc9,46ab0d418373cbc9,false] 23031 --- [nio-8081-exec-4] ...
  55. 55. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. 55 n – Azure Monitor • Top10 – • micrometer(https://micrometer.io/) • Microsoft app insight(Alliance Platform )
  56. 56. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. PCF / Spring Boot Actuator n – PCF deploy Spring Boot Spring Boot Actuator PCF App Manager UI – – PCF /cloudfoundryapplication – /${service-context}/actuator/${endpoint} PCF n – https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html – https://docs.pivotal.io/platform/application-service/2-7/console/spring-boot-actuators.html 56
  57. 57. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. PCF / Spring Boot Actuator n Tips – spring-boot-maven-plugin build-info target jar – PCF App Manager UI deploy 57 <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.4.2.RELEASE</version> <executions> <execution> <goals> <goal>build-info</goal> <!– --> </goals> </execution> </executions> </plugin> </plugins> </build>
  58. 58. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. PCF / Spring Boot Actuator n Tips – Deploy Spring Boot Servlet Context /cloudfoundryapplication servlet context – https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready-cloudfoundry 58 @Bean public TomcatServletWebServerFactory servletWebServerFactory() { return new TomcatServletWebServerFactory() { @Override protected void prepareContext(Host host, ServletContextInitializer[] initializers) { super.prepareContext(host, initializers); StandardContext child = new StandardContext(); child.addLifecycleListener(new Tomcat.FixContextListener()); child.setPath("/cloudfoundryapplication"); ServletContainerInitializer initializer = getServletContextInitializer(getContextPath()); child.addServletContainerInitializer(initializer, Collections.emptySet()); child.setCrossContext(true); host.addChild(child); } }; } private ServletContainerInitializer getServletContextInitializer(String contextPath) { return (c, context) -> { Servlet servlet = new GenericServlet() { @Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { ServletContext context = req.getServletContext().getContext(contextPath); context.getRequestDispatcher("/cloudfoundryapplication").forward(req, res); } }; context.addServlet("cloudfoundry", servlet).addMapping("/*"); }; }
  59. 59. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n n n PCF + Actuator 59
  60. 60. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. e ea N 1 C .. 60 5 c 4 N3 2
  61. 61. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n – Microservices Microservice – 61
  62. 62. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Auto Reconfiguration by Java Buildpack n –Spring Boot PCF deploy DB Datasource – Spring Boot 62
  63. 63. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. Auto Reconfiguration by Java Buildpack 63 @Profile("cloud") @Configuration public class CloudFoundryConfig { @Bean public Cloud cloud() { return new CloudFactory().getCloud(); } @Bean @ConfigurationProperties(prefix = "spring.datasource") public DataSource dataSource() { DataSource ds = cloud().getSingletonServiceConnector(DataSource.class, null); return (ds instanceof DelegatingDataSource) ? ((DelegatingDataSource) ds).getTargetDataSource() : ds; } } n – Java Buildpack Auto Reconfiguration Datasource – Cloud JavaConfig – Datasource @ConfigurationProperties – return
  64. 64. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. RestTemplate with Apache HttpClient 64 n – RestTemplate java.net.HttpUrlConnection HTTP – HttpClient RestTemplate HttpClient
  65. 65. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. RestTemplate with Apache HttpClient n – HttpClient (PoolingHttpClientConnectionManager) 65 maxConnPerRoute 2 maxConnTotal 20
  66. 66. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. RestTemplate with Apache HttpClient n LoadBalancer – LB (Azure LB 4min(240sec) ) – TCP/IP FIN HttpClient Timeout 66 Spring Boot Application LB FIN FIN
  67. 67. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. RestTemplate with Apache HttpClient n – HttpClientBuilder JavaConfig – LB TimeToLive – HTTP (Redis ) 67 public ClosableHttpClient httpClient() { return HttpClients.custom() .setMaxConnPerRoute(routeMaxConnection) // set max connection .setMaxConnTotal(totalMaxConnection) // set max connection .setConnectionTimeToLive(180, TimeUnit.SECONDS) // set connection ttl to 180s .evictExpiredConnections() // enable evict expired connection .build(); }
  68. 68. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n DB n RedisTemaplate 68
  69. 69. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n Microservices n n HTTP n PCF Auto Reconfiguration 69
  70. 70. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved.
  71. 71. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. n Spring Boot Microservices n Microservices n n 71
  72. 72. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. ! Wantedly https://www.wantedly.com/projects/333155
  73. 73. (C) Copyright NISSAN MOTOR CO., LTD. 2019 All rights reserved. ! !

×