Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Messaging in .NET via MassTransit by Arturs Karbone at .NET focused 73rd DevClub.lv

99 views

Published on

What is a distributed system and how to glue the applications in it? Messaging is one of the powerful ways to do that. Let’s go through the common messaging communication patterns together. Recall some theory, understand the difference between message brokers and message buses and see how the last ones help us focusing on writing business features and not concentrating on low-level communication details. The talk will be illustrated with a lot of real-life examples from the Insurance industry.
(Language – English)

Arturs is a seasoned, independent consultant, who went through enterprise applications of all kinds. He is enthusiastic about building and leading strong teams, revealing their potential and making smart people working with other smart people.Artur’s peers know how pragmatically he combines business-oriented thinking and fanatic passion for software development best practices like Domain-Driven Design, TDD, paired programming, writing clean code, etc. Before he went independent, he worked as an architect and a tech lead. In addition to that Artur is an active OSS contributor and blogs at Craftsman at Work.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Messaging in .NET via MassTransit by Arturs Karbone at .NET focused 73rd DevClub.lv

  1. 1. Arturs Karbone 14-March-2019 MESSAGING IN .NET VIA MASSTRANSIT https://www.linkedin.com/in/arturkarbone/ Blog http://craftsmanatwork.guru/ Training course http://devchampions.com/training/unit_and_integration_testing/
  2. 2. A DISTRIBUTED SYSTEM. AN INSURANCE COMPANY
  3. 3. INTEGRATION PATTERNS: RPC (SOAP/REST) • Tightly coupled • Complexity grows • Need to modify existing code, when a new system appears • What if system X is down for maintenance?
  4. 4. 1. Decoupled 2. Share only messaging contract 3. Truly async communication: the message will reach the destination INTEGRATION PATTERNS: MESSAGING
  5. 5. MESSAGE QUEUE (FIRST IN FIRST OUT)
  6. 6. • A Queue (Friend’s mailbox) • Know your friend’s exact address • Have a ride • Put the letter into his mailbox • An Exchange (a post office) • Know your friend’s exact address • Bring the letter to the post office • They will take care of the routing TRANSPORT THEORY
  7. 7. MESSAGING PATTERNS: BROADCAST/EVENT
  8. 8. Events should be expressed in a noun-verb (past tense) sequence: • PolicyIssued • ClientUpdated • OrderShipped • PhoneChanged MESSAGING PATTERNS: BROADCAST/EVENT
  9. 9. MESSAGING PATTERNS: A COMMAND
  10. 10. Commands should be expressed in a verb-noun sequence, following the tell style • RegisterClient • ChangeAddress • SubmitOrder MESSAGING PATTERNS: A COMMAND
  11. 11. MESSAGING PATTERNS: RPC REQUEST/RESPONSE
  12. 12. Another layer of abstraction can solve any problem in IT MESSAGE BROKER VS MESSAGE BUS • Message bus is broker agnostic (an abstraction above message brokers). Like ORM DB providers in .NET or Log4net, etc. • Message bus takes care of low-level details like • Queues/Exchanges/Bindings • Acknowledgements • Serialization/Deserialization • Error handling • Retries/Resilience • Auditing • Developers can concentrate on sending and receiving messages. • Message bus – usually is language specific
  13. 13. ANATOMY OF MESSAGING CONTRACT(JUST A NUGET PACKAGE)
  14. 14. A CONSUMER EXAMPLE: DEFINITION
  15. 15. A CONSUMER EXAMPLE: CONSUMPTION
  16. 16. FIRE UP RABBIT  docker run -d --name myrabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management  docker start myrabbit
  17. 17. DEMO: EXCHANGES
  18. 18. DEMO: EXCHANGE BINDINGS
  19. 19. DEMO: MESSAGE’S PAYLOAD
  20. 20. SERIALIZATION/DESERIALIZATION
  21. 21. ERROR HANDLING
  22. 22. Simple rule: Define policy & Define exceptions to handle Supported Retry Policies • None • Immediate • Intervals • Exponential • Incremental RESILIENCE
  23. 23. CONSUME ERRORS
  24. 24. SYMPTOMS WHEN TO USE MESSAGING • Integration with inner microservices • Integration with 3rd party (it is almost always a good idea) • Resilience • Truly async communication • Messaging in applications (menu notifies other components) • Domain events
  25. 25. SYMPTOMS WHEN TO MASSTRANSIT • A distributed system consists of .NET services/apps • Developers want to concentrate on sending and receiving messages. • You already have experience with RabbitMq
  26. 26. • https://stackoverflow.com/questions/tagged/masstransit • https://gitter.im/MassTransit/MassTransit • http://masstransit-project.com/MassTransit/learn/videos.html • https://www.pluralsight.com/courses/masstransit-rabbitmq-scaling-micr MASSTRANSIT LEARNING RESOURCES

×