1
1
using System ;
2
- using System . Threading . Tasks ;
3
2
using Endpoint1 ;
4
3
using Microsoft . Extensions . DependencyInjection ;
5
4
using Microsoft . Extensions . Hosting ;
6
5
using NServiceBus ;
7
6
8
- class Program
9
- {
10
- public static async Task Main ( string [ ] args )
7
+ var host = Host . CreateDefaultBuilder ( args )
8
+ . ConfigureServices ( ( hostContext , services ) => { services . AddHostedService < InputLoopService > ( ) ; } )
9
+ . UseNServiceBus ( x =>
11
10
{
12
- await CreateHostBuilder ( args ) . Build ( ) . RunAsync ( ) ;
13
- }
11
+ #region endpointName
14
12
15
- public static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
16
- Host . CreateDefaultBuilder ( args )
17
- . ConfigureServices ( ( hostContext , services ) =>
18
- {
19
- services . AddHostedService < InputLoopService > ( ) ;
13
+ var endpointName = "Samples.Azure.StorageQueues.Endpoint1.With.A.Very.Long.Name.And.Invalid.Characters" ;
14
+ var endpointConfiguration = new EndpointConfiguration ( endpointName ) ;
20
15
21
- } ) . UseNServiceBus ( x =>
22
- {
23
- #region endpointName
16
+ #endregion
24
17
25
- var endpointName = "Samples.Azure.StorageQueues.Endpoint1.With.A.Very.Long.Name.And.Invalid.Characters" ;
26
- var endpointConfiguration = new EndpointConfiguration ( endpointName ) ;
18
+ Console . Title = endpointName ;
27
19
28
- #endregion
20
+ #region config
29
21
30
- Console . Title = endpointName ;
22
+ var transport = new AzureStorageQueueTransport ( "UseDevelopmentStorage=true" ) ;
23
+ var routingSettings = endpointConfiguration . UseTransport ( transport ) ;
24
+ routingSettings . RouteToEndpoint ( typeof ( Endpoint2 . MyRequest ) , "Samples-Azure-StorageQueues-Endpoint2" ) ;
31
25
32
- #region config
26
+ #endregion
33
27
34
- var transport = new AzureStorageQueueTransport ( "UseDevelopmentStorage=true" ) ;
35
- var routingSettings = endpointConfiguration . UseTransport ( transport ) ;
28
+ #region sanitization
36
29
37
- #endregion
30
+ transport . QueueNameSanitizer = BackwardsCompatibleQueueNameSanitizer . WithMd5Shortener ;
38
31
39
- #region sanitization
32
+ #endregion
40
33
41
- transport . QueueNameSanitizer = BackwardsCompatibleQueueNameSanitizer . WithMd5Shortener ;
34
+ routingSettings . DisablePublishing ( ) ;
35
+ endpointConfiguration . UsePersistence < LearningPersistence > ( ) ;
36
+ endpointConfiguration . UseSerialization < SystemJsonSerializer > ( ) ;
37
+ endpointConfiguration . EnableInstallers ( ) ;
42
38
43
- #endregion
39
+ return endpointConfiguration ;
40
+ } ) . Build ( ) ;
44
41
45
- routingSettings . DisablePublishing ( ) ;
46
- endpointConfiguration . UsePersistence < LearningPersistence > ( ) ;
47
- endpointConfiguration . UseSerialization < SystemJsonSerializer > ( ) ;
48
- endpointConfiguration . EnableInstallers ( ) ;
49
-
50
-
51
- return endpointConfiguration ;
52
- } ) ;
53
-
54
- }
42
+ await host . RunAsync ( ) ;
0 commit comments