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

Gr8Conf: Implementing loosely coupled microservices with Grails

Gr8Conf: Implementing loosely coupled microservices with Grails

Grails 3 is s a great starting point for creating microservices and many projects are following this path. However many microservice landscapes are still based on synchronous calls to REST Resources which obviously increases coupling between those applications. This talk focusses on building loosely coupled microservices that are based on Domain Events, which are becoming more and more popular in the Domain Driven Design community. We will take a look at how Grails 3 helps us in building such systems by introducing the Grails 3 event system and by taking a look how we can leverage Domain Events for a decoupled communication between Grails applications.

21a532a137b506128914478ac521fc8b?s=128

Michael Plöd

June 01, 2017
Tweet

More Decks by Michael Plöd

Other Decks in Programming

Transcript

  1. Loosely Coupled Microservices with Grails Michael Plöd @bitboss

  2. Interactions between Microserivces Grails App A Grails App B Typically

    RESTful HTTP
  3. Interactions between Microserivces Grails App A Grails App B Grails

    App C Grails Ap D Grails App E Grails App F
  4. Interactions between Microserivces Grails App A Grails App B Grails

    App C Grails Ap D Grails App E Grails App F ! " # $ %
  5. Welcome to the Dark Side

  6. Challenges ! " # $ % Service Discovery Timeouts Errors

    Latency Load Balancing &Stability
  7. Usual Architecture Patterns > Event-Driven Architecture > REST > SOA

    > Microservices / Self-Contained Systems > CQRS > Reactive / Actor Model
  8. Domain Events > Applications can issue Domain Events > Domain

    Events are important occurrences in an Domain > UserVerified > ShoppingCartCheckedOut > ShipmentDelivered > Domain Events are usually based on eventual consistency > Major driver for high degree of decoupling between Microservices
  9. Domain Events Customer
 Notification
 Application Shipping
 Application Shipment
 Delivered
 Event

    Messaging
 System Shipment
 Delivered
 Event
  10. An event is something 
 that happened in the past

    t now Event Event Event Event Event
  11. ShipmentDeliveredEvent
 CustomerVerifiedEvent CartCheckedOutEvent CreateCustomerEvent
 WillSaveItemEvent
 DoStuffEvent

  12. An Event is always immutable !

  13. Loan Details Entered Financial Situation Entered Personal Infromation Entered Application

    Submitted Credit
 Application Scoring … …
  14. Let’s reuse the ESB from the failed SOA project

  15. NO

  16. NO

  17. NO

  18. Talking about Grails

  19. Loan Details Entered Financial Situation Entered Personal Infromation Entered Application

    Submitted Use the 
 Grails 3 
 Event System for handling of internal Events Use 
 RabbitMQ 
 or 
 Kafka 
 for handling of external Events
  20. Options for Events Event with complete payload Event with a

    REST URL Empty Event as a Feed update notification > The Event contains all relevant data > Enables complete async processing > Payload is big and can fill up your message broker > The Event only contains a URL to a REST-Resource and some minimal data, that is usually always needed > Small payload that is fast to transport > Standard cases work completely asynchronous, more complex cases might require a synchronous roundtrip (without service lookup though) > The Event has no payload at all, it is just a notification > The payload, be it data or a REST URL, is usually contained in an Atom Feed > Event is a polling trigger for the feed
  21. https://github.com/mploed/event-driven-spring-boot Let’s replace the Scoring one with a Grails 3

    Microservice! https://github.com/mploed/event-driven-grails
  22. THANK YOU I’ll post links to slides and code on

    Twitter
 Michael Plöd - innoQ @bitboss