SlideShare a Scribd company logo
1 of 35
Download to read offline
~
~ 
Roy Cornelissen 
Software Architect 
@roycornelissen 
Mark Taling 
Lead Developer 
@marktaling
Where we started 
Discovering NServiceBus 
Multi tenancy 
Saga’s 
The evolution of NServiceBus 
Performance considerations 
Maintainability 
NServiceBusin a brownfield 
Wrap up 
Q&A
Integration Layer 
Service Layer 
NIS 
Presentation Layer 
Planning UI 
Reporting UI 
customer 
external apps 
Employee Self Service 
Common 
Forecast 
Realization 
Payment 
Schedule
Monitoring & Control 
Integration Layer 
Service Layer 
NIS 
Presentation Layer 
Planning UI 
Reporting UI 
Employee Self Service 
Common 
Forecast 
Payment 
Schedule 
Service Bus 
Integration Services 
IS HRM 
IS Payroll 
IS Budget 
IS Provisioning 
IS Time 
IS Point of Sale 
Realization
Tenant ID 
Tenant ID 
Tenant ID 
Tenant ID
publicclassBuildPrincipalFromHeaders:IMutateIncomingMessages 
{ 
publicobjectMutateIncoming(objectmessage) 
{ 
Thread.CurrentPrincipal=null; 
stringtenantId=Headers.GetMessageHeader(message,“urn:dv:tenantid”); 
ICollection<Claim>claims=newList<Claim>(); 
… 
claims.Add(newClaim(SecurityConstants.TenantIdClaim,tenantId)); 
varprincipal=newClaimsPrincipal( 
newClaimsIdentityCollection{ newClaimsIdentity(claims) }); 
Thread.CurrentPrincipal=principal; 
returnmessage; 
} 
…
publicclassSetHeadersFromPrincipal:IMutateOutgoingMessages 
{ 
publicIBusBus{get;set;} 
publicobjectMutateOutgoing(objectmessage) 
{ 
IClaimsIdentityidentity= 
Thread.CurrentPrincipal.IdentityasIClaimsIdentity; 
stringtenantId=identity.GetTenantId(); 
if(!string.IsNullOrWhiteSpace(tenantId)) 
{ 
Bus.SetMessageHeader(message,“urn:dv:tenantid”,tenantId); 
} 
returnmessage; 
} 
…
-Multiple properties 
-Concatenation 
-IFindSaga 
-ISagaPersister
publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); } publicnewvoidComplete(IContainSagaDatasaga) { base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); } publicnewvoidComplete(IContainSagaDatasaga) { base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); StoreMappingKeys(saga); } publicnewvoidComplete(IContainSagaDatasaga) { RemoveMappingKeys(saga); base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ privatereadonlyRavenSessionFactory_sessionFactory; publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { _sessionFactory= sessionFactory; } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); StoreMappingKeys(saga); } publicnewvoidComplete(IContainSagaDatasaga) { RemoveMappingKeys(saga); base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ privatereadonlyRavenSessionFactory_sessionFactory; publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { _sessionFactory= sessionFactory; } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); StoreMappingKeys(saga); } publicnewvoidComplete(IContainSagaDatasaga) { RemoveMappingKeys(saga); base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } } vardocument = _sessionFactory.Session.Include("SagaDocId").Load<SagaMappingIdentity>(mappingId); return_sessionFactory.Session.Load<TSagaData>(document.SagaId);
RequestUtcTimeout<PolicyRenewal>(TimeSpan.FromDays(300));
Lessonslearned 
-Upgrade regularly 
-RetryPoCsandassumptions 
-Beware of abstractions
Lessonslearned 
-Upgrade regularly 
-RetryPoCsandassumptions 
-Beware of abstractions
Keep yourtransactions on a diet 
Design withparallelismin mind 
{Tx} 
[Unique] saga properties
Keep yourtransactions on a diet 
Design withparallelismin mind 
{Tx} 
{Tx} 
[Unique] saga properties 
{Tx}
UseTransport<Rfc1149>(); 
http://www.make-awesome.com/2014/04/nservicebus-transport-for-rfc-1149/
NServiceBusis an opinionatedframework 
If it fits, it fits like a glove 
Prepare to make concessionsat first 
Clean up later 
Messaging makes totally different use cases possible 
Requires a new mindsetfor everyone
NServiceBusis a greatway tobreak open existingarchitectures 
Despiteitsflexibility andpluggability, alwaysfollow itsdesign principles 
Go withthe flow, itsolvesreal life problemsyoumightnotknowyouhave
~ 
Roy Cornelissen 
Software Architect 
@roycornelissen 
Mark Taling 
Lead Developer 
@marktaling 
blogs.infosupport.com

More Related Content

What's hot

DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a CometDDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
Richard Banks
 
Compensating Transactions: When ACID is too much
Compensating Transactions: When ACID is too muchCompensating Transactions: When ACID is too much
Compensating Transactions: When ACID is too much
JBUG London
 

What's hot (20)

DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a CometDDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
 
Reactive Architectures
Reactive ArchitecturesReactive Architectures
Reactive Architectures
 
Celix, Universal OSGi?
Celix, Universal OSGi?Celix, Universal OSGi?
Celix, Universal OSGi?
 
Message Oriented Architecture using NServiceBus
Message Oriented Architecture using NServiceBusMessage Oriented Architecture using NServiceBus
Message Oriented Architecture using NServiceBus
 
Taking Your Enterprise to the Next Level with WSO2 Message Broker and WSO2 En...
Taking Your Enterprise to the Next Level with WSO2 Message Broker and WSO2 En...Taking Your Enterprise to the Next Level with WSO2 Message Broker and WSO2 En...
Taking Your Enterprise to the Next Level with WSO2 Message Broker and WSO2 En...
 
Messaging in the cloud - Azure Service Bus
Messaging in the cloud - Azure Service BusMessaging in the cloud - Azure Service Bus
Messaging in the cloud - Azure Service Bus
 
CQRS and ES with Lagom
CQRS and ES with LagomCQRS and ES with Lagom
CQRS and ES with Lagom
 
Sql Server Service Broker In The Real World
Sql Server Service Broker In The Real WorldSql Server Service Broker In The Real World
Sql Server Service Broker In The Real World
 
Automating the Entire PostgreSQL Lifecycle
Automating the Entire PostgreSQL Lifecycle Automating the Entire PostgreSQL Lifecycle
Automating the Entire PostgreSQL Lifecycle
 
Micro service architecture
Micro service architectureMicro service architecture
Micro service architecture
 
Building a Web Frontend with Microservices and NGINX Plus
Building a Web Frontend with Microservices and NGINX PlusBuilding a Web Frontend with Microservices and NGINX Plus
Building a Web Frontend with Microservices and NGINX Plus
 
KubeCon + CloudNative Con NA 2021 | A New Generation of NATS
KubeCon + CloudNative Con NA 2021 | A New Generation of NATSKubeCon + CloudNative Con NA 2021 | A New Generation of NATS
KubeCon + CloudNative Con NA 2021 | A New Generation of NATS
 
Azure paa s v2 – microservices, microsoft (azure) service fabric, .apps and o...
Azure paa s v2 – microservices, microsoft (azure) service fabric, .apps and o...Azure paa s v2 – microservices, microsoft (azure) service fabric, .apps and o...
Azure paa s v2 – microservices, microsoft (azure) service fabric, .apps and o...
 
How Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine LearningHow Clarifai uses NATS and Kubernetes for Machine Learning
How Clarifai uses NATS and Kubernetes for Machine Learning
 
JavaOne 2016 - Reactive Microservices with Java and Java EE
JavaOne 2016 - Reactive Microservices with Java and Java EEJavaOne 2016 - Reactive Microservices with Java and Java EE
JavaOne 2016 - Reactive Microservices with Java and Java EE
 
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
Real-world #microservices with Apache Camel, Fabric8, and OpenShiftReal-world #microservices with Apache Camel, Fabric8, and OpenShift
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
 
How lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsHow lagom helps to build real world microservice systems
How lagom helps to build real world microservice systems
 
Lagom in Practice
Lagom in PracticeLagom in Practice
Lagom in Practice
 
Compensating Transactions: When ACID is too much
Compensating Transactions: When ACID is too muchCompensating Transactions: When ACID is too much
Compensating Transactions: When ACID is too much
 
Azure service fabric: a gentle introduction
Azure service fabric: a gentle introductionAzure service fabric: a gentle introduction
Azure service fabric: a gentle introduction
 

Similar to Embracing Nservicebus Best Practices

Similar to Embracing Nservicebus Best Practices (20)

Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
AWS January 2016 Webinar Series - Managing your Infrastructure as Code
AWS January 2016 Webinar Series - Managing your Infrastructure as CodeAWS January 2016 Webinar Series - Managing your Infrastructure as Code
AWS January 2016 Webinar Series - Managing your Infrastructure as Code
 
Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19
 
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
 
The use case of a scalable architecture
The use case of a scalable architectureThe use case of a scalable architecture
The use case of a scalable architecture
 
Vertx - Reactive & Distributed
Vertx - Reactive & DistributedVertx - Reactive & Distributed
Vertx - Reactive & Distributed
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"
 
Futures and Rx Observables: powerful abstractions for consuming web services ...
Futures and Rx Observables: powerful abstractions for consuming web services ...Futures and Rx Observables: powerful abstractions for consuming web services ...
Futures and Rx Observables: powerful abstractions for consuming web services ...
 
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
 

More from Particular Software

More from Particular Software (20)

Scaling for Success: Lessons from handling peak loads on Azure with NServiceBus
Scaling for Success: Lessons from handling peak loads on Azure with NServiceBusScaling for Success: Lessons from handling peak loads on Azure with NServiceBus
Scaling for Success: Lessons from handling peak loads on Azure with NServiceBus
 
Beyond simple benchmarks—a practical guide to optimizing code
Beyond simple benchmarks—a practical guide to optimizing code Beyond simple benchmarks—a practical guide to optimizing code
Beyond simple benchmarks—a practical guide to optimizing code
 
An exception occurred - Please try again
An exception occurred - Please try againAn exception occurred - Please try again
An exception occurred - Please try again
 
Tales from the trenches creating complex distributed systems
Tales from the trenches  creating complex distributed systemsTales from the trenches  creating complex distributed systems
Tales from the trenches creating complex distributed systems
 
Got the time?
Got the time?Got the time?
Got the time?
 
Implementing outbox model-checking first
Implementing outbox   model-checking firstImplementing outbox   model-checking first
Implementing outbox model-checking first
 
Reports from the field azure functions in practice
Reports from the field   azure functions in practiceReports from the field   azure functions in practice
Reports from the field azure functions in practice
 
Finding your service boundaries - a practical guide
Finding your service boundaries - a practical guideFinding your service boundaries - a practical guide
Finding your service boundaries - a practical guide
 
Decomposing .NET Monoliths with NServiceBus and Docker
Decomposing .NET Monoliths with NServiceBus and DockerDecomposing .NET Monoliths with NServiceBus and Docker
Decomposing .NET Monoliths with NServiceBus and Docker
 
DIY Async Message Pump: Lessons from the trenches
DIY Async Message Pump: Lessons from the trenchesDIY Async Message Pump: Lessons from the trenches
DIY Async Message Pump: Lessons from the trenches
 
Share the insight of ServiceInsight
Share the insight of ServiceInsightShare the insight of ServiceInsight
Share the insight of ServiceInsight
 
What to consider when monitoring microservices
What to consider when monitoring microservicesWhat to consider when monitoring microservices
What to consider when monitoring microservices
 
Making communications across boundaries simple with NServiceBus
Making communications across boundaries simple with NServiceBusMaking communications across boundaries simple with NServiceBus
Making communications across boundaries simple with NServiceBus
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service Bus
 
How to avoid microservice pitfalls
How to avoid microservice pitfallsHow to avoid microservice pitfalls
How to avoid microservice pitfalls
 
Connect front end to back end using SignalR and Messaging
Connect front end to back end using SignalR and MessagingConnect front end to back end using SignalR and Messaging
Connect front end to back end using SignalR and Messaging
 
Async/Await: NServiceBus v6 API Update
Async/Await: NServiceBus v6 API UpdateAsync/Await: NServiceBus v6 API Update
Async/Await: NServiceBus v6 API Update
 
Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps
 
Async/Await Best Practices
Async/Await Best PracticesAsync/Await Best Practices
Async/Await Best Practices
 
Making workflow implementation easy with CQRS
Making workflow implementation easy with CQRSMaking workflow implementation easy with CQRS
Making workflow implementation easy with CQRS
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Embracing Nservicebus Best Practices

  • 1. ~
  • 2. ~ Roy Cornelissen Software Architect @roycornelissen Mark Taling Lead Developer @marktaling
  • 3. Where we started Discovering NServiceBus Multi tenancy Saga’s The evolution of NServiceBus Performance considerations Maintainability NServiceBusin a brownfield Wrap up Q&A
  • 4. Integration Layer Service Layer NIS Presentation Layer Planning UI Reporting UI customer external apps Employee Self Service Common Forecast Realization Payment Schedule
  • 5. Monitoring & Control Integration Layer Service Layer NIS Presentation Layer Planning UI Reporting UI Employee Self Service Common Forecast Payment Schedule Service Bus Integration Services IS HRM IS Payroll IS Budget IS Provisioning IS Time IS Point of Sale Realization
  • 6.
  • 7. Tenant ID Tenant ID Tenant ID Tenant ID
  • 8. publicclassBuildPrincipalFromHeaders:IMutateIncomingMessages { publicobjectMutateIncoming(objectmessage) { Thread.CurrentPrincipal=null; stringtenantId=Headers.GetMessageHeader(message,“urn:dv:tenantid”); ICollection<Claim>claims=newList<Claim>(); … claims.Add(newClaim(SecurityConstants.TenantIdClaim,tenantId)); varprincipal=newClaimsPrincipal( newClaimsIdentityCollection{ newClaimsIdentity(claims) }); Thread.CurrentPrincipal=principal; returnmessage; } …
  • 9. publicclassSetHeadersFromPrincipal:IMutateOutgoingMessages { publicIBusBus{get;set;} publicobjectMutateOutgoing(objectmessage) { IClaimsIdentityidentity= Thread.CurrentPrincipal.IdentityasIClaimsIdentity; stringtenantId=identity.GetTenantId(); if(!string.IsNullOrWhiteSpace(tenantId)) { Bus.SetMessageHeader(message,“urn:dv:tenantid”,tenantId); } returnmessage; } …
  • 10. -Multiple properties -Concatenation -IFindSaga -ISagaPersister
  • 11.
  • 12. publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); } publicnewvoidComplete(IContainSagaDatasaga) { base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
  • 13. publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); } publicnewvoidComplete(IContainSagaDatasaga) { base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
  • 14. publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); StoreMappingKeys(saga); } publicnewvoidComplete(IContainSagaDatasaga) { RemoveMappingKeys(saga); base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
  • 15. publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ privatereadonlyRavenSessionFactory_sessionFactory; publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { _sessionFactory= sessionFactory; } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); StoreMappingKeys(saga); } publicnewvoidComplete(IContainSagaDatasaga) { RemoveMappingKeys(saga); base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } }
  • 16. publicclassAdvancedRavenSagaPersister: RavenSagaPersister, ISagaPersister{ privatereadonlyRavenSessionFactory_sessionFactory; publicAdvancedRavenSagaPersister(RavenSessionFactorysessionFactory): base(sessionFactory) { _sessionFactory= sessionFactory; } publicnewvoidSave(IContainSagaDatasaga) { base.Save(saga); StoreMappingKeys(saga); } publicnewvoidComplete(IContainSagaDatasaga) { RemoveMappingKeys(saga); base.Complete(saga); } voidISagaPersister.Save(IContainSagaDatasaga) { Save(saga); } voidISagaPersister.Complete(IContainSagaDatasaga) { Complete(saga); } } vardocument = _sessionFactory.Session.Include("SagaDocId").Load<SagaMappingIdentity>(mappingId); return_sessionFactory.Session.Load<TSagaData>(document.SagaId);
  • 17.
  • 18.
  • 19.
  • 20.
  • 22. Lessonslearned -Upgrade regularly -RetryPoCsandassumptions -Beware of abstractions
  • 23. Lessonslearned -Upgrade regularly -RetryPoCsandassumptions -Beware of abstractions
  • 24. Keep yourtransactions on a diet Design withparallelismin mind {Tx} [Unique] saga properties
  • 25. Keep yourtransactions on a diet Design withparallelismin mind {Tx} {Tx} [Unique] saga properties {Tx}
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 33. NServiceBusis an opinionatedframework If it fits, it fits like a glove Prepare to make concessionsat first Clean up later Messaging makes totally different use cases possible Requires a new mindsetfor everyone
  • 34. NServiceBusis a greatway tobreak open existingarchitectures Despiteitsflexibility andpluggability, alwaysfollow itsdesign principles Go withthe flow, itsolvesreal life problemsyoumightnotknowyouhave
  • 35. ~ Roy Cornelissen Software Architect @roycornelissen Mark Taling Lead Developer @marktaling blogs.infosupport.com