how to swing a service bus like you mean it
DESCRIPTION
How to Swing a Service Bus Like You Mean It. SOA with NServiceBus. Jim Pelletier @pjimmy [email protected]. What is NServiceBus?. Asynchronous Messaging Framework Durable messaging with MSMQ Moderately Opinionated Event Driven Autonomous Services as opposed to RPC Web Services. - PowerPoint PPT PresentationTRANSCRIPT
![Page 2: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/2.jpg)
What is NServiceBus?
• Asynchronous Messaging Framework• Durable messaging with MSMQ• Moderately Opinionated• Event Driven Autonomous Services as
opposed to RPC Web Services
![Page 3: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/3.jpg)
Yeah? So… What about it?
SOA Provides:• Freedom of design and implementation • Unprecedented flexibility for growth & change• Waste nearly no code on pure technical concerns
SOA with Messaging VS.
N-Tier with RPC
![Page 4: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/4.jpg)
Outline & Disclaimer• Just presenting a different possibility
• Mainly talking and pictures, with a little code:– Intro to Messaging with NServiceBus– Messaging Patterns– Modeling using Messages– Autonomous Services, Boundaries and Decoupling via Messaging– Architecture Overview– SOA Composite Application Demo
![Page 5: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/5.jpg)
App
Messaging with Queues
App
SendQueueQueue
Receive
Makes for inherently asynchronous systems able to deal with spikes in load
![Page 6: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/6.jpg)
Tx
App
Messaging with Transactional Queues
Tx
App
SendQueueQueue
Receive
Rollback
Makes robust applications simple to implement
Save or UpdateRollback
![Page 7: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/7.jpg)
Tx
App
Messaging with Durable Queues = Store & Forward
Tx
App
SendQueueQueue
Receive
Provides an alternative and elegant solution to availability & data loss
![Page 8: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/8.jpg)
Tx
App
Durable Transactional Queues = Fire & Forget
Tx
App
SendQueueQueue
Receive
Which we leverage thru NServiceBus to build much simpler, more flexible and scalable solutions
![Page 9: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/9.jpg)
Publisher
Subscriber
Subscribe
Subscriber
Subscriber
Subscriber
Subscriber
![Page 10: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/10.jpg)
Publisher
Subscriber
Subscriber
Subscriber
Subscriber
Subscriberabcdefgh
abcdefgh
abcdefgh
abcdefgh
abcdefgh
![Page 11: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/11.jpg)
Decisions Based on Past EventsPlace Order
Order Service
Billing Service
Order Placed
Customer Billed
Set Max Debit For Customer
Current Debt > Max Debt
Customer ID
Max DebtCurrent Balance
![Page 12: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/12.jpg)
Billing Service
Web UIWeb UI
UI
Code Demo: Stock Trading Website
IBM
+7.5
6IN
TC +0
.34
Ordering Service
Stock Ticker Service
GOOG
+0
.34 APPL
-2.3
MSF
T -5.
6
Place OrderO
rder
Ac c
epte
d
Customer Billed
![Page 13: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/13.jpg)
Modeling with MessagesCommand
Service
Service
Service
Service
Events
Events
![Page 14: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/14.jpg)
Modeling with commands & eventsUpdate Customer
Customer Service
Address Service
Validation Service
Transaction Service
Customer Updated
![Page 15: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/15.jpg)
Modeling with commands & eventsPlace Order
Order Service
Shipping Service
Billing Service
Customer Care Service
Order Placed
Customer Notified of Order Placed
Order Billed
Order Shipped
![Page 16: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/16.jpg)
Sales Service
Polymorphism, BC’s and DDD oh my!
Orders Service
Handle Place Order
Place Customers First Order
Place Order
Send Customer Catalogue & Order Forms
New Lead Identified
Order Accepted
Handle Place Order
Handle First
Order
Order Accepted
![Page 17: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/17.jpg)
What is a service?
Some code which exists exclusively as part of a service providing the sole source of a
given business capability to an organization
![Page 18: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/18.jpg)
What is a service?
It is made up of:
An Autonomous ServiceMVC Controllers &
ViewsXAML &
Presenters
Message Handlers
Business Logic
Some Persistent Store
• No “Orchestration” code• No “Management” code• No Transformation code• No Data Access code• No Data “Munging” code• No Error Handling• No Unreachable code • No unintended or unused code paths• No code except business abstractions
![Page 19: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/19.jpg)
What else is a service?
• Services are autonomous
![Page 20: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/20.jpg)
Decoupling with a Message Schema
Service A
Mgs Schema A
Service B
Mgs Schema B
Bus
![Page 21: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/21.jpg)
Composed application
Billing Service
Order Service
Pricing Service
Product Catalogue
Service
Layout & Branding Service
User Application Executable
Bus
NSB Host
Exec(s).
NSB HostExec(s).
NSB Host
Exec(s).
NSB Host
Exec(s).
![Page 22: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/22.jpg)
Code Demo – CrazyJimsSOA
• Composing a UI from many logically distinct components
![Page 23: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/23.jpg)
Layout & Branding Service
MVC Controllers
HTML + JavaScript
Catalogue Service
MVC Controllers
Pricing Service Ordering Service
MVC Controllers
MVC Controllers
![Page 24: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/24.jpg)
Catalogue Service
MVC Controllers
Pricing Service Ordering Service
Layout & Branding Service
MVC Controllers
MVC Controllers
MVC Controllers
{JSON} + <jTemplate \>
{JSON} + <jTemplate \>
{JSON} + <jTemplate \>
HTML + JavaScript
![Page 25: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/25.jpg)
#WIN like this…
• Freedom of design and implementation • Unprecedented flexibility for growth & change• Waste nearly no code on pure technical concerns
![Page 26: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/26.jpg)
Thanks & Resources• Thanks to @UdiDahan checkout his ADSD course! - http
://www.udidahan.com/training/#Advanced_Distributed_System_Design
• NServiceBus Website (Documentation & Community Sections are great) – http://www.nservicebus.com/
• Distributed Podcast - http://distributedpodcast.com/• NServiceBus Mailing List - http://tech.groups.yahoo.com/group/nservicebus/• Other Mailing Lists –
– http://groups.google.com/group/dddcqrs?pli=1– http://tech.groups.yahoo.com/group/service-orientated-architecture/– http://tech.groups.yahoo.com/group/domaindrivendesign/messages
![Page 27: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/27.jpg)
Questions?
![Page 29: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/29.jpg)
![Page 30: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/30.jpg)
AC’s, BC’s and DDD oh my!
Order Service
Order Processing running in NServiceBus.Host.exe
Order Placement UI running in a web site
![Page 31: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/31.jpg)
AC – Business Logic
AC -Persistent View Model Store
What is CQRS?
UI
Command Handlers
View Model Updaters
CommandsEv
ents
Queries
![Page 32: How to Swing a Service Bus Like You Mean It](https://reader036.vdocuments.us/reader036/viewer/2022081422/56816471550346895dd656b5/html5/thumbnails/32.jpg)
Where does CQRS fit in the picture?
Billing Service
Order Service
Pricing Service
Product Service
Layout & Branding Service
User Application Executable
Bus
NSB Host
Exec(s).
NSB HostExec(s).
NSB Host
Exec(s).
NSB Host
Exec(s).
Comm
ands Even
ts
Comm
ands