Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event-Driven Architecture

Event-Driven Architecture

Event-Driven Architecture
JVM Meetup #13

Eko Kurniawan Khannedy

August 14, 2018
Tweet

More Decks by Eko Kurniawan Khannedy

Other Decks in Technology

Transcript

  1. EKO KURNIAWAN KHANNEDY ▸ Senior Principal R&D Engineer at Blibli.com

    ▸ Part of R&D Team ▸ [email protected] ▸ JVM User Group Indonesia Committee ▸ Spring Cloud Contributor EVENT-DRIVEN ARCHITECTURE
  2. MONOLITH MODULES ORDER SERVICE CUSTOMER 
 SERVICE MERCHANT
 SERVICE CART


    SERVICE CONTENT
 SERVICE ... EVENT-DRIVEN ARCHITECTURE
  3. MONOLITH PROBLEM ▸ The large monolithic code base intimidates developers.

    ▸ Overloaded IDE & web container. ▸ Scaling the application can be difficult. ▸ Requires a long-term commitment to a technology stack. EVENT-DRIVEN ARCHITECTURE
  4. STRANGLER APPLICATION LEGACY
 SYSTEM ... CUSTOMER 
 SERVICE EVENT-DRIVEN ARCHITECTURE

    https://www.martinfowler.com/bliki/StranglerApplication.html
  5. MICROSERVICES ERA ORDER MANAGEMENT CUSTOMER 
 MANAGEMENT MERCHANT
 MANAGEMENT CART


    MANAGEMENT CONTENT
 MANAGEMENT ... EVENT-DRIVEN ARCHITECTURE
  6. TYPE OF MICROSERVICES MESSAGE
 SERVICE RISK
 SERVICE ... PRODUCT
 SERVICE

    MEMBER
 SERVICE PAYMENT
 SERVICE INVENTORY
 SERVICE ORDER 
 SERVICE ... UTILITY MASTER DATA CART
 SERVICE FLASHSALE 
 SERVICE ... ORCHESTRATOR EVENT-DRIVEN ARCHITECTURE
  7. API DRIVEN / ORCHESTRATION PATTERN Checkout Cart Create Payment CART


    SERVICE ORDER 
 SERVICE PAYMENT
 SERVICE Create Order EVENT-DRIVEN ARCHITECTURE
  8. ORCHESTRATION PATTERN PROBLEM Checkout Cart Send Email Create Payment CART


    SERVICE ORDER 
 SERVICE MESSAGE
 SERVICE PAYMENT
 SERVICE Create Order EVENT-DRIVEN ARCHITECTURE
  9. EVENT DRIVEN / CHOREOGRAPHY PATTERN Checkout Cart Send Email Create

    Payment CART
 SERVICE ORDER 
 SERVICE MESSAGE
 SERVICE PAYMENT
 SERVICE Create Order CART EVENT EVENT-DRIVEN ARCHITECTURE
  10. EVENT DRIVEN / CHOREOGRAPHY PATTERN Checkout Cart Send Email Create

    Payment CART
 SERVICE ORDER 
 SERVICE MESSAGE
 SERVICE PAYMENT
 SERVICE Create Order CART EVENT RISK
 SERVICE Calculate Risk Score EVENT-DRIVEN ARCHITECTURE
  11. CHOREOGRAPHY PATTERN PROBLEM Checkout Cart Send Email Create Payment CART


    SERVICE ORDER 
 SERVICE MESSAGE
 SERVICE PAYMENT
 SERVICE Create Order CART EVENT RISK
 SERVICE Calculate Risk Score EVENT-DRIVEN ARCHITECTURE
  12. EVENT-CARRIED STATE TRANSFER Checkout Cart Send Email Create Payment CART


    SERVICE ORDER 
 SERVICE MESSAGE
 SERVICE PAYMENT
 SERVICE Create Order FULL CART EVENT RISK
 SERVICE Calculate Risk Score CART DATA CART DATA CART DATA CART DATA EVENT-DRIVEN ARCHITECTURE
  13. EVENT-DRIVEN ARHITECTURE EVENT-CARRIED STATE TRANSFER ▸ Good Part ▸ Decoupling

    ▸ Reduced load on producer ▸ Bad Part ▸ Replicated Data ▸ Eventual Consistency
  14. EVENT-DRIVEN MICROSERVICES CART
 SERVICE ORDER
 SERVICE MEMBER
 SERVICE MERCHANT
 SERVICE

    RISK
 SERVICE ... MESSAGE BROKER API GATEWAY EVENT-DRIVEN ARCHITECTURE
  15. SAME CALL REPEATEDLY WILL PRODUCE THE SAME RESULT. IN OTHER

    WORDS, MAKING MULTIPLE IDENTICAL REQUESTS HAS THE SAME EFFECT AS MAKING A SINGLE REQUEST What is idempotent mean? BLIBLI WALLET ARCHITECTURE https://www.restapitutorial.com/lessons/idempotency.html
  16. EVENT-DRIVEN IN CQRS API GATEWAY MONGODB PRODUCT SERVICE PRODUCT SEARCH

    SERVICE ELASTICSEARCH APACHE KAFKA Write Request EVENT-DRIVEN ARHITECTURE Read Request Produce Event Consume Event
  17. EVENT-DRIVEN ARHITECTURE EVENT AGGREGATION PROBLEM ▸ How to aggregate data

    from several services? https://www.enterpriseintegrationpatterns.com/patterns/messaging/Aggregator.html
  18. AGGREGATOR SERVICE API GATEWAY DATASTORE AGGREGATOR SERVICE MESSAGE BROKER Read

    Aggregate Data Aggregate and Save It Receive All Events EVENT-DRIVEN ARHITECTURE Get Aggregate Data
  19. EVENT-DRIVEN ARHITECTURE THE CHALLENGES OF EVENT-DRIVEN ARCHITECTURE ▸ Asynchronous ▸

    Message Schema ▸ Versioning ▸ Tracing ▸ Message Order ▸ Consumer Complexity ▸ Message Broker
  20. SAMPLE EVENT-DRIVEN IN BLIPAY ▸ Register new merchant ▸ Register

    new member ▸ Refund member cash ▸ Get member + balance ▸ Receive payment confirmation from Bank ▸ … EVENT-DRIVEN ARHITECTURE
  21. REGISTER NEW MERCHANT BLIPAY-API BLIPAY-MEMBER BLIPAY- MERCHANT BLIPAY-CORE BLIPAY-PAYMENT BLIPAY-

    NOTIFICATION BLIPAY- PROMOTION APACHE KAFKA 1. HTTP Request 2. HTTP Request 3. SaveMerchantEvent 4. SaveMerchantEvent EVENT-DRIVEN ARHITECTURE
  22. REGISTER NEW MEMBER BLIPAY-API BLIPAY-MEMBER BLIPAY- MERCHANT BLIPAY-CORE BLIPAY-PAYMENT BLIPAY-

    NOTIFICATION BLIPAY- PROMOTION APACHE KAFKA 1. HTTP Request 2. HTTP Request 3. SaveMemberEvent 4. SaveMemberEvent 4. SaveMemberEvent EVENT-DRIVEN ARHITECTURE
  23. REFUND MEMBER CASH BLIPAY-API BLIPAY-MEMBER BLIPAY- MERCHANT BLIPAY-CORE BLIPAY-PAYMENT BLIPAY-

    NOTIFICATION BLIPAY- PROMOTION APACHE KAFKA 1. HTTP Request 2. HTTP Request 4. SaveBalanceEvent 3. Some Events 4. SaveTransactionEvent EVENT-DRIVEN ARHITECTURE
  24. GET MEMBER + BALANCE BLIPAY-API BLIPAY-MEMBER BLIPAY- MERCHANT BLIPAY-CORE BLIPAY-PAYMENT

    BLIPAY- NOTIFICATION BLIPAY- PROMOTION APACHE KAFKA 1. HTTP Request 2. HTTP Request EVENT-DRIVEN ARHITECTURE
  25. RECEIVE PAYMENT FROM BANK BLIPAY-API BLIPAY-MEMBER BLIPAY- MERCHANT BLIPAY-CORE BLIPAY-PAYMENT

    BLIPAY- NOTIFICATION BLIPAY- PROMOTION APACHE KAFKA 1. HTTP Request 2. HTTP Request 3. SavePaymentEvent 4. SavePaymentEvent 4. SavePaymentEvent 5. SaveBalanceEvent 6. SaveBalanceEvent EVENT-DRIVEN ARHITECTURE