Messaging patterns in the cloud

389 views
305 views

Published on

Presentation for ITCamp 2013. www.itcamp.ro
Talking about different patterns that can be used when we need to deal with messages. Sample code is based on Windows Azure Service Bus

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
389
On SlideShare
0
From Embeds
0
Number of Embeds
166
Actions
Shares
0
Downloads
5
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Messaging patterns in the cloud

  1. 1. itcampro@ itcamp13# Premium conference on Microsoft technologiesMessaging Patterns in theCloudRadu VunvuleaiQuest Group@RaduVunvuleahttp://vunvulearadu.blogspot.com
  2. 2. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudHuge thanks to our sponsors!
  3. 3. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• World of Messages• On-Premise and Cloud solutions• Messaging Patterns• Costs, Benefits and LimitationsAgenda
  4. 4. itcampro@ itcamp13# Premium conference on Microsoft technologiesWORLD OF MESSAGES
  5. 5. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudWorld of Messages
  6. 6. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudWorld of Messages
  7. 7. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudWorld of Messages
  8. 8. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudWorld of Messages
  9. 9. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudWorld of MessagesMessageMessageMessage
  10. 10. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudEnterprise Service Bus
  11. 11. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudEnterprise Service BusInteraction and communication betweensoftware applications
  12. 12. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudEnterprise Service BusTopicSubscriptions
  13. 13. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudEnterprise Service BusTopicSubscriptions
  14. 14. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudEnterprise Service BusTopicSubscriptions
  15. 15. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudEnterprise Service Bus
  16. 16. itcampro@ itcamp13# Premium conference on Microsoft technologiesON-PREMISE AND CLOUDSOLUTIONS
  17. 17. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Pro– Open Source– Flexible– Good price– Transactional queue read/write– Flexible load distribution• Cons– No queue management– Document not up to date– Only one queue technology supported (MSMQ)NService Bus
  18. 18. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Pro– Free for commercial use– Supports MSMQ and RabittMQ– Open Source– Good administration console• Cons– No commercial support– Not as fast as NServiceBusMassTransit
  19. 19. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Pro– Scalable– Lots of features– Good administration console– Support– Cross platform and multiple environments• Cons– Is not free– LatencyAzure Service Bus
  20. 20. itcampro@ itcamp13# Premium conference on Microsoft technologiesMESSAGING PATTERNS
  21. 21. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage Filter
  22. 22. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage FilterTopicSubscriptions
  23. 23. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Custom rules based on message attributes• Add attributes to messageMessage FilterBrokeredMessage msg = new BrokeredMessage(messageContent);msg.Properties["colorCode"] = 1;• Create subscription with custom ruleRuleDescription rule = new RuleDescription(){// 1 - green, 2 - orangeFilter = new SqlFilter("colorCode = 1");}namespaceManager.CreateSubscription("itcamp", "greensubscription", rule);
  24. 24. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage Splitter
  25. 25. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage SplitterTopicSubscriptions
  26. 26. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Group messages based on sessionMessage SplitterMessageSession msgSession =msgReceiver.AcceptMessageSession();BrokeredMessage message;while ((message = msgSession.Receive()) != null){// Process message}msgSession.Complete()BrokeredMessage message = new BrokereMessage(content);message.SessionId = "sessionId";• Consume messages based on session id
  27. 27. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Group messages based on sessionMessage SplitterMessageSession msgSession =msgReceiver.AcceptMessageSession();BrokeredMessage message;while ((message = msgSession.Receive()) != null){// Process message}msgSession.Complete()BrokeredMessage message = new BrokereMessage(content);message.SessionId = "sessionId";• Consume messages based on session id
  28. 28. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage Aggregator
  29. 29. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage AggregatorTopicSubscriptions
  30. 30. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Group messages based on sessionMessage AggregatorBrokeredMessage message = new BrokereMessage(content);message.SessionId = "sessionId";• Use correlation id and filtersBrokereMessage message = new BrokereMessage(content);message.CorrelationId = “CJ"topic.Send(message);namespaceManager.CreateSubscription(“itcamp”,“iquestsubscriptioncar”,new CorrelationFilterExpression(“CJ"));
  31. 31. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage Resequencer
  32. 32. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage Resequencer
  33. 33. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage ResequencerTopicSubscriptions123412341234
  34. 34. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage ResequencerTopicSubscriptions123412343412
  35. 35. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Session, message index and message countMessage Resequencer• Mark message as dead letter when inincorrect order• Iterate dead letter queue to access amessage with a lower indexBrokeredMessage message = new BrokereMessage(content);message.Properties["index"] = 2;message.Properties["count"] = 10message.SessionId = “CJ-15-IQU";
  36. 36. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage ResequencerMessageSession messageSession =queueClient.AcceptMessageSession();int currentIndex = 1;while(true){BrokeredMessage message = messageSession.Receive();if(int.Parse(message.Properties[“index”]) != currentIndex){message.DeadLetter();continue;}…message.Complete();if(int.Parse(messsage[“count”]) == currentIndex){break;}currentIndex++;}
  37. 37. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudMessage RecipientTopicSubscriptions
  38. 38. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Use a property to specific the list of groupsMessage Recipient• Define custom filters using LIKE operatorBrokeredMessage message = new BrokeredMessage(content);message.Properties[“groups”] = “orange magenta”;SqlFilter filter = new SqlFilter(“groups LIKE „%orange%‟”);topic.AddSubscription(“subscription3”, filter);• OR different properties for each group typeSqlFilter filter = new SqlFilter(“EXISTS orange”);topic.AddSubscription(“subscription3”, filter);
  39. 39. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Use a property to specific the list of groupsMessage Recipient• Define custom filters using LIKE operatorBrokeredMessage message = new BrokeredMessage(content);message.Properties[“groups”] = “orange magenta”;SqlFilter filter = new SqlFilter(“groups LIKE „%orange%‟”);topic.AddSubscription(“subscription3”, filter);• OR different properties for each group type• Use only one property and a prime numberfor each group
  40. 40. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudContent-Based RouterTopicSubscriptions
  41. 41. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudContent-Based RouterTopicSubscriptions
  42. 42. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudScatter-GatherTopicSubscriptionsQueue
  43. 43. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudScatter-GatherTopicSubscriptionsQueue
  44. 44. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudDynamic RouterTopicSubscriptions
  45. 45. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudDynamic RouterTopicSubscriptions
  46. 46. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public CloudDynamic RouterTopicSubscriptions
  47. 47. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• [key, values] properties• Store properties• Decorate propertiesDynamic Router
  48. 48. itcampro@ itcamp13# Premium conference on Microsoft technologiesCOSTS, BENEFITS ANDLIMITATIONS
  49. 49. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• What are the costs of processing:– 24kB message size– 10M messages– 1 Topic- 8 hoursCosts
  50. 50. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• 10$ Sending• 27.46$ Bandwidth (sending)Costs
  51. 51. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• 10$ Sending• 27.46$ Bandwidth (sending)• 10 $ Receiving• 0 $ Bandwidth (receiving)Costs
  52. 52. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• 10$ Sending• 27.46$ Bandwidth (sending)• 10 $ Receiving• 0 $ Bandwidth (receiving)• 47.46$ Costs related to Service BusCosts
  53. 53. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• 10$ Sending• 27.46$ Bandwidth (sending)• 10 $ Receiving• 0 $ Bandwidth (receiving)• 47.46$ Costs related to Service Bus• 8.64$ 4 Medium Worker Roles used toconsume messages• 56.1$ Total costCosts
  54. 54. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Cheap• 99.9% Uptime• Extremely scalable and flexible• No message is lost• Filters and actions support• REST API• Death-letter and transaction support• Same API for on-premise and cloudBenefits
  55. 55. itcampro@ itcamp13# Premium conference on Microsoft technologiesPrivate &Public Cloud• Not for real-time application• When processing more than 1M messageson the same topic in a 30 minutes timeinterval latency increases• You need to pay for each send/receivecommand• Batch maximum size – 100 messagesLimitations
  56. 56. itcampro@ itcamp13# Premium conference on Microsoft technologiesQ & A
  57. 57. itcampro@ itcamp13# Premium conference on Microsoft technologiesTHANK YOU

×