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

Service Bus

  • Upload
    amity

  • View
    54

  • Download
    0

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Service Bus

Service Bus

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

Page 2: Service Bus

Построение гибридных решений

Datacenter

LOB web service

LOB app

Partner

Mobile Device

Page 3: Service Bus

Построение гибридных решений

Datacenter

LOB web service

LOB app

Partner

Mobile Device

SB

ACS

Page 4: Service Bus

Построение гибридных решений

Datacenter

LOB web service

LOB app

Partner

Mobile Device

SB

ACS

Page 5: Service Bus

Datacenter

Построение гибридных решений

Partner

Mobile Device

LOB web service

LOB app

SB

ACS

Page 6: Service Bus

Построение гибридных решений

Partner

Mobile Device

Datacenter

LOB web service

LOB app

SB

ACS

Page 7: Service Bus

Relays в облаке

Service Bus

Sender Receiver

sb://stringreversalinc.servicebus.windows.net/processtringBackendNamingRoutingFabric

Frontend

Nodes

Ctrl

1

2

3

4

Socket-SocketForwarder

outb

oun

d

sock

et

connec

t

outbound

socket

rendezvous

Ctrl

TCP/SSL 818

OnewayRendezvous

Ctrl Msg

NLB

Page 8: Service Bus

Delivering push notifications to millions of mobile devicesSergey [email protected]

Page 9: Service Bus

Notification Hubs makes it easy

to push multi-platform, personalized notifications both to single users and very large groups.

Page 10: Service Bus

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.

Page 11: Service Bus

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

Page 12: Service Bus

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.

Page 13: Service Bus

Push notification lifecycle

Registration at app launch.1. Client app contacts Platform Notification Service,

to retrieve current channel (e.g., ChannelURIs, device tokens, registrationIds).

2. App updates handle in back-end.

Sending Notification.3. App back-end send notification to PNS.4. PNS pushes the notification to the app

on the device.

Maintenance.5. Delete expired handles when PNS rejects them.

PlatformNotification

Service

App back-end

Client app

Page 14: Service Bus

Challenges of push notifications

Platform dependencyDifferent communication protocols to PNS’ (e.g., HTTP vs. TCP, xml payload vs. JSON payload).Different presentation formats and capabilities (tiles vs. toasts vs. badges).

RoutingPNS’ 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.

ScaleApp 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).

Page 15: Service Bus

Using Notification Hubs

One-time set upCreate a Notification Hub in Service Bus.

RegisterThe 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 NotificationThe app back-end sends a message to the Notification Hub.Notification Hub pushes it to the PNS’.

APNs WNS

Notification Hub

App back-end

iOS app Windows Storeapp

Page 16: Service Bus

Advantages of using Notification HubsNo 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.

BroadcastPush notifications to millions of devices (across platforms) with a single call.

Page 17: Service Bus

Demo

Getting started with Notification Hubs

Page 18: Service Bus

Register a Windows Store app

var hub = new NotificationHub(“<hub name>", "<connection string>");

var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

await hub.RegisterNativeAsync(channel.Uri);

Page 19: Service Bus

Broadcast a Windows notification

var hubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", “<hub name>");

var toast = @“<notification payload>";

hubClient.SendWindowsNativeNotificationAsync(toast);

Page 20: Service Bus

Register an iOS app

(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken {

SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:

@"<connection string>" notificationHubPath:@"mynh"];

[hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) {

if (error != nil) {

NSLog(@"Error registering for notifications: %@", error);

}

}];

}

Page 21: Service Bus

In your main activity:

Notification Hub hub = new NotificationHub("<hub name>", "<connection string>", context);

GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);

String regid = gcm.register(SENDER_ID);

NativeRegistration r = hub.register(regid);

Register an Android app

Page 22: Service Bus

Broadcast iOS and Android notificationsvar hubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", “<hub name>");

var toastForIos = @“<notification payload>";

hubClient.SendAppleNativeNotificationAsync(toastForIos);

var toastForAndroid = @“<notification payload>";

hubClient.SendGcmNativeNotificationAsync(toastForAndroid);

Page 23: Service Bus

var azure = require('azure');

var notificationHubService = azure.createNotificationHubService('hubname', 'connectionString');

notificationHubService.wns.sendToastText01(null, { text1: 'Hello from Node and Mobile Services!' }, function (error) { if (!error) { // message sent successfully } });

From node/mobile services

Page 24: Service Bus

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.

Page 25: Service Bus

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.

Page 26: Service Bus

Sending notifications to specific devicesTags as interest groups.1. Client app can register with a set of tags.2. Tags are simple strings (no pre-provisioning is required).3. 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.

Notification Hub

App back-end

Tag:”Beatles”Tag:”Wailers”

Tag:”Beatles”

Page 27: Service Bus

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.”

Page 28: Service Bus

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.

Page 29: Service Bus

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.1. Device does *not* contain the notification hub credentials.2. Devices authenticate with the app back-end to register.3. 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 HubApp back-

end

Page 30: Service Bus

Register from the back-end (.NET)// POST api/registerpublic async void Post(bool instId, bool channelUri, bool userId) { // We assume a windows store app (if coding a multiplatform app, a ‘platform‘ parameter should be passed) … if (!authorizedToRegisterTag(userId)) { throw new Exception("User not authorized to register"); } var regsForInstId = await hubClient.GetRegistrationsByTag(instId, 100); bool updated = false; bool firstRegistration = true; foreach (var registrationDescription in regsForInstId) { if (firstRegistration) { var winReg = registrationDescription as WindowsRegistrationDescription; winReg.ChannelUri = new Uri(channelUri); winReg.Tags.Clear(); winReg.Tags.UnionWith(new string[] {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, new string[] {instId, userId}); }}

Page 31: Service Bus

Take-aways

When security is needed register from the back-endNo Notification Hub SDK required on the devices

Page 32: Service Bus

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.

Page 33: Service Bus

Using templates for multi-platform pushRegistration.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.

Service Bus Notification HubApp back-

end

<toast><visual><binding

template=\"ToastText01\"><text

id=\"1\">$(message)</text></binding>

</visual></toast>

{aps: {

alert: “$(message)”

}}

{ message: “Hello!” }

Hello!

Hello

!

Page 34: Service Bus

Using templates for personalization

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’}.

Service Bus Notification HubApp back-

end

<toast><visual><binding

template=\"ToastText01\"><text id=\"1\">$(tempF)</text>

</binding></visual>

</toast>

{aps: {

alert: “$(tempC)”

}}

{tempC: “23”, tempF: “73”}

73

23

Page 35: Service Bus

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.

Page 36: Service Bus

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.

Page 37: Service Bus

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.

Page 38: Service Bus

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.

Page 39: Service Bus

Platform support, pricing & launch datePlatform 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!

Page 41: Service Bus

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.