Skip to content

Commit 67031b0

Browse files
committed
Merge branch 'release/3.0'
2 parents 1f70b2f + 8675ab3 commit 67031b0

File tree

156 files changed

+2571
-1245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+2571
-1245
lines changed

Examples/01-PublishSubscribe/01-PublishSubscribe.csproj

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>_01_PublishSubscribe</RootNamespace>
7+
<Nullable>enable</Nullable>
78
</PropertyGroup>
89

910
<ItemGroup>
10-
<PackageReference Include="Autofac" Version="6.2.0" />
11-
<PackageReference Include="Castle.Windsor" Version="5.1.1" />
12-
<PackageReference Include="Ninject" Version="3.3.4" />
13-
<PackageReference Include="SimpleInjector" Version="5.3.0" />
14-
<PackageReference Include="Unity" Version="5.11.10" />
11+
<PackageReference Include="Autofac" Version="6.5.0" />
12+
<PackageReference Include="Castle.Windsor" Version="5.1.2" />
13+
<PackageReference Include="Ninject" Version="3.3.6" />
14+
<PackageReference Include="SimpleInjector" Version="5.4.1" />
1515
</ItemGroup>
1616

1717
<ItemGroup>
@@ -20,7 +20,6 @@
2020
<ProjectReference Include="..\..\Tapeti.DataAnnotations\Tapeti.DataAnnotations.csproj" />
2121
<ProjectReference Include="..\..\Tapeti.Ninject\Tapeti.Ninject.csproj" />
2222
<ProjectReference Include="..\..\Tapeti.SimpleInjector\Tapeti.SimpleInjector.csproj" />
23-
<ProjectReference Include="..\..\Tapeti.UnityContainer\Tapeti.UnityContainer.csproj" />
2423
<ProjectReference Include="..\..\Tapeti\Tapeti.csproj" />
2524
<ProjectReference Include="..\ExampleLib\ExampleLib.csproj" />
2625
<ProjectReference Include="..\Messaging.TapetiExample\Messaging.TapetiExample.csproj" />

Examples/01-PublishSubscribe/Program.cs

+17-32
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
using Tapeti.Default;
1414
using Tapeti.Ninject;
1515
using Tapeti.SimpleInjector;
16-
using Tapeti.UnityContainer;
17-
using Unity;
1816
using Container = SimpleInjector.Container;
1917

2018
// ReSharper disable UnusedMember.Global
@@ -23,14 +21,13 @@ namespace _01_PublishSubscribe
2321
{
2422
public class Program
2523
{
26-
public static void Main(string[] args)
24+
public static void Main()
2725
{
2826
var dependencyResolver = GetSimpleInjectorDependencyResolver();
2927

3028
// or use your IoC container of choice:
3129
//var dependencyResolver = GetAutofacDependencyResolver();
3230
//var dependencyResolver = GetCastleWindsorDependencyResolver();
33-
//var dependencyResolver = GetUnityDependencyResolver();
3431
//var dependencyResolver = GetNinjectDependencyResolver();
3532

3633
// This helper is used because this example is not run as a service. You do not
@@ -47,7 +44,7 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
4744
.RegisterAllControllers()
4845
.Build();
4946

50-
using (var connection = new TapetiConnection(config)
47+
await using var connection = new TapetiConnection(config)
5148
{
5249
// Params is optional if you want to use the defaults, but we'll set it
5350
// explicitly for this example
@@ -63,28 +60,27 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
6360
{ "example", "01 - Publish Subscribe" }
6461
}
6562
}
66-
})
67-
{
68-
// IoC containers that separate the builder from the resolver (Autofac) must be built after
69-
// creating a TapetConnection, as it modifies the container by injecting IPublisher.
70-
(dependencyResolver as AutofacDependencyResolver)?.Build();
63+
};
64+
65+
// IoC containers that separate the builder from the resolver (Autofac) must be built after
66+
// creating a TapetConnection, as it modifies the container by injecting IPublisher.
67+
(dependencyResolver as AutofacDependencyResolver)?.Build();
7168

7269

73-
// Create the queues and start consuming immediately.
74-
// If you need to do some processing before processing messages, but after the
75-
// queues have initialized, pass false as the startConsuming parameter and store
76-
// the returned ISubscriber. Then call Resume on it later.
77-
await connection.Subscribe();
70+
// Create the queues and start consuming immediately.
71+
// If you need to do some processing before processing messages, but after the
72+
// queues have initialized, pass false as the startConsuming parameter and store
73+
// the returned ISubscriber. Then call Resume on it later.
74+
await connection.Subscribe();
7875

7976

80-
// We could get an IPublisher from the container directly, but since you'll usually use
81-
// it as an injected constructor parameter this shows
82-
await dependencyResolver.Resolve<ExamplePublisher>().SendTestMessage();
77+
// We could get an IPublisher from the container directly, but since you'll usually use
78+
// it as an injected constructor parameter this shows
79+
await dependencyResolver.Resolve<ExamplePublisher>().SendTestMessage();
8380

8481

85-
// Wait for the controller to signal that the message has been received
86-
await waitForDone();
87-
}
82+
// Wait for the controller to signal that the message has been received
83+
await waitForDone();
8884
}
8985

9086

@@ -132,17 +128,6 @@ internal static IDependencyContainer GetCastleWindsorDependencyResolver()
132128
}
133129

134130

135-
internal static IDependencyContainer GetUnityDependencyResolver()
136-
{
137-
var container = new UnityContainer();
138-
139-
container.RegisterType<ILogger, ConsoleLogger>();
140-
container.RegisterType<ExamplePublisher>();
141-
142-
return new UnityDependencyResolver(container);
143-
}
144-
145-
146131
internal static IDependencyContainer GetNinjectDependencyResolver()
147132
{
148133
var kernel = new StandardKernel();

Examples/02-DeclareDurableQueues/02-DeclareDurableQueues.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>_02_DeclareDurableQueues</RootNamespace>
7+
<Nullable>enable</Nullable>
78
</PropertyGroup>
89

910
<ItemGroup>
10-
<PackageReference Include="SimpleInjector" Version="5.3.0" />
11+
<PackageReference Include="SimpleInjector" Version="5.4.1" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

Examples/02-DeclareDurableQueues/Program.cs

+11-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace _02_DeclareDurableQueues
1111
{
1212
public class Program
1313
{
14-
public static void Main(string[] args)
14+
public static void Main()
1515
{
1616
var container = new Container();
1717
var dependencyResolver = new SimpleInjectorDependencyResolver(container);
@@ -30,19 +30,18 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
3030
.EnableDeclareDurableQueues()
3131
.Build();
3232

33-
using (var connection = new TapetiConnection(config))
34-
{
35-
// This creates or updates the durable queue
36-
await connection.Subscribe();
33+
await using var connection = new TapetiConnection(config);
34+
35+
// This creates or updates the durable queue
36+
await connection.Subscribe();
3737

38-
await dependencyResolver.Resolve<IPublisher>().Publish(new PublishSubscribeMessage
39-
{
40-
Greeting = "Hello durable queue!"
41-
});
38+
await dependencyResolver.Resolve<IPublisher>().Publish(new PublishSubscribeMessage
39+
{
40+
Greeting = "Hello durable queue!"
41+
});
4242

43-
// Wait for the controller to signal that the message has been received
44-
await waitForDone();
45-
}
43+
// Wait for the controller to signal that the message has been received
44+
await waitForDone();
4645
}
4746
}
4847
}

Examples/03-FlowRequestResponse/03-FlowRequestResponse.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>_03_FlowRequestResponse</RootNamespace>
7+
<Nullable>enable</Nullable>
78
</PropertyGroup>
89

910
<ItemGroup>
10-
<PackageReference Include="SimpleInjector" Version="5.3.0" />
11+
<PackageReference Include="SimpleInjector" Version="5.4.1" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

Examples/03-FlowRequestResponse/ParallelFlowController.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public class ParallelFlowController
1515
private readonly IFlowProvider flowProvider;
1616
private readonly IExampleState exampleState;
1717

18-
public string FirstQuote;
19-
public string SecondQuote;
20-
public string ThirdQuote;
18+
public string? FirstQuote;
19+
public string? SecondQuote;
20+
public string? ThirdQuote;
2121

2222

2323
public ParallelFlowController(IFlowProvider flowProvider, IExampleState exampleState)
@@ -56,7 +56,7 @@ public void HandleFirstQuoteResponse(QuoteResponseMessage message)
5656

5757

5858
[Continuation]
59-
public async Task HandleSecondQuoteResponse(QuoteResponseMessage message, IFlowParallelRequest parallelRequest)
59+
public async ValueTask HandleSecondQuoteResponse(QuoteResponseMessage message, IFlowParallelRequest parallelRequest)
6060
{
6161
Console.WriteLine("[ParallelFlowController] Second quote response received");
6262
SecondQuote = message.Quote;

Examples/03-FlowRequestResponse/Program.cs

+19-20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace _03_FlowRequestResponse
1212
{
1313
public class Program
1414
{
15-
public static void Main(string[] args)
15+
public static void Main()
1616
{
1717
var container = new Container();
1818
var dependencyResolver = new SimpleInjectorDependencyResolver(container);
@@ -33,34 +33,33 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
3333
.Build();
3434

3535

36-
using (var connection = new TapetiConnection(config))
37-
{
38-
// Must be called before using any flow. When using a persistent repository like the
39-
// SQL server implementation, you can run any required update scripts (for example, using DbUp)
40-
// before calling this Load method.
41-
// Call after creating the TapetiConnection, as it modifies the container to inject IPublisher.
42-
await dependencyResolver.Resolve<IFlowStore>().Load();
36+
await using var connection = new TapetiConnection(config);
37+
38+
// Must be called before using any flow. When using a persistent repository like the
39+
// SQL server implementation, you can run any required update scripts (for example, using DbUp)
40+
// before calling this Load method.
41+
// Call after creating the TapetiConnection, as it modifies the container to inject IPublisher.
42+
await dependencyResolver.Resolve<IFlowStore>().Load();
4343

4444

45-
await connection.Subscribe();
45+
await connection.Subscribe();
4646

4747

48-
var flowStarter = dependencyResolver.Resolve<IFlowStarter>();
48+
var flowStarter = dependencyResolver.Resolve<IFlowStarter>();
4949

50-
var startData = new SimpleFlowController.StartData
51-
{
52-
RequestStartTime = DateTime.Now,
53-
Amount = 1
54-
};
50+
var startData = new SimpleFlowController.StartData
51+
{
52+
RequestStartTime = DateTime.Now,
53+
Amount = 1
54+
};
5555

5656

57-
await flowStarter.Start<SimpleFlowController, SimpleFlowController.StartData>(c => c.StartFlow, startData);
58-
await flowStarter.Start<ParallelFlowController>(c => c.StartFlow);
57+
await flowStarter.Start<SimpleFlowController, SimpleFlowController.StartData>(c => c.StartFlow, startData);
58+
await flowStarter.Start<ParallelFlowController>(c => c.StartFlow);
5959

6060

61-
// Wait for the controller to signal that the message has been received
62-
await waitForDone();
63-
}
61+
// Wait for the controller to signal that the message has been received
62+
await waitForDone();
6463
}
6564
}
6665
}

Examples/03-FlowRequestResponse/ReceivingMessageController.cs

+7-16
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,16 @@ namespace _03_FlowRequestResponse
99
public class ReceivingMessageController
1010
{
1111
// No publisher required, responses can simply be returned
12-
public async Task<QuoteResponseMessage> HandleQuoteRequest(QuoteRequestMessage message)
12+
public static async Task<QuoteResponseMessage> HandleQuoteRequest(QuoteRequestMessage message)
1313
{
14-
string quote;
15-
16-
switch (message.Amount)
14+
var quote = message.Amount switch
1715
{
18-
case 1:
16+
1 =>
1917
// Well, they asked for it... :-)
20-
quote = "'";
21-
break;
22-
23-
case 2:
24-
quote = "\"";
25-
break;
26-
27-
default:
28-
quote = new string('\'', message.Amount);
29-
break;
30-
}
18+
"'",
19+
2 => "\"",
20+
_ => new string('\'', message.Amount)
21+
};
3122

3223
// Just gonna let them wait for a bit, to demonstrate async message handlers
3324
await Task.Delay(1000);

Examples/04-Transient/04-Transient.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>_04_Transient</RootNamespace>
7+
<Nullable>enable</Nullable>
78
</PropertyGroup>
89

910
<ItemGroup>
10-
<PackageReference Include="SimpleInjector" Version="5.3.0" />
11+
<PackageReference Include="SimpleInjector" Version="5.4.1" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

Examples/04-Transient/Program.cs

+9-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace _04_Transient
1313
{
1414
public class Program
1515
{
16-
public static void Main(string[] args)
16+
public static void Main()
1717
{
1818
var container = new Container();
1919
var dependencyResolver = new SimpleInjectorDependencyResolver(container);
@@ -34,22 +34,20 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
3434
.Build();
3535

3636

37-
using (var connection = new TapetiConnection(config))
38-
{
39-
await connection.Subscribe();
37+
await using var connection = new TapetiConnection(config);
38+
await connection.Subscribe();
4039

4140

42-
Console.WriteLine("Sending request...");
41+
Console.WriteLine("Sending request...");
4342

44-
var transientPublisher = dependencyResolver.Resolve<ITransientPublisher>();
45-
var response = await transientPublisher.RequestResponse<LoggedInUsersRequestMessage, LoggedInUsersResponseMessage>(
46-
new LoggedInUsersRequestMessage());
43+
var transientPublisher = dependencyResolver.Resolve<ITransientPublisher>();
44+
var response = await transientPublisher.RequestResponse<LoggedInUsersRequestMessage, LoggedInUsersResponseMessage>(
45+
new LoggedInUsersRequestMessage());
4746

48-
Console.WriteLine("Response: " + response.Count);
47+
Console.WriteLine("Response: " + response.Count);
4948

5049

51-
// Unlike the other example, there is no need to call waitForDone, once we're here the response has been handled.
52-
}
50+
// Unlike the other example, there is no need to call waitForDone, once we're here the response has been handled.
5351
}
5452
}
5553
}

Examples/05-SpeedTest/05-SpeedTest.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>_05_SpeedTest</RootNamespace>
7+
<Nullable>enable</Nullable>
78
</PropertyGroup>
89

910
<ItemGroup>
10-
<PackageReference Include="SimpleInjector" Version="5.3.0" />
11+
<PackageReference Include="SimpleInjector" Version="5.4.1" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

0 commit comments

Comments
 (0)