1 / 41

Service Bus

Service Bus. Предоставляет защищенный механизм доставки сообщений и соединения между разными сетевыми топологиями Позволяет строить гибридные решения Предоставляет различные протоколы соединения. Построение гибридных решений. Datacenter. Partner. LOB app. Mobile Device. LOB web service.

amity
Download Presentation

Service Bus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Service Bus Предоставляет защищенный механизм доставки сообщений и соединения между разными сетевыми топологиями Позволяет строить гибридные решения Предоставляет различные протоколы соединения

  2. Построение гибридных решений Datacenter Partner LOB app Mobile Device LOB web service

  3. Построение гибридных решений Partner Datacenter ACS LOB app SB Mobile Device LOB web service

  4. Построение гибридных решений Datacenter Partner ACS LOB app SB Mobile Device LOB web service

  5. Построение гибридных решений Datacenter Partner ACS LOB app SB Mobile Device LOB web service

  6. Построение гибридных решений Partner Datacenter ACS LOB app SB Mobile Device LOB web service

  7. Relays в облаке Service Bus sb://stringreversalinc.servicebus.windows.net/processtring BackendNaming RoutingFabric Oneway RendezvousCtrl Msg Frontend Nodes Ctrl NLB 2 3 TCP/SSL 818 outbound socket connect outbound socket rendezvous Socket-SocketForwarder Ctrl 1 Sender Receiver 4

  8. Delivering push notifications to millions of mobile devices Sergey Poplavskiy v-spopla@Microsoft.com

  9. Notification Hubs makes it easy to push multi-platform, personalized notifications both to single users and very large groups.

  10. Outline • Push notifications 101. • Why Notification Hubs. • Getting started demo. • Using tags. • Mediaapp demo. • Securing tag registrations. • Notifyuser demo. • Using templates. • Personalized notifications demo. • Other information.

  11. Why Notification Hubs? Push is essential to the user experience of many apps. • Increase user engagement. • Update tiles/widgets with current financial/weather information. • Display badges with the number of current sales leads in a CRM app. Real world apps have complex needs. • Multi-platform push. • Localization. • User preferences. • Different client app versions. • Scale. Windows News app uses Notification Hubs

  12. Push notifications • Push notifications require a platform specific service. • Each platform (Windows Store, iOS, Android, …) has a different push notification service. • Different capabilities and protocols. • An e2e solution requires lots of back-end code. • Store and keep up to date the device information. • Implement platform-specific protocols.

  13. Push notification lifecycle • Registration at app launch. • Client app contacts Platform Notification Service, to retrieve current channel (e.g., ChannelURIs, device tokens, registrationIds). • App updates handle in back-end. • Sending Notification. • App back-end send notification to PNS. • PNS pushes the notification to the app on the device. • Maintenance. • Delete expired handles when PNS rejects them. Client app Platform Notification Service App back-end

  14. Challenges of push notifications • Platform dependency • Different communication protocols to PNS’ (e.g., HTTP vs. TCP, xml payload vs. JSON payload). • Different presentation formats and capabilities (tiles vs. toasts vs. badges). • Routing • PNS’ provide a way to send a message to a device/channel. • Usually notifications are targeted at users or interest groups(e.g., employees assigned to a customer account). • App back-end has to maintain a registry associating device handles to interest groups/users. • Scale • App back-end has to store current handles for each device  high storage and VM costs. • Broadcast to millions of devices with low latency requires parallelization (DB ad VM).

  15. Using Notification Hubs • One-time set up • Create a Notification Hub in Service Bus. • Register • The client app retrieves its current handle from the PNS. • Client app creates (or updates) a registration on the Notification Hub with the current handle. • Send Notification • The app back-end sends a message to the Notification Hub. • Notification Hub pushes it to the PNS’. iOS app Windows Store app Notification Hub App back-end WNS APNs

  16. Advantages of using Notification Hubs • No platform-specific protocols. • App back-end just communicates with the Notification Hub. • Avoid storing device information in the app back-end. • Notification Hub maintains the registry of devices and the associations to users/interest groups. • Broadcast • Push notifications to millions of devices (across platforms) with a single call.

  17. Getting started with Notification Hubs • Demo

  18. Register a Windows Store app • varhub = newNotificationHub(“<hub name>", "<connection string>"); • var channel = awaitPushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); • awaithub.RegisterNativeAsync(channel.Uri);

  19. Broadcast a Windows notification • varhubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", “<hub name>"); • vartoast = @“<notification payload>"; • hubClient.SendWindowsNativeNotificationAsync(toast);

  20. Register an iOS app • (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*) deviceToken { • … • SBNotificationHub* hub = [[SBNotificationHuballoc] initWithConnectionString: • @"<connection string>" notificationHubPath:@"mynh"]; • [hub registerNativeWithDeviceToken:deviceTokentags:nil completion:^(NSError* error) { • if (error != nil) { • NSLog(@"Error registering for notifications: %@", error); • } • }]; • }

  21. Register an Android app • In your main activity: • Notification Hub hub = newNotificationHub("<hub name>", "<connection string>", context); • GoogleCloudMessaginggcm = GoogleCloudMessaging.getInstance(context); • String regid = gcm.register(SENDER_ID); • NativeRegistrationr = hub.register(regid);

  22. Broadcast iOS and Android notifications • varhubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", “<hub name>"); • vartoastForIos= @“<notification payload>"; • hubClient.SendAppleNativeNotificationAsync(toastForIos); • vartoastForAndroid= @“<notification payload>"; • hubClient.SendGcmNativeNotificationAsync(toastForAndroid);

  23. From node/mobile services • var azure = require('azure'); • varnotificationHubService = azure.createNotificationHubService('hubname', 'connectionString'); • notificationHubService.wns.sendToastText01(null, { text1: 'Hello from Node and Mobile Services!' },function(error) { if (!error) { // message sent successfully} } • );

  24. Take-aways • No need to store and maintain ChannelURIs. • In your device local storage, in the cloud. • Device registrations expire. • No need to clean-up when app is uninstalled. • Call RegisterAsync regularly.

  25. Outline • Push notifications 101. • Why Notification Hubs. • Getting started demo. • Using tags. • Mediaapp demo. • Securing tag registrations. • Notifyuser demo. • Using templates. • Personalized notifications demo. • Other information.

  26. Sending notifications to specific devices • Tags as interest groups. • Client app can register with a set of tags. • Tags are simple strings (no pre-provisioning is required). • App back-end can target all clients with the same tag. • You can use tags also for: • Multiple type of interest groups, e.g.,: • Follow bands: tag “followband:Beatles”. • Follow users: tag “followuser:Alice”. • Tag devices with a user ID. Tag:”Beatles” Notification Hub App back-end Tag:”Wailers” Tag:”Beatles”

  27. Take-aways • Store the categories/tags. • In your device local storage, in the cloud. • Make sure to register regularly. • Rule of thumb: “every app start, up to once per day.”

  28. Outline • Push notifications 101. • Why Notification Hubs. • Getting started demo. • Using tags. • Mediaapp demo. • Securing tag registrations. • Notifyuser demo. • Using templates. • Personalized notifications demo. • Other information.

  29. Tags as user IDs • Registering from device is not secure. • Every device can register for any tag. • Embedding credentials in the device works for “public” notifications (e.g., News apps). • Register from back-end. • Device does *not* contain the notification hub credentials. • Devices authenticate with the app back-end to register. • App back-end registers the device for the correct tags. • Same registration patterns apply. • Devices have to register regularly (registrations still expire). • Store the required tags in your back-end. Notification Hub App back-end

  30. Register from the back-end (.NET) // POST api/register public asyncvoidPost(boolinstId, boolchannelUri, booluserId) { // We assume a windows store app (if coding a multiplatform app, a ‘platform‘ parameter should be passed) … if(!authorizedToRegisterTag(userId)) { thrownewException("User not authorized to register"); } varregsForInstId = await hubClient.GetRegistrationsByTag(instId, 100); boolupdated = false; boolfirstRegistration = true; foreach(varregistrationDescriptioninregsForInstId) { if(firstRegistration) { varwinReg = registrationDescriptionasWindowsRegistrationDescription; winReg.ChannelUri= newUri(channelUri); winReg.Tags.Clear(); winReg.Tags.UnionWith(newstring[] {instId, userId}); hubClient.UpdateRegistration(winReg); updated = true; firstRegistration= false; } else{ // if templates are not used, delete all extra registrations with this installation id. hubClient.DeleteRegistration(registrationDescription); } } // if not updated, a new registration has to be created for the device if(!updated) { hubClient.CreateWindowsNativeRegistration(channelUri, newstring[] {instId, userId}); } }

  31. Take-aways • When security is needed  register from the back-end • No Notification Hub SDK required on the devices

  32. Outline • Push notifications 101. • Why Notification Hubs. • Getting started demo. • Using tags. • Mediaapp demo. • Securing tag registrations. • Notifyuser demo. • Using templates. • Personalized notifications demo. • Other information.

  33. Using templates for multi-platform push <toast> <visual> <binding template=\"ToastText01\"> <text id=\"1\">$(message)</text> </binding> </visual> </toast> • Registration. • Client apps can register with a platform specific template, e.g., • Alice’s Surface registers with Windows Store ToastText01 template. • Bob’s iPhone with the Apple JSON template:{ aps: {alert: “$(message)”}}. • Send notification. • App back-end sends a platform independent message: {message: “Hello!”}. • Version independence. • Templates can be used to abstract different client app versions. Hello! Service Bus Notification Hub • { message: “Hello!” } App back-end Hello! • { • aps: { • alert: “$(message)” • } • }

  34. Using templates for personalization <toast> <visual> <binding template=\"ToastText01\"> <text id=\"1\">$(tempF)</text> </binding> </visual> </toast> • Registration. • Client apps can register with personalized templates, e.g., • Alice’s Surface wants to receive weather information in F degrees. • Bob’s iPhone wants weather information in C degrees. • Send notification. • App back-end sends a message including both temperatures: {tempC: “23”, tempF: “73”}. • Template Expressions. • Template support a simple expression language: • E.g., {‘Elio, ’+$(friend)+’ added you to ’+$(groupName)+‘ group’}. 73 Service Bus Notification Hub • {tempC: “23”, tempF: “73”} App back-end 23 • { • aps: { • alert: “$(tempC)” • } • }

  35. Templates take-aways • Platform agnostic code in the back-end. • Abstract client app version differences from the back-end. • Powerful personalization with no back-end complexity. • E.g., localized messages, C/F temperatures.

  36. Outline • Push notifications 101. • Why Notification Hubs. • Getting started demo. • Using tags. • Mediaapp demo. • Securing tag registrations. • Notifyuser demo. • Using templates. • Personalized notifications demo. • Other information.

  37. Delivery guarantee and telemetry • Notification Hubs do not provide delivery guarantee. • All platform notification systems are “best effort”, e.g., device could be disconnected, could never reconnect, etc. • Guideline: important communications have to be delivered in-app. • Telemetry. • Notification Hubs provide powerful telemetry to track each and every outcome of the notifications for each platform (e.g., successful notifications, throttled notifications, expired channels/tokens). • Accessible through Windows Azure portal and programmatically.

  38. Scale • Notification Hubs run on a fully parallelized architecture. • All our VMs are ready for your broadcast! • A single Notification Hub scales up to millions of devices, with no special coding required. • Number of devices and latency. • During preview Notification Hubs are limited to 10,000 active devices. • At launch, Notification Hubs will support millions of devices out of the box. • The expected latency of a broadcast to all registered devices is a couple of minutes, even for millions of devices.

  39. Platform support, pricing & launch date • Platform support. • At launch, we will support push notifications through WNS, APNs, GCM, and MPNS. • Device SDKs for Windows Store Apps, Windows Phone 8, iOS (Objective-C), Android. • Server SDKs for .NET, Node, Mobile Services. • All functions available from REST. • Launch date. • “Summer 2013” in all data centers, i.e., very soon!

  40. Resources • Documentation • Notification Hubs Guidance • Windows Store (tutorial, feature guide) • iOS (tutorial, feature guide) • Android (tutorial, feature guide) SDKs .NET Server SDK Node Server SDK Windows Store Device SDK iOS Device SDK Android Device SDK

More Related