The document discusses challenges with monolithic "Big Ball of Mud" architectures and how messaging/event-driven architectures using NServiceBus can help address these. It covers how messaging allows for better encapsulation, separation of concerns, and loose coupling between components. It also discusses strategies for gradually transitioning from a monolith to a messaging system to reduce risk, including using the strangler pattern and automation.
2. Background
From Dallas, TX
Professional develop since 1996
.net since 1.0
Independent contractor since 2010
3. Around the web
kijanawoodard.com
twitter.com/kijanawoodard
github.com/kijanawoodard
linkedin.com/in/kijanawoodard
particular forum
ravendb forum
ddd/cqrs forum
hypermedia forum
4. Slides are on GitHub
github.com/kijanawoodard/NSBCon-NYC-2014/
13. Events Implementation
public 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);
}
}
14. Bliss
Encapsulation
Single Responsibility
Open Closed Principle
Interface Segregation Principle
Dependency Inversion Principle
15. It's almost as if...
OOP to me means only messaging, local
retention and protection and hiding of state-process,
and extreme late-binding of all things.
Alan Kay - 2003
27. Don't Call It a Rewrite
public 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;
}
}
28. Strangler Pattern
- Entry on Strangler Fig Wikipedia
http://www.martinfowler.com/bliki/StranglerApplication.html
29. Context
Remember that time when we couldn't deploy anything for 6
weeks...
Remember that time when the strategic marketing initiative
was held up due to a Shipping upgrade...
33. Conventions: Web vs Endpoint
Separate configuration repo
Days to Minutes
Smaller, more frequent releases
Confidence
Repeatability
34. Configuration
db alert
local http://localhost:8080 alerts@devnull.example.com
dev http://localhost:8080 alerts@dev.example.com
qa http://qa:8080 alerts@qa.example.com
prod http://p532977:8080 alerts@example.com
35. Don't Do an
"Automation Project"
Over time, layer in...
Build scripts
powershell / msbuild
Team City / Bamboo
Deploy scripts
powershell
Octopus Deploy
Monitoring and Metrics
Service Insight / Control
SCOM
Discussion on DevOPS Experience on devopslive.org
48. A 2nd Look at Events Impl
public 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);
}
}
49. One Choice
public 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)
{
50. Exploit Decoupling
public 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);
}
}
56. Break Apart the API?
Later....
{
"submit-order" : "http://api.example.com/orders"
}
{
"submit-order" : "http://orders.example.com/"
}
HAL - Hypertext Application Language
57. What about queries?
N fanout queries vs 1 for command
Volatile queues
Could work with proper circuit breakers
Easier configuration with mulitple databases