This document discusses using messaging to power front-end applications. It covers using messaging for broadcasting notifications to all clients, sending targeted responses to single clients, adding fault tolerance through message persistence, and scaling concerns. The document provides examples using SignalR and RabbitMQ to demonstrate broadcasting notifications, targeted responses, handling faults when a handler is offline, and addressing scaling issues.
2. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
• Channel to the User
• Broadcast Notifications
• Targeted Responses
• Fault Tolerance
• Scaling Concerns
Outline
3. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Any back-end communication
Client callback mechanism
Mobile push / WebSockets / polling
Channel to the User
Broadcast
All clients
Pub-sub style
Targeted
Single client
Req-resp style
4. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Two-way comms over TCP/IP
Persistent connection (SPA)
SignalR adds fault-tolerance
WebSockets & SignalR
Server
.NET Hub
Can invoke client calls
Client
Connects to Hub
Can invoke server calls
5. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Demo: Broadcast Notifications
Noticeboard Web App WebSockets & Messaging
6. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Client-server call with SignalR
Web Server publishes to Exchange
Broadcast Notifications
exchange: noticeboard
SendMailRequest
7. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Exchange bound to Queues
Web Server listens on Queue
Broadcast Notifications
exchange: noticeboard
SendMailRequest
queue: broadcast
queue: persist
8. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Web server broadcasts to clients
Client renders new message
Broadcast Notifications
9. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Multiple Servers
Additional Queues
Broadcast Notifications
10. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Demo: Response Messages
Noticeboard Web App WebSockets & Messaging
11. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Multiple message handlers
Targeted Responses
exchange: noticeboard
SendMailRequest
queue: broadcast
queue: persist
12. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Dedicated reply queue
Specified in outgoing messages
Web Server listens for replies
Targeted Responses
exchange: noticeboard
SendMailRequest
queue: reply-svr01
Sender: elton
Content: hi
ReplyTo: reply-svr01
13. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Handlers act on message
Send reply with result
Targeted Responses
SendMailRequest
queue: persist
queue: reply-svr01
MailSavedEvent
HandlerFailedEvent
14. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Handlers act on message
Send reply with result
Targeted Responses
queue: broadcast
queue: reply-svr01
MailBroadcastEvent
HandlerFailedEvent
SendMailRequest
15. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Web server receives reply
Looks up client & sends
Targeted Responses
17. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Persistence handler offline
Demo: Fault Tolerance
exchange: noticeboard
SendMailRequest
queue: broadcast
queue: persist X
18. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Durable queues
Messages wait for handler
Fault Tolerance
exchange: noticeboard
SendMailRequest
queue: persist
19. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Broadcast notification is easy
Targeted response – not so much...
Scaling Concerns
20. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
SignalR fault tolerance
Heartbeat checks connection
Scaling Concerns
21. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Connection re-established
Load-balanced Web servers
Scaling Concerns
22. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Messages to 'wrong' Reply Queue
Scaling Concerns
queue: reply-svr01 queue: reply-svr02
23. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
Instead of per-server Reply Queue
Common Reply Exchange
Scaling Concerns
24. Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends
• You need a channel to the client
• Messaging semantics: pub-sub & req-resp
• Maintain patterns with messaging
• Fault tolerance – persistent messages
• Scaling – broadcast and filter
Summary