soa visão geral das funcionalidades de descoberta e roteamento de serviços em wcf 4

31
SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Upload: margaret-craig

Post on 11-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

SOA

Visão Geral das Funcionalidades de

Descoberta e Roteamento de Serviços em WCF 4

Page 2: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

www.rumos.pt

[email protected]

• (MCT) Microsoft

Certified Trainer

• (MCPD) ASP.NET

Developer 3.5

• (MCTS) Microsoft Office

SharePoint Server 2007

– Configuration

• Formador Rumos

• Sys Admin DGITA

• Consultor

• Analista Programador

• PG GSI

• PG Informática

• LIC Informática

Page 3: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

DEMOS

Demo : Creating a Calculator Service

Demo : Service Routing

Demo : Add-hoc Service Discovery Demo : Managed Service Discovery

Comunidade Rumos – Webcasts http://comunidade.rumos.pt/webcasts.rumos

Source Code: MSDN (WCF) Sampleshttp://msdn.microsoft.com/en-us/library/dd483346.aspx

Page 4: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Why SOA?

• Challenges in Building Business Applications

• Objectives of Service-Oriented Architecture

• What Is a Service?

• The Pillars of SOA

• Services Communicate Through Edges

Page 5: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Challenges in Building Business Applications

We are living in a distributed world

Business is agile

Efficient integration and interoperability are essential

Costs must be reduced

Systems have to be scalable, secure, and reliable

Page 6: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Objectives of Service-Oriented Architecture

SOA is an architectural style designed for building distributed systems

Agility

Reuse Reduce Cost

Productivity

Page 7: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

What Is a Service?

A service exposes functionality by accepting data (requests) and sometimes returning data (responses)

Page 8: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

The Pillars of SOA

Services handle data, not objects

Services are autonomous

Services have explicit boundaries

Services expose contract and policy

The following properties define a service-oriented architecture:

Page 9: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Services Communicate Through Edges

Services expose edges to the outside world—edges can be used for communication with the service

All interaction with a service is done through an edge

A service can expose multiple edges

The edge has an address

SOA edges are WCF endpoints

Page 10: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Demo Creating a Calculator Service

- The Service- ServiceHost Class- Endpoint ABC (address binding contract)- Metadata behaviour- Endpoint behaviour

- The Client- Proxy Pattern

Page 11: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Routing

• The Benefits of Routing• Introduction to the WCF Routing Service• Configuring Routing Using Message Filters• Configuring Routing Endpoints and Filters• Using Custom Filter Types and Content-Based

Routing• Using Routers for Protocol Bridging• Using Routers to Mask Service Unavailability• Using Routers for Multicast Messaging

Page 12: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

The Benefits of Routing

The broker design pattern provides agility and reliability to distributed systems, and enables:

Content-based load balancing

Automatically use of fallback services

Protocol bridging

Masking of versioning issues

Page 13: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Introduction to the WCF Routing Service

The Routing Service is part of WCF 4, and is implemented in the System.ServiceModel.Routing.RoutingService class

Hosted like any other service

Supports all messaging patterns

Determines the target service by evaluating each incoming message against a set of message filters

Implements the ISimplexDatagramRouter, ISimplexSessionRouter,  IRequestReplyRouter, and IDuplexSessionRouter contracts

Page 14: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Configuring Routing Using Message Filters

Message filters are specified in code or in the Routing configuration section

Message filters are grouped into filter tables

The routing configuration contains filter types and a collection of mappings between a message filter and a target endpoint

The RoutingBehavior defines the filter table to use

Page 15: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Configuring Routing Endpoints and Filters

<routing> <filters>  <filter name="MatchAllFilter" filterType="MatchAll"/> </filters> <filterTables>  <filterTable name="MyFilterTable">   <add filterName="MatchAllFilter" endpointName="Service"/>  </filterTable> </filterTables></routing><behaviors> <serviceBehaviors>  <behavior name="UseRouting">   <routing filterTableName="MyFilterTable" />  </behavior> </serviceBehaviors></behaviors><client> <endpoint name="Service“ address="..." binding="...“ contract="..."/>      </client>

Page 16: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Using Custom Filter Types and Content-Based Routing

WCF supports a wide range of filter types

You can use XPath filters to inspect the content of the incoming messages

You can define custom filters (rules) that target messages according to their content

You can create custom filter types for advanced routing scenarios

Page 17: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Using Routers for Protocol Bridging

The client-to-router and router-to-service bindings do not have to match

You can bridge incompatible protocols using a Routing Service as the middle-man

The client-to-router and router-to-service messaging patterns must match

Page 18: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Using Routers to Mask Service Unavailability

You can configure the router service to route a message to a backup service if the target service fails; this masks service unavailability and improves reliability

<routing><filters> <filter name="MatchAllFilter" filterType="MatchAll"/></filters><filterTables> <filterTable name="MyFilterTable">           <add filterName="MatchAllFilter" endpointName="CalcService"       backupList="AlternateCalc"/> </filterTable></filterTables><backupLists> <backupList>  <add endpointName="AlternateCalc"/> </backupList> </backupLists></routing>

Page 19: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Using Routers for Multicast Messaging

The Routing Service supports multicast, enabling publish/subscribe and distribution-style messaging

If the incoming message matches multiple filters, it will be delivered to each of the target endpoints

Multicast only works for one-way or duplex messaging; it does not work for request-response messaging

Page 20: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

WCF Discovery

• Introduction to WCF Discovery• Ad-Hoc Discovery Architecture• The Process of Ad-Hoc Discovery• Configuring Ad-Hoc Discovery• Issuing Probe and Resolve Messages

• Discovery Proxy Architecture• The Process of the Discovery Proxy• Discovering Services Using a Discovery Proxy

Page 21: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Discovery addresses the question: Where is the service?

The service’s location is dynamic

Discovery and Service Repository using WS-Discovery

Discovery enables agility – choose the service to consume at runtime

Introduction to WCF Discovery

Page 22: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Ad-Hoc Discovery Architecture

WCF 4 introduces WS-Discovery support that consists of two message categories:

Announcements (Hello/Bye messages)

Discovery (Probe/Resolve messages)

Page 23: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

The Process of Ad-Hoc Discovery

Hello

Bye

Probe

Resolve

Service is up

Service is up

Service is downService is down

Where is the

service?

Where is the

service?

Discovery

Announcement

CLI

EN

T

Page 24: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Configuring Ad-Hoc Discovery

<behavior name="SendAnnouncements">  <serviceDiscovery>     <!--specify that announcement messages will be sent and where.-->       <announcementEndpoints>         <endpoint kind="udpAnnouncementEndpoint"/>       </announcementEndpoints>  </serviceDiscovery>          </behavior>

 <standardEndpoints>    <udpDiscoveryEndpoint>    <!--Specify the discovery protocol version and maxResponseDelay-->     <standardEndpoint name="adhocDiscoveryEndpointConfiguration“

discoveryVersion="WSDiscovery11" maxResponseDelay="00:00:00.600" /> 

  </udpDiscoveryEndpoint> </standardEndpoints>

<service name=“...” behaviorConfiguration="SendAnnouncements">   . . . <!-- listen for discovery request messages. -->    <endpoint name="udpDiscovery" kind="udpDiscoveryEndpoint“ endpointConfiguration="adhocDiscoveryEndpointConfiguration"/> </service>

Page 25: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Issuing Probe and Resolve Messages

The DynamicEndpoint class is used by the client to issue probe messages

Dynamic endpoints can be defined in code and in the XML configuration file

The FindCriteria class enables granular discovery

// Discover endpoints when the client is opened. // The contract is used as the FindCriteria.// UdpDiscoveryEndpoint is used to send Probe message.DynamicEndpoint dynamicEndpoint = new DynamicEndpoint(        ContractDescription.GetContract(

typeof(ICalculatorService)),        new WSHttpBinding());

Page 26: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

DemoAdd-hoc Service Discovery

- The Service- behaviourConfiguration for serviceDiscovery

- announcementEndpoints for announcements

- Enpoint with kind=“udpDiscoveryEndpoint” for discovery- Calc endpointBehaviorConfiguration behaviour for scope criteria

- The Client- Endpoint with kind=“dynamicEndpoint” and

dynamicEndpointConfiguration for find scope criteria

Page 27: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Discovery Proxy Architecture

The discovery proxy enables discovery support outside the enterprise:

Listens for announcements and caches endpoint information internally

Forwards “Probe” and “Resolve” messages

Can function as a router

Page 28: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

The Process of the Discovery Proxy

Hello

Bye

Probe

Resolve

Service is up

Service is up

Service is downService is down

Where is the

service?

Where is the

service?

Discovery

Announcement

PR

OX

Y

Subnet

CLI

EN

T

Page 29: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Discovering Services Using a Discovery Proxy

The DiscoveryClient class calls the discovery proxy; it can also be used to issue “Probe” messages inside the subnet

// The discovery endpoint points to the discovery proxyUri probeEndpointAddress = new Uri("net.tcp://localhost:8001/Probe");DiscoveryEndpoint discoveryEP = new DiscoveryEndpoint( new NetTcpBinding(), new EndpointAddress(probeEndpointAddress));// Call the discovery proxyDiscoveryClient discoveryClient = new DiscoveryClient(discoveryEP);FindResponse findResponse = discoveryClient.Find( new FindCriteria(typeof(ICalculatorService)));if (findResponse.Endpoints.Count > 0)  InvokeCalculatorService(findResponse.Endpoints[0].Address);

Page 30: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Using Routers for Multicast Messaging

The Routing Service supports multicast, enabling publish/subscribe and distribution-style messaging

If the incoming message matches multiple filters, it will be delivered to each of the target endpoints

Multicast only works for one-way or duplex messaging; it does not work for request-response messaging

Page 31: SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4

Demo 2.2Managed Service Discovery

- The Discovery Proxy Abstract Class

- The Service- Announces it’s presence in the proxy’s anouncement endpoint

- The Client- Endpoint with kind=“dynamicEndpoint”

- And dynamicEndpointConfiguration for - find scope criteria - set it’s discovery address endpoint to the proxy’s probe address