yaahsin

@yaahsin

Joined on Feb 18, 2023

  • BFF實作Spring Security spring boot層層filter, 安全控制設定為一個被稱為springSecurityFilterChain的Servlet filter,使用@EnableWebSecurity anonotation 對應用程式所有 URL 作驗證 允許使用者登出 阻絕 CSRF 攻擊 防止 Session Fixation ...... Spring Secutiry key concept
     Like  Bookmark
  • image Figure. 高層次抽象, 以JPA為例 image Figure. Repository interfaces: 藍色為spring data核心interface :microscope: Specification 動態條件查詢 JPA提供Criteria查詢, Spring Data JPA則對Criteria進行封裝 api interface: SpecificationExecutorlong count(Specification<T> spec);
     Like  Bookmark
  • Ticket Selling Service NoSQL database: Redis Monitoring tools: Prometheus + Grafana ticket-selling-architecture Figure. 服務及監控架構 說明: 本服務為票券登錄系統(Restful API),使用者短時間內湧入高量請求,為增進存取資料操作效率,採用Redis,在監控部分,以Prometheus收集指標,搭配Grafana將資料視覺化,提供予監控程式情況,並能設立規則主動發出警告
     Like  Bookmark
  • Spring Boot Application health monitor Actuator module收集內部info, 可以透過http或jmx取得 health check, metric, httptrack etc, 輔助監控及管理spring boot application, 另外也能結合外部監控系統, 像是Prometheus,Grafana, 利用dashboard, analysis, alert等進階操作 Spring Boot Actuator 導入actuator的depenedency 及接合外部系統的micrometer(如: ptometheus) <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
     Like  Bookmark
  • 如何構建Project: Intro to Maven Maven是常用的build tool, 依循預定義的資料結構(predifined folder sturcture),主要的特色為套件管理, 套件有分direct(需配置)和transitive(傳遞依賴), 透過pom.xml, maven指令進行操作; 另外常見的build tool還有gradle 套件管理(Frameworks & libraries used in a project),使用pom.xml設定, 指定要載入的library(dependency):Parent Pom: spring-boot-starter-parentdependency management套件版控: spring-boot-dependencies 套件denpendencies: 中央repository藉由artifact及group Id做錨定來源單位groupId 成品jar檔artifactId 版本version: 通常parent會管控部分套件版本,若有特殊需求或其他未納管的dependencies會用到此tag 執行範圍scope:compile(default) test: 運行時不需要, 單純為test purpose, 常見在Test dependencies provided: at runtime by JDK or a container, 例如部署在container上的web app, 環境已提供部分libraries
     Like  Bookmark
  • 起: 後端為microservice架構時,前端最單純就是直接與各服務溝通,「direct client to microservice communication」 client 與服務高度耦合,不易維護 多個round trip,可能增加latency 安全性隱憂,Endpoints向外暴露 Cross Cutting Concerns,相同邏輯橫切多個模組 承: api gateway 為一層proxy layer,除去原本前端對每個後端系統的高耦合性,並且減少network request 可以作為 Reverse Proxy Layer 7 的 Routing,使 Client Side 與 Services 解耦,達到關注點分離 便於轉移後端應用架構,如monolithic refactor to microservice
     Like 1 Bookmark
  • Optional (java.util.Optional) 處理NullPointerException議題 1. Lambda expression (args) -> body 可以使用函數式程式的結構,適用於將動作作為參數給method的情況 lambda表達是對象, 依賴函數interface, 變成函數式的表達;是函數式接口的instance就能用lambda處理,只處理這個method",因此語法概念就是"省略不必要的字":Class method 變數型態
     Like  Bookmark
  • [THREAD] JAVA執行緒 :::info :bulb: Before the 1:1 meeting, ask the manager and employee to fill in the answer. You can design questions according to your needs. ::: :white_check_mark: 何謂執行緒 1. 前言介紹 program 程式: code的集合,尚未load進記憶體,可以被執行多次(有多個process),靜態的程式碼 process 程序: 是被電腦執行的程式實體(instance),包含有code、系統資源(像是memory, file, i/o devices),變成可被執行狀態,例如我們點開應用程式的行為,就是在將program化為process,包含有memory space跟thread(s),可以藉由inter-process communication(IPC) mechanisms相互溝通。 thread 執行緒: 程序的次單位,每個thread有自己的program counter, stack及Local變數,CPU調度級分派的基本單位,包含在程序當中,共享程序當中的資源及memory space,各負責一個功能,可以在單一的執行緒當中,執行多個tasks,也就是說執行緒是一連串的指示,在同一個程式當中,各個執行緒能獨立並行執行tasks. thread溝通方式,可以透過shared memory, synchronization機制(LOCK)或SEMAPHORES(旗號)<!--特定數值的號誌,根據情境做加減,當數值為0時為unsignaled 大於0時為signaled,依情況管理執行緒對資源的操作,不過無法保證進入順序-->或condition變數
     Like  Bookmark
  • 最直觀的方法就是delete,但這種方法效率不好,而且可能data被其它session擋住,解法為(oracle db適用): :bulb::bulb::bulb: 將DML操作改為DDL操作 移除全部內容:truncate 使用create-table-as-select 移除大部分的data drop或truncate patition 使用filtered table move DML statement 刪除rows
     Like  Bookmark
  • :::warning :dromedary_camel: 基於企業整合模式EIP(enterprise integration patterns)設計的開源框架,使用component的方式接入第三方系統,便於快速簡單整合不同系統做處理及生產data -> 直接使用URLs來串接不同的傳輸或訊息模型,像是HTTP、kafka、cxf -> 包含有消息路由及轉換等特定領域語言(DSL) ::: :japanese_castle: 架構組成 CamelContext,Camel的工作環境,一個application通常會有一個CamelContext對象,像是有: 1. SpringCamelContext與Spring框架縫合,透過createRegistrt創建applicationContextRegistry instance,再從其中的applicationContext的getBean取得instance 2. DefaultCamelContext運行所需的基本資訊,Service啟動時作為參數傳入,實現共享上下文的效果
     Like  Bookmark