Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

GGX 2014 - Grails and the real time world

1.470 visualizaciones

Publicado el

Slides for my GGX 2014 talk "Grails and the real time world". The code is available here: https://github.com/lmivan/ggx2014

-----------------

In a hyper-connected world the concept ""Real Time"" is used more and more every day. With the traditional Grails architecture it's difficult to achieve this, so we need to use a different approach. The answer is to use message driven architectures that will allow us to achieve the goal and also build fast, decoupled and easy to test applications.

In this talk you'll see a different type of architecture that will help you to serve content in real-time to a lot of clients in a fast and easy to scale way. You'll see some examples of how to achieve this using Spring Integration and integrate with external systems like websockets and XMPP in an easy and decoupled way.

Publicado en: Tecnología
  • Sé el primero en comentar

GGX 2014 - Grails and the real time world

  1. 1. Iván López @ilopmar GRAILS AND THE REAL-TIME WORLD
  2. 2. Hello! I am Iván López @ilopmar @madridgug http://greachconf.com
  3. 3. Traditional architectures Request-response POST /register-user POST /register-user POST /register-user
  4. 4. Traditional architectures
  5. 5. Traditional architectures
  6. 6. “ A problem postponed is a problem solved. Really?
  7. 7. 1. Event Driven Architectures
  8. 8. Event Driven Architecture ▷ Fire & Forget ▷ Decouple producer and consumer ▷ Immediate action in the consumer ▷ Real-time
  9. 9. Traditional architecture POST /purchase POST /purchase - Receive request 5 ms - Data validation 20 ms - Save 40 ms - PDF generation 200 ms - Send email 80 ms - Render response 50 ms Total: 395 ms
  10. 10. “ Can we do it better?
  11. 11. Event driven architecture POST /purchase POST /purchase - Receive request 5 ms No - Data validation 20 ms No - Save 40 ms No - PDF generation 200 ms Yes - Send email 80 ms Yes - Render response 50 ms No Total: 115 ms ~ 70% better Can anyone else do it?
  12. 12. Event driven architecture POST /purchase PDF Generation POST /purchase - Receive request 5 ms - Data validation 20 ms - Save 40 ms - Render response 50 ms Total: 115 ms Send email
  13. 13. “ Don't keep your clients waiting unnecessarily! Can I defer it?
  14. 14. Goals ▷ Loosely coupled architecture, easy to extend and evolve ▷ Build high performance and scalable systems ▷ Keep the business logic where “it belongs”
  15. 15. What about Grails? ▷ Platform core ▷ Events plugin ▷ Executor plugin ▷ Grails 2.3 async
  16. 16. Synchronous example // Send confirmation email def user = new User(params).save() emailService.sendRegistationMail(user) render view:'registerOk' class EmailService { public void sendRegistrationMail(User user) { sendMail { to user.email subject "Confirm your account" html g.render(template: "userEmailConfirmation") } } }
  17. 17. Asynchronous example // Platform core def user = new User(params).save() event('sendRegistrationMail', user) render view:'registerOk' class EmailService { @grails.events.Listener public void sendRegistrationMail(User user) { sendMail { to user.email subject "Confirm your account" html g.render(template: "userEmailConfirmation") } } }
  18. 18. Asynchronous example // Executor def user = new User(params).save() runAsync { emailService.sendRegistationMail(user) } render view:'registerOk' class EmailService { public void sendRegistrationMail(User user) { sendMail { to user.email subject "Confirm your account" html g.render(template: "userEmailConfirmation") } } }
  19. 19. “ I love the smell of code in the morning
  20. 20. What if we don't want this? ▷ Extract “dependencies” to configuration ▷ Change the application behaviour modifying the configuration
  21. 21. Spring Integration Use inside Spring the well-known Enterprise Integration Patterns http://www.enterpriseintegrationpatterns.com/
  22. 22. Spring Integration ▷ Lightweight messaging mechanism for Spring applications ▷ High level abstraction for messaging ▷ Application code is not aware of the messaging API ▷ External systems integration declaring adapters
  23. 23. Message ▷ Payload ▷ Header ▷ Immutable
  24. 24. Channel ▷ Point-to-point ▷ Publish-Subscribe
  25. 25. Endpoints ▷ Transformer ▷ Filter ▷ Router ▷ Splitter ▷ Aggregator ▷ Service activator ▷ Channel-adapter ▷ Enricher ▷ Bridge ▷ ...
  26. 26. Adapters ▷ JMS ▷ AMQP ▷ TCP ▷ UDP ▷ File ▷ FTP ▷ RMI ▷ HTTP (Rest) ▷ WS ▷ Mail ▷ JDBC ▷ XMPP ▷ Twitter ▷ RSS ▷ MongoDB ▷ Redis ▷ Gemfire ▷ Stream
  27. 27. “ Talk is cheap. Show me the code.
  28. 28. 2. Demo
  29. 29. 3. Summary
  30. 30. Summary ▷ Grails standard architecture fits in most of the cases ▷ It doesn't scale to infinite (and beyond!) ▷ Think about the application you're building ▷ Think about information flow
  31. 31. Thanks! Any questions? Iván López @ilopmar lopez.ivan@gmail.com https://github.com/lmivan http://kcy.me/1dwf7

×