spring-boot-reactive-example
ตัวอย่างการเขียน Java Spring-boot Reactive (WebFlux) ซึ่งเป็นการเขียน Spring-boot แบบ Non-Blocking I/O หรือ Asynchronous
ปัญหา / ข้อเสนอแนะ
หากพบปัญหา หรือ ต้องการให้ทำอะไรเพิ่ม รบกวนช่วยเปิด issue ให้ด้วยน่ะครับ
ขอบคุณครับ :)
เอกสาร Spring
ข้อแตกต่าง
WebFlux Performance
- SpringBoot 2 performance — servlet stack vs WebFlux reactive stack
- Spring Boot performance battle: blocking vs non-blocking vs reactive
- https://blog.ippon.tech/spring-5-webflux-performance-tests/
Prerequisites
สิ่งที่ต้องรู้ก่อนเขียน Spring-boot Reactive
- java 11+ ตอนนี้ผมใช้ OpenJdk 11
- Apache Maven
- Reactive Programming ลองอ่านนี่ดูได้ครับ RxJava series - part 1 - ตอน อะไรเอ่ย ReactiveX? ขอบคุณสำหรับบทความครับ
- Spring-boot ใช้ Reactor ซึ่งเป็น lib reactive ตัวนึง มีความคล้ายกันกับ ReactiveX สามารถอ่านทฤษฎีแทนกันได้ Concept เหมือนกัน
- Event Loop
ตัวอย่างการเขียน Reactor
เริ่ม
Code บางตัวอาจจะไม่สามารถเอาไป Run ได้เลย เนื่องจากต้องเตรียม environment ต่าง ๆ ให้พร้อมก่อน เช่น Postgresql, Mongodb, Redis เป็นต้น ต้องมี database หรือ data source ปลายทางก่อน
ให้เรียนรู้/ดูตัวอย่างตามลำดับต่อไปนี้
ปรับ Code เป็น Java 11 แล้ว
- spring-boot-reactive-helloworld - Hello World!
- spring-boot-reactive-dockerfile - การเขียน Dockerfile, การ Build Docker Image และการ Run Container
- spring-boot-reactive-jenkinsfile - การเขียน Jenkinsfile
- spring-boot-reactive-logging - การ Config และใช้งาน Logging
- spring-boot-reactive-controller - การเขียน Controller
- spring-boot-reactive-form-data - การรับค่าจาก Html Form
- spring-boot-reactive-download-file - การ Download File
- spring-boot-reactive-upload-file - การ Upload File
- spring-boot-reactive-session - พื้นฐานการใช้ Session
- spring-boot-reactive-cookie - พื้นฐานการใช้ Cookie
- spring-boot-reactive-configuration-properties - การอ่าน Config จาก application.properties
- spring-boot-reactive-thymleaf - การใช้ Thymleaf ทำ View (Server Site) Rendering (HTML)
- spring-boot-reactive-web-filter - การเขียน Web Filter
- spring-boot-reactive-error-handler - การจัดการ Exception หรือ Error
- spring-boot-reactive-custom-error-handler - การ Custom ตัวจัดการ Exception หรือ Error
- spring-boot-reactive-validation - การ Validate ข้อมูล
- spring-boot-reactive-manual-validation - การ Validate ข้อมูลแบบ Manual
- spring-boot-reactive-custom-validator - การ custom validator
- spring-boot-reactive-scheduling - การ Run Job/Task แบบ Scheduling
- spring-boot-reactive-unit-test-junit5 - การเขียน Unit Test ด้วย JUnit 5
- spring-boot-reactive-oauth-client - การเขียน Code เพื่อ Login ผ่าน OAuth ของ Google, Facebook
- spring-boot-reactive-google-cloud-storage - การเขียน Code เพื่อเชื่อมต่อกับ Google Cloud
- spring-boot-reactive-digitalocean-spaces - การเขียน Code เพื่อเชื่อมต่อกับ DigitalOcean Spaces
รอการปรับ Code เป็น Java 11
- spring-boot-webflux-unit-test-mockito - การเขียน Unit Test + Mockito
- spring-boot-webflux-test-coverage - Test Coverage ด้วย JaCoCo
- spring-boot-webflux-security - พื้นฐานการ Config Spring Security สำหรับทำการ Login
- spring-boot-webflux-custom-login-page - การ custom หน้า login
- spring-boot-webflux-security-authority - การกำหนดสิทธิ์การเข้าถึง
- spring-boot-webflux-postgresql - การเชื่อมต่อ Postgresql (Relational Database)
- spring-boot-webflux-pagination - การทำ Pagination
- spring-boot-webflux-jdbc-template - การเขียน Native Query จาก JDBC Template
- spring-boot-webflux-entity - การเขียน Entity Class
- spring-boot-webflux-simple-service - พื้นฐานการเขียน Service
- spring-boot-webflux-mongodb - การเชื่อมต่อ Mongodb (NoSQL Document Database)
- spring-boot-webflux-mongo-operations - การเขียน Query ผ่าน Mogo Operations
- spring-boot-webflux-redis - การเชื่อมต่อ Redis (Key/Value NoSQL)
- spring-boot-webflux-nuxtjs - การเขียน Spring-boot Reactive + Nuxt.js
- spring-boot-webflux-javadoc - การ Generate Java Document API