SOA with NServiceBus 20130124

24
SOA With NServiceBus Sean Farmar

description

 

Transcript of SOA with NServiceBus 20130124

Page 1: SOA with NServiceBus 20130124

SOA With NServiceBus

Sean Farmar

Page 2: SOA with NServiceBus 20130124

What is the problem we are trying to

solve?

•Scale

•Growth

•Stability and Durability

Page 3: SOA with NServiceBus 20130124

Why SOA?

•SOA's tenets are about reducing coupling.

Page 4: SOA with NServiceBus 20130124

•Coupling:

•Afferent, efferent

•Temporal

•Spatial

•Platform

Why SOA? [cont.]

Page 5: SOA with NServiceBus 20130124

n-tier architecture

Page 6: SOA with NServiceBus 20130124

In practice

Page 7: SOA with NServiceBus 20130124

In practice

•Domain decomposition

•Definition of components boundaries

•Using messaging and pub/sub

Page 8: SOA with NServiceBus 20130124

Publish Subscribe [pub/sub]

Page 9: SOA with NServiceBus 20130124

Publish Subscribe [pub/sub]

Page 10: SOA with NServiceBus 20130124

In practice [cont.]

•Following principles (best thinking):

•Explicit intentions [naming, context]

•Single Responsibility

•Command Query Separation

•Drive your design and decision making to address all aspects of coupling

•Backwards compatibility

Page 11: SOA with NServiceBus 20130124

Why NServiceBus?

•.Net Solution

•Distributed bus (not a broker)

•Messaging pub/sub (asynchronous)

•Durable and Transactional (if you want)

•Sagas

Page 12: SOA with NServiceBus 20130124

Why NServiceBus? [cont.]

•A Message

[Serializable]public class EventMessage : IMyEvent{

public Guid EventId { get; set; }public DateTime? Time { get; set; }

}

public interface IMyEvent{

Guid EventId { get; set; }DateTime? Time { get; set; }TimeSpan Duration { get; set; }

}

var m = new EventMessage();// Or:var m = Bus.CreateInstance<IMyEvent>();

Page 13: SOA with NServiceBus 20130124

Why NServiceBus? [cont.]

•Handlerpublic IBus Bus { get; set; }

public class EventMessageHandler : IHandleMessages<EventMessage>{

public void Handle(EventMessage message){

// do stuff...IMyEvent anotherEventMessage;

anotherEventMessage = Bus.CreateInstance<IMyEvent>();

anotherEventMessage = Guid.NewGuid();

anotherEventMessage = DateTime.Now.Second;

anotherEventMessage = TimeSpan.FromSeconds(99999D);

Bus.Publish(anotherEventMessage);}

}

Page 14: SOA with NServiceBus 20130124

Service Examples

Subscribe to Customer Status Updated

Publish

Customer Status Updated

Save status locally

Subscribe to Product Product Pricing UpdatedPricing Updated

Publish

Product Pricing Updated

Save pricing locally

Place Order

Publish Order Accepted

Sales

Marketing

Customer Care

Page 15: SOA with NServiceBus 20130124

Why NServiceBus? [cont.]

•Config

<?xml version="1.0"?><configuration>  <configSections>    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>    <section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />  </configSections>

  <MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/>

  <UnicastBusConfig ForwardReceivedMessagesTo="audit">    <MessageEndpointMappings>      <add Messages="MyMessages" Endpoint="MyServer"/>    </MessageEndpointMappings>  </UnicastBusConfig>  </configuration>

Page 16: SOA with NServiceBus 20130124

Why NServiceBus? [cont.]

•Integration

•Scalable

•Elegant programming model

•Developer productivity

•Used in the industry

Page 17: SOA with NServiceBus 20130124
Page 18: SOA with NServiceBus 20130124

A story about performance

Page 19: SOA with NServiceBus 20130124

A story about performance

•The evolution

Page 20: SOA with NServiceBus 20130124

A story about performance

•Turning the lights on

Page 21: SOA with NServiceBus 20130124

A story about performance

•Performance and Load testing

•Fixing it

•How did NServiceBus make it better?

Page 22: SOA with NServiceBus 20130124

Summary

•SOA

•NServiceBus

•You can do it

Page 23: SOA with NServiceBus 20130124

Q&A

Page 24: SOA with NServiceBus 20130124

Thank You!

nservicebus.comudidahan.com/blogSean Farmartwitter: @farmar