-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
518d164
commit 2724ae6
Showing
23 changed files
with
264 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Contracts; | ||
using Models; | ||
using NPoco; | ||
using NServiceBus; | ||
using NServiceBus.MessageRouting.RoutingSlips; | ||
|
||
namespace ComponentAService | ||
{ | ||
public class BuildWidgetHandler : IHandleMessages<BuildWidgetCommand> | ||
{ | ||
private readonly RoutingSlip _routingSlip; | ||
|
||
public BuildWidgetHandler(RoutingSlip routingSlip) | ||
{ | ||
_routingSlip = routingSlip; | ||
} | ||
|
||
public void Handle(BuildWidgetCommand message) | ||
{ | ||
using (var db = new Database("connstr")) | ||
{ | ||
db.BeginTransaction(); | ||
db.Execute("UPDATE TOP(1) Component_A SET batchid = @0 WHERE batchid IS NULL", message.BatchId); | ||
var componentA = db.Single<Component_A>("WHERE batchid = @0", message.BatchId); | ||
|
||
_routingSlip.Attachments["componentAId"] = componentA.id.ToString(); | ||
|
||
db.CompleteTransaction(); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Iesi.Collections" version="4.0.1.4000" targetFramework="net45" /> | ||
<package id="NHibernate" version="4.0.1.4000" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net451" /> | ||
<package id="NPoco" version="2.6.88" targetFramework="net451" /> | ||
<package id="NServiceBus" version="5.0.0" targetFramework="net45" /> | ||
<package id="NServiceBus.Host" version="6.0.0" targetFramework="net45" /> | ||
<package id="NServiceBus.NHibernate" version="6.0.1" targetFramework="net45" /> | ||
<package id="NServiceBus.MessageRouting" version="1.0.1.0" targetFramework="net451" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Contracts; | ||
using Models; | ||
using NPoco; | ||
using NServiceBus; | ||
using NServiceBus.MessageRouting.RoutingSlips; | ||
|
||
namespace ComponentBService | ||
{ | ||
public class BuildWidgetHandler : IHandleMessages<BuildWidgetCommand> | ||
{ | ||
private readonly RoutingSlip _routingSlip; | ||
|
||
public BuildWidgetHandler(RoutingSlip routingSlip) | ||
{ | ||
_routingSlip = routingSlip; | ||
} | ||
|
||
public void Handle(BuildWidgetCommand message) | ||
{ | ||
using (var db = new Database("connstr")) | ||
{ | ||
db.BeginTransaction(); | ||
db.Execute("UPDATE TOP(1) Component_B SET batchid = @0 WHERE batchid IS NULL", message.BatchId); | ||
var componentB = db.Single<Component_B>("WHERE batchid = @0", message.BatchId); | ||
|
||
_routingSlip.Attachments["componentBId"] = componentB.id.ToString(); | ||
|
||
db.CompleteTransaction(); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Iesi.Collections" version="4.0.1.4000" targetFramework="net45" /> | ||
<package id="NHibernate" version="4.0.1.4000" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net451" /> | ||
<package id="NPoco" version="2.6.88" targetFramework="net451" /> | ||
<package id="NServiceBus" version="5.1.3" targetFramework="net45" /> | ||
<package id="NServiceBus.Host" version="6.0.0" targetFramework="net45" /> | ||
<package id="NServiceBus.NHibernate" version="6.0.1" targetFramework="net45" /> | ||
<package id="NServiceBus.MessageRouting" version="1.0.1.0" targetFramework="net451" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/WidgetSaga/ProcessComplete.cs → src/Contracts/ProcessComplete.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using NServiceBus; | ||
|
||
namespace WidgetSaga | ||
namespace Contracts | ||
{ | ||
public class ProcessComplete : ICommand | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | ||
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | ||
<configuration> | ||
<configSections> | ||
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" /> | ||
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" /> | ||
<section name="TransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core" /> | ||
<section name="AuditConfig" type="NServiceBus.Config.AuditConfig, NServiceBus.Core" /> | ||
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core"/> | ||
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/> | ||
<section name="TransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core"/> | ||
<section name="AuditConfig" type="NServiceBus.Config.AuditConfig, NServiceBus.Core"/> | ||
</configSections> | ||
<connectionStrings> | ||
<add name="connstr" connectionString="Server=.\SQLEXPRESS;Database=RoutingSlipsSample;Trusted_Connection=True;" providerName="System.Data.SqlClient" /> | ||
<add name="connstr" connectionString="Server=.\SQLEXPRESS;Database=RoutingSlipsSample;Trusted_Connection=True;" providerName="System.Data.SqlClient"/> | ||
<add name="NServiceBus/Persistence" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Trusted_Connection=True;"/> | ||
</connectionStrings> | ||
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error" /> | ||
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/> | ||
<UnicastBusConfig> | ||
<MessageEndpointMappings /> | ||
<MessageEndpointMappings/> | ||
</UnicastBusConfig> | ||
<AuditConfig QueueName="audit" /> | ||
<TransportConfig MaximumConcurrencyLevel="4" MaxRetries="2" MaximumMessageThroughputPerSecond="0" /> | ||
</configuration> | ||
<AuditConfig QueueName="audit"/> | ||
<TransportConfig MaximumConcurrencyLevel="4" MaxRetries="2" MaximumMessageThroughputPerSecond="0"/> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using Contracts; | ||
using NServiceBus; | ||
using NServiceBus.MessageRouting.RoutingSlips; | ||
|
||
namespace Service | ||
{ | ||
public class BuildWidgetHandler : IHandleMessages<BuildWidgetCommand> | ||
{ | ||
private readonly IBus _bus; | ||
|
||
public BuildWidgetHandler(IBus bus) | ||
{ | ||
_bus = bus; | ||
} | ||
|
||
public void Handle(BuildWidgetCommand message) | ||
{ | ||
var destinations = new List<string>(); | ||
destinations.Add("ComponentAService"); | ||
|
||
if(message.NeedsComponentB) | ||
destinations.Add("ComponentBService"); | ||
|
||
destinations.Add("WidgetService"); | ||
|
||
_bus.Route(message, destinations.ToArray()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.