advanced n service bus deployment - nsbconnyc 2014 by kijana woodard

Post on 06-Jun-2015

217 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Mitigation all the way down

TRANSCRIPT

AdvancedNServiceBusDeployment

NSBCon NYC 2014 / Kijana Woodard @kijanawoodard

BackgroundFrom Dallas, TXProfessional develop since 1996.net since 1.0Independent contractor since 2010

Slides are on GitHubgithub.com/kijanawoodard/NSBCon-NYC-2014/

Mitigationallthewaydown

An application which defies modificationBig Ball of Mud

BBOM Formal DefinitionSELECT currentAssignmentFROM workHistoryWHERE originalDeveloper != me

Defense MechanismsChange control committeeSource control committee

BBOM Architecure

- thedailywtf.com Comment On The Enterprise Dependency

BBOM Implementationpublic class OrderController{ ...

public OrderController( IOrderRepository orders, IBillingService billing, IShippingService shipping) { _orders = orders; _billing = billing; _shipping = shipping; }

public HttpStatusCode Post(Order order) { _orders.Save(order.OrderDetails); _billing.Charge(order.BillingDetails); _shipping.Ship(order.ShippingDetails);

return HttpStatusCode.OK; }}

Mediatorkijanawoodard.com/introducing-nimbuslostechies.com/jimmybogard/2014/09/09/tackling-cross-cutting-concerns-with-a-mediator-pipeline/

Decouple through Events

Events Implementationpublic class OrderController{ public IBus Bus { get; set; }

public HttpStatusCode Post(ProcessOrder order) { Bus.Send(order); return HttpStatusCode.OK; }}

...

public class OrderHandler : IHandleMessages<ProcessOrder>{ public IBus Bus { get; set; }

public void Handle(ProcessOrder message) { //save order... Bus.Publish<IOrderAccepted>(x => x.Id = message.Id); }}

BlissEncapsulationSingle ResponsibilityOpen Closed PrincipleInterface Segregation PrincipleDependency Inversion Principle

It's almost as if...

Alan Kay - 2003

OOP to me means only messaging, localretention and protection and hiding of state-

process, and extreme late-binding of all things.

What's the Problem?

BBOM Solution

Events Solution

Events Dev UX

FrictionMessage ConventionsSerialization FormatPersistence Configuration

Harder to DeployMany Endpoints vs One Application

Decreased Legibilityribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/

Developer's Opinion ofBBOM

- thedailywtf.com Comment On The Enterprise Dependency

Executive Summary ofBBOM

Executive Summary ofMessaging

Combat Friction

Don't Call It a Rewritepublic class OrderController{ ...

public OrderController( IOrderRepository orders, IBillingService billing, IShippingService shipping) { _orders = orders; _billing = billing; _shipping = shipping; }

public HttpStatusCode Post(Order order) { _orders.Save(order.OrderDetails); _billing.Charge(order.BillingDetails); _shipping.Ship(order.ShippingDetails);

return HttpStatusCode.OK; }}

ContextRemember that time when we couldn't deploy anything for 6weeks...Remember that time when the strategic marketing initiativewas held up due to a Shipping upgrade...

Restore some Legibility

The Big Ball of Mud will not die easily

Have No Illusions

- Advanced Life Skills

Automate

Automate

Automate

Conventions: Web vs EndpointSeparate configuration repoDays to MinutesSmaller, more frequent releasesConfidenceRepeatability

Configurationdb alert

local http://localhost:8080 alerts@devnull.example.comdev http://localhost:8080 alerts@dev.example.comqa http://qa:8080 alerts@qa.example.comprod http://p532977:8080 alerts@example.com

Over time, layer in...

Don't Do an"Automation Project"

Build scriptspowershell / msbuildTeam City / Bamboo

Deploy scriptspowershellOctopus Deploy

Monitoring and MetricsService Insight / ControlSCOM

Discussion on DevOPS Experience on devopslive.org

Bus Stopgithub.com/andreasohlund/BusStop

Bus Stopnamespace BusStop.Config{ public static class MyConvention { public static Configure MyMessageConventions(this Configure config) { config.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Contracts")); return config; } }}

github.com/andreasohlund/BusStop

Endpoints vs Handlers

Before

All Together

Combined

Dev UX

Build Artifacts

Mix and Match

NServiceBus.Host.exe -endpointName=orders

Run

Decouple Dev from OPSRedeploy without recompileTie to Platform Tools

Pushing Forwards

A 2nd Look at Events Implpublic class OrderController{ public IBus Bus { get; set; }

public HttpStatusCode Post(ProcessOrder order) { Bus.Send(order); return HttpStatusCode.OK; }}

...

public class OrderHandler : IHandleMessages<ProcessOrder>{ public IBus Bus { get; set; }

public void Handle(ProcessOrder message) { //save order... Bus.Publish<IOrderAccepted>(x => x.Id = message.Id); }}

One Choicepublic class OrderController{ private IFactory<Duck<Mockable<ProcessOrder>>> _something; public IBus Bus { get; set; }

public OrderController(IFactory<Duck<Mockable<ProcessOrder>>> something) { _something = something; } public HttpStatusCode Post(ProcessOrder order) { _something.Process(order); return HttpStatusCode.OK; }}

...

public class OrderHandler : IHandleMessages<ProcessOrder>{ private IFactory<Duck<Mockable<ProcessOrder>>> _something; public IBus Bus { get; set; }

public OrderHandler(IFactory<Duck<Mockable<ProcessOrder>>> something) { _something = something; } public void Handle(ProcessOrder message) {

Exploit Decouplingpublic class OrderController{ private readonly IHandleMessages<ProcessOrder> _handler; public IBus Bus { get; set; }

public OrderController(IHandleMessages<ProcessOrder> handler) { _handler = handler; }

public HttpStatusCode Post(ProcessOrder order) { _handler.Handle(order); return HttpStatusCode.OK; }}

...

public class OrderHandler : IHandleMessages<ProcessOrder>{ public IBus Bus { get; set; }

public void Handle(ProcessOrder message) { //save order... Bus.Publish<IOrderAccepted>(x => x.Id = message.Id); }}

Run

Subscriptions

Subscribed

Direct

Future exploration

Later....

Break Apart the API?{ "submit-order" : "http://api.example.com/orders"}

{ "submit-order" : "http://orders.example.com/"}

HAL - Hypertext Application Language

What about queries?N fanout queries vs 1 for commandVolatile queuesCould work with proper circuit breakersEasier configuration with mulitple databases

Assembly NeutralInterfaces

davidfowl.com/assembly-neutral-interfaces/Consumer Driven Contracts

What if source files were distrbuted....

Roslyn

THE END

Advanced NServiceBusDeployment

Questions?slides @ github.com/kijanawoodard/NSBCon-NYC-2014/kijanawoodard.comtwitter.com/kijanawoodard

top related