1. Building enterprise
applications with
NServiceBus
Andreas Öhlund
twitter: @andreasohlund
blog: andreasohlund.blogspot.com
tisdag den 15 juni 2010
2. What is a distributed
system?
“A distributed system is one in which the
failure of a computer you didn't even
know existed can render your own
computer unusable”
-Leslie Lamport
tisdag den 15 juni 2010
9. The effects of
tight coupling
Temporal
Behavioral
tisdag den 15 juni 2010
10. Communication and
coupling
Low
command - oriented event - oriented
Temporal
distributed 3-layer Emergency services
High
High Low
Behavioural
tisdag den 15 juni 2010
11. Coupling NServiceBus style
Low Command - oriented Event - oriented
Temporal
High Distributed 3-layer Emergency services
High Behavioural Low
tisdag den 15 juni 2010
12. Command oriented
communication
CompleteSaleCommand
OnlineSales OrderService
tisdag den 15 juni 2010
14. Receiving and
processing of messages
public class CompleteSaleMessageHandler:
CreateOrderCommand
IHandleMessages<CompleteSaleCommand>
{ OrderService
public void Handle(CompleteSaleCommand c)
{
...
}
}
tisdag den 15 juni 2010
15. Throttling the load
• Manage traffic peaks
• Consumer controls the pace
• <MsmqTransportConfig
NumberOfWorkerThreads="3" />
tisdag den 15 juni 2010
16. What happens when the load
becomes to heavy for one server?
tisdag den 15 juni 2010
18. Building consistent systems
• Do we produce
predictable results even
under failure conditions?
• What about non
transactional sources?
tisdag den 15 juni 2010
19. Isolate non transactional sources as
separate endpoints
public void Handle(CompleteSaleCommand cmd)
{
var order = ....
orderRepository.Save(order)
smtpClient.Send(new MailMessage{...})
}
tisdag den 15 juni 2010
20. Isolate non transactional sources as
separate endpoints
public void Handle(CompleteSaleCommand cmd)
{
public void Handle(CompleteSaleCommand cmd)
{ var order = ....
orderRepository.Save(order)
var order = ....
orderRepository.Save(order)
bus.Send(new NotifyCustomerRequest
{
smtpClient.Send(new MailMessage{...})
} EmailAddress = customer.Email,
Body = “Order confirmation”
});
}
tisdag den 15 juni 2010
22. Messaging gives you a
chance to do better
• No more showing the users a WSOD
• Messages are replayable
• Async communication opens up a crucial
windows of time for corrections
tisdag den 15 juni 2010
23. Coupling NServiceBus style
Low Command - oriented Event - oriented
Temporal
High Distributed 3-layer Emergency services
High Low
Behavioural
tisdag den 15 juni 2010