Skip to content

Commit

Permalink
Updating the manufacturing sample to use the [Unique] property for the
Browse files Browse the repository at this point in the history
purchase order number. Also changing the simulation to be a more real world like scenario.
  • Loading branch information
andreasohlund authored and shlomii committed May 8, 2012
1 parent 2a7e79d commit 9a325c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
Binary file modified Samples/Manufacturing/Manufacturing.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@
namespace OrderService
{
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher {}

public class TimeoutConfiguration:IWantCustomInitialization
{
public void Init()
{
Configure.Instance.RunTimeoutManager();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class OrderSagaData : IContainSagaData
public virtual Guid Id { get; set; }
public virtual string Originator { get; set; }
public virtual string OriginalMessageId { get; set; }

[Unique]
public virtual string PurchaseOrderNumber { get; set; }
public virtual Guid PartnerId { get; set; }
public virtual DateTime ProvideBy { get; set; }
Expand Down
17 changes: 9 additions & 8 deletions Samples/Manufacturing/Partner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,25 @@ static void Main()
private static void Simulate(IBus bus, bool step)
{
Guid partnerId = Guid.NewGuid();
int numberOfLines;
int numberOfOrders;
int secondsToProvideBy;

while(true)
{
Random r = new Random();
var r = new Random();

numberOfLines = 5 + r.Next(0, 5);
numberOfOrders = 5 + r.Next(0, 5);
secondsToProvideBy = 10 + r.Next(0, 10);
string purchaseOrderNumber = Guid.NewGuid().ToString();

for (int i = 0; i < numberOfLines; i++)
{

for (var i = 0; i < numberOfOrders; i++)
{
var purchaseOrderNumber = Guid.NewGuid().ToString();

bus.Send<IOrderMessage>(m =>
{
m.PurchaseOrderNumber = purchaseOrderNumber;
m.PartnerId = partnerId;
m.Done = (i == numberOfLines - 1);
m.Done = true;
m.ProvideBy = DateTime.UtcNow + TimeSpan.FromSeconds(secondsToProvideBy);
m.OrderLines = new List<IOrderLine> {
bus.CreateInstance<IOrderLine>(ol => {
Expand Down

0 comments on commit 9a325c7

Please sign in to comment.