1
- using MassTransit ;
1
+ using dotenv . net ;
2
+ using MassTransit ;
2
3
3
4
public static class BusRegistrationConfiguratorExt
4
5
{
@@ -10,10 +11,11 @@ public static void SetupTransport(this IBusRegistrationConfigurator x, string[]
10
11
{
11
12
x . UsingAmazonSqs ( ( ctx , cfg ) =>
12
13
{
13
- cfg . Host ( Environment . GetEnvironmentVariable ( "AWS_REGION" ) , h =>
14
+ var envs = DotEnv . Read ( new DotEnvOptions ( envFilePaths : [ Path . GetFullPath ( "../../../sqs.env" ) ] ) ) ;
15
+ cfg . Host ( envs [ "AWS_REGION" ] , h =>
14
16
{
15
- h . AccessKey ( Environment . GetEnvironmentVariable ( "AWS_ACCESS_KEY_ID" ) ) ;
16
- h . SecretKey ( Environment . GetEnvironmentVariable ( "AWS_SECRET_ACCESS_KEY" ) ) ;
17
+ h . AccessKey ( envs [ "AWS_ACCESS_KEY_ID" ] ) ;
18
+ h . SecretKey ( envs [ "AWS_SECRET_ACCESS_KEY" ] ) ;
17
19
} ) ;
18
20
19
21
cfg . ConfigureEndpoints ( ctx ) ;
@@ -22,10 +24,10 @@ public static void SetupTransport(this IBusRegistrationConfigurator x, string[]
22
24
}
23
25
else if ( args . Contains ( "--azureservicebus" ) )
24
26
{
25
-
27
+ var envs = DotEnv . Read ( new DotEnvOptions ( envFilePaths : [ Path . GetFullPath ( "../../../asb.env" ) ] , ignoreExceptions : false ) ) ;
26
28
x . UsingAzureServiceBus ( ( context , cfg ) =>
27
29
{
28
- cfg . Host ( Environment . GetEnvironmentVariable ( "CONNECTIONSTRING_AZURESERVICEBUS" ) ) ;
30
+ cfg . Host ( envs [ "CONNECTIONSTRING" ] ) ;
29
31
30
32
cfg . ConfigureEndpoints ( context ) ;
31
33
} ) ;
@@ -64,8 +66,9 @@ public static void SetupTransport(this IBusRegistrationConfigurator x, string[]
64
66
65
67
if ( cfg is IServiceBusReceiveEndpointConfigurator sb )
66
68
{
67
- sb . ConfigureDeadLetterQueueDeadLetterTransport ( ) ;
68
- sb . ConfigureDeadLetterQueueErrorTransport ( ) ;
69
+ // Uncomment this code to use deadletter
70
+ //sb.ConfigureDeadLetterQueueDeadLetterTransport();
71
+ //sb.ConfigureDeadLetterQueueErrorTransport();
69
72
}
70
73
} ) ;
71
74
}
0 commit comments