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

Building Reactive Systems

Building Reactive Systems

This presentation was made in Brazil at DevFest XP By 99 '17 ( https://devfestxp.com/ )

Eduardo Costa

December 09, 2017
Tweet

More Decks by Eduardo Costa

Other Decks in Programming

Transcript

  1. About me - Eduardo Costa - From São Paulo /

    SP - 99ner - Backend developer - Scala enthusiastic - @jeduardocosta
  2. Agenda - Demystifying Reactive - Back-pressure - Circuit breaker -

    Event Sourcing and CQRS - How can we start?
  3. Back Pressure // Getting a stream of jobs from an

    imaginary external system as a Source val jobs: Source[Job, NotUsed] = inboundJobsConnector() jobs .buffer(1000, OverflowStrategy.backpressure) .map(url => pipeline(Get(url)).map((url, _))) .map(parseUrls) .runWith(Sink.foreach(println)) OverflowStrategy.dropBuffer | OverflowStrategy.dropHead OverflowStrategy.dropTail | OverflowStrategy.dropNew
  4. Circuit Breaker class DangerousActor extends Actor with ActorLogging { import

    context.dispatcher val breaker = new CircuitBreaker( context.system.scheduler, maxFailures = 5, callTimeout = 10.seconds, resetTimeout = 1.minute).onOpen(notifyMeOnOpen()) def notifyMeOnOpen() = log.warning("My CircuitBreaker is now open, and will not close for one minute")
  5. Steps - Embrace reactive principles - Asynchronous processing with back-pressuring

    - Start with reactive programming - Use circuit-breaker - Events over states (Event Sourcing and CQRS)
  6. References - CQRS Journey (https://msdn.microsoft.com/en-us/library/jj554200.aspx) - How Events Are Reshaping

    Modern Systems - Jonas Bonér (https://speakerdeck.com/jboner/how-events-are-reshaping-modern-systems) - Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And Kafka (https://www.lightbend.com/blog/lessons-learned-from-paypal-implementing-bac k-pressure-with-akka-streams-and-kafka)