11namespace ServiceControlInstaller . Engine . Configuration . ServiceControl
22{
3+ using System ;
4+ using System . Data . Common ;
35 using System . IO ;
46 using Instances ;
57
@@ -12,7 +14,7 @@ public ServiceControlAppConfig(IServiceControlInstance instance) : base(Path.Com
1214
1315 protected override void UpdateSettings ( )
1416 {
15- Config . ConnectionStrings . ConnectionStrings . Set ( "NServiceBus/Transport" , details . ConnectionString ) ;
17+ Config . ConnectionStrings . ConnectionStrings . Set ( "NServiceBus/Transport" , UpdateConnectionString ( ) ) ;
1618 var settings = Config . AppSettings . Settings ;
1719 var version = details . Version ;
1820 settings . Set ( ServiceControlSettings . InstanceName , details . InstanceName , version ) ;
@@ -43,6 +45,9 @@ protected override void UpdateSettings()
4345 settings . RemoveIfRetired ( ServiceControlSettings . AuditLogQueue , version ) ;
4446 settings . RemoveIfRetired ( ServiceControlSettings . ForwardAuditMessages , version ) ;
4547 settings . RemoveIfRetired ( ServiceControlSettings . InternalQueueName , version ) ;
48+ settings . RemoveIfRetired ( ServiceControlSettings . LicensingComponentRabbitMqManagementApiUrl , version ) ;
49+ settings . RemoveIfRetired ( ServiceControlSettings . LicensingComponentRabbitMqManagementApiUsername , version ) ;
50+ settings . RemoveIfRetired ( ServiceControlSettings . LicensingComponentRabbitMqManagementApiPassword , version ) ;
4651
4752 RemoveRavenDB35Settings ( settings , version ) ;
4853 }
@@ -68,6 +73,43 @@ public override void SetTransportType(string transportTypeName)
6873 settings . Set ( ServiceControlSettings . TransportType , transportTypeName , version ) ;
6974 }
7075
71- IServiceControlInstance details ;
76+ string UpdateConnectionString ( )
77+ {
78+ var connectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = details . ConnectionString } ;
79+
80+ MigrateLicensingComponentRabbitMqManagementApiSettings ( connectionStringBuilder ) ;
81+
82+ return connectionStringBuilder . ConnectionString ;
83+ }
84+
85+ void MigrateLicensingComponentRabbitMqManagementApiSettings ( DbConnectionStringBuilder connectionStringBuilder )
86+ {
87+ if ( ! details . TransportPackage . Name . Contains ( "rabbitmq" , StringComparison . OrdinalIgnoreCase ) )
88+ {
89+ return ;
90+ }
91+
92+ var settings = Config . AppSettings . Settings ;
93+
94+ var legacySetting = settings [ ServiceControlSettings . LicensingComponentRabbitMqManagementApiUrl . Name ] ;
95+ if ( legacySetting is not null && ! connectionStringBuilder . ContainsKey ( "ManagementApiUrl" ) )
96+ {
97+ connectionStringBuilder . Add ( "ManagementApiUrl" , legacySetting . Value ) ;
98+ }
99+
100+ legacySetting = settings [ ServiceControlSettings . LicensingComponentRabbitMqManagementApiUsername . Name ] ;
101+ if ( legacySetting is not null && ! connectionStringBuilder . ContainsKey ( "ManagementApiUserName" ) )
102+ {
103+ connectionStringBuilder . Add ( "ManagementApiUserName" , legacySetting . Value ) ;
104+ }
105+
106+ legacySetting = settings [ ServiceControlSettings . LicensingComponentRabbitMqManagementApiPassword . Name ] ;
107+ if ( legacySetting is not null && ! connectionStringBuilder . ContainsKey ( "ManagementApiPassword" ) )
108+ {
109+ connectionStringBuilder . Add ( "ManagementApiPassword" , legacySetting . Value ) ;
110+ }
111+ }
112+
113+ readonly IServiceControlInstance details ;
72114 }
73115}
0 commit comments