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 ) ;
@@ -37,6 +39,9 @@ protected override void UpdateSettings()
3739 settings . RemoveIfRetired ( ServiceControlSettings . AuditLogQueue , version ) ;
3840 settings . RemoveIfRetired ( ServiceControlSettings . ForwardAuditMessages , version ) ;
3941 settings . RemoveIfRetired ( ServiceControlSettings . InternalQueueName , version ) ;
42+ settings . RemoveIfRetired ( ServiceControlSettings . LicensingComponentRabbitMqManagementApiUrl , version ) ;
43+ settings . RemoveIfRetired ( ServiceControlSettings . LicensingComponentRabbitMqManagementApiUsername , version ) ;
44+ settings . RemoveIfRetired ( ServiceControlSettings . LicensingComponentRabbitMqManagementApiPassword , version ) ;
4045
4146 RemoveRavenDB35Settings ( settings , version ) ;
4247 }
@@ -62,6 +67,43 @@ public override void SetTransportType(string transportTypeName)
6267 settings . Set ( ServiceControlSettings . TransportType , transportTypeName , version ) ;
6368 }
6469
65- IServiceControlInstance details ;
70+ string UpdateConnectionString ( )
71+ {
72+ var connectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = details . ConnectionString } ;
73+
74+ MigrateLicensingComponentRabbitMqManagementApiSettings ( connectionStringBuilder ) ;
75+
76+ return connectionStringBuilder . ConnectionString ;
77+ }
78+
79+ void MigrateLicensingComponentRabbitMqManagementApiSettings ( DbConnectionStringBuilder connectionStringBuilder )
80+ {
81+ if ( ! details . TransportPackage . Name . Contains ( "rabbitmq" , StringComparison . OrdinalIgnoreCase ) )
82+ {
83+ return ;
84+ }
85+
86+ var settings = Config . AppSettings . Settings ;
87+
88+ var legacySetting = settings [ ServiceControlSettings . LicensingComponentRabbitMqManagementApiUrl . Name ] ;
89+ if ( legacySetting is not null && ! connectionStringBuilder . ContainsKey ( "ManagementApiUrl" ) )
90+ {
91+ connectionStringBuilder . Add ( "ManagementApiUrl" , legacySetting . Value ) ;
92+ }
93+
94+ legacySetting = settings [ ServiceControlSettings . LicensingComponentRabbitMqManagementApiUsername . Name ] ;
95+ if ( legacySetting is not null && ! connectionStringBuilder . ContainsKey ( "ManagementApiUserName" ) )
96+ {
97+ connectionStringBuilder . Add ( "ManagementApiUserName" , legacySetting . Value ) ;
98+ }
99+
100+ legacySetting = settings [ ServiceControlSettings . LicensingComponentRabbitMqManagementApiPassword . Name ] ;
101+ if ( legacySetting is not null && ! connectionStringBuilder . ContainsKey ( "ManagementApiPassword" ) )
102+ {
103+ connectionStringBuilder . Add ( "ManagementApiPassword" , legacySetting . Value ) ;
104+ }
105+ }
106+
107+ readonly IServiceControlInstance details ;
66108 }
67109}
0 commit comments