Messaging Powered Front Ends

Post on 22-Jan-2017

356 views 2 download

Transcript of Messaging Powered Front Ends

Elton StonemanMicrosoft MVP & Pluralsight Author

http://particular.net

Messaging Powered Front Ends

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

•Channel to the User

•Broadcast Notifications

•Targeted Responses

•Fault Tolerance

•Scaling Concerns

Outline

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Any back-end communicationClient callback mechanism Mobile push / WebSockets / polling

Channel to the User

BroadcastAll clientsPub-sub style

TargetedSingle clientReq-resp style

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Two-way comms over TCP/IPPersistent connection (SPA)SignalR adds fault-tolerance

WebSockets & SignalR

Server.NET HubCan invoke client calls

ClientConnects to HubCan invoke server calls

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Demo: Broadcast Notifications

Noticeboard Web App WebSockets & Messaging

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Client-server call with SignalRWeb Server publishes to Exchange

Broadcast Notifications

exchange: noticeboard

SendMailRequest

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Exchange bound to QueuesWeb Server listens on Queue

Broadcast Notifications

exchange: noticeboard

SendMailRequestqueue: broadcast

queue: persist

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Web server broadcasts to clientsClient renders new message

Broadcast Notifications

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Multiple ServersAdditional Queues

Broadcast Notifications

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Demo: Response Messages

Noticeboard Web App WebSockets & Messaging

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Multiple message handlers

Targeted Responses

exchange: noticeboard

SendMailRequest

queue: broadcast

queue: persist

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Dedicated reply queueSpecified in outgoing messagesWeb Server listens for replies

Targeted Responses

exchange: noticeboard

SendMailRequest

queue: reply-svr01

Sender: eltonContent: hiReplyTo: reply-svr01

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Handlers act on messageSend reply with result

Targeted Responses

SendMailRequest

queue: persist

queue: reply-svr01

MailSavedEvent

HandlerFailedEvent

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Handlers act on messageSend reply with result

Targeted Responses

queue: broadcast

queue: reply-svr01

MailBroadcastEvent

HandlerFailedEvent

SendMailRequest

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Web server receives replyLooks up client & sends

Targeted Responses

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

But... you can do this just with SignalR

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Persistence handler offline

Demo: Fault Tolerance

exchange: noticeboard

SendMailRequest

queue: broadcast

queue: persist X

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Durable queuesMessages wait for handler

Fault Tolerance

exchange: noticeboard

SendMailRequest

queue: persist

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Broadcast notification is easyTargeted response – not so much...

Scaling Concerns

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

SignalR fault toleranceHeartbeat checks connection

Scaling Concerns

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Connection re-establishedLoad-balanced Web servers

Scaling Concerns

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Messages to 'wrong' Reply Queue

Scaling Concerns

queue: reply-svr01 queue: reply-svr02

Introduction to ServiceInsight for NServiceBusMessaging Powered Front Ends

Instead of per-server Reply QueueCommon Reply Exchange

Scaling Concerns

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

Thank you

blog.sixeyed.com

@EltonStoneman