public async ValueTask <MigrationCheckResult> AbleToMigrate(EndpointInfo endpoint) { var migrationsResult = new MigrationCheckResult(); try { var table = client.GetTableReference(delayedDeliveryTableNameProvider.GetDelayedDeliveryTableName(endpoint.EndpointName)); var exists = await table.ExistsAsync(); if (!exists) { migrationsResult.Problems.Add($"Target delayed delivery table {delayedDeliveryTableNameProvider.GetDelayedDeliveryTableName(endpoint.EndpointName)} does not exist."); } } catch (StorageException ex) { migrationsResult.Problems.Add($"Unable to connect to the storage instance on account '{client.Credentials.AccountName}'. Verify the connection string. Exception message '{ex.Message}'"); } try { await EnsureStagingTableExists($"{delayedDeliveryTableNameProvider.GetStagingTableName(endpoint.EndpointName)}"); } catch (StorageException ex) { migrationsResult.Problems.Add($"Unable to create staging queue '{delayedDeliveryTableNameProvider.GetDelayedDeliveryTableName(endpoint.EndpointName)}staging'. Exception message '{ex.Message}'"); } return(migrationsResult); }
public ValueTask <MigrationCheckResult> AbleToMigrate(EndpointInfo endpoint) { EndpointWasVerified = true; var problems = problemsToReturn ?? new List <string>(); var result = new MigrationCheckResult { Problems = problems }; return(new ValueTask <MigrationCheckResult>(result)); }
ValueTask <MigrationCheckResult> VerifyEndpointIsReadyForNativeTimeouts(EndpointInfo endpoint) { var result = new MigrationCheckResult(); if ((endpoint.LongestTimeout - DateTime.UtcNow).TotalSeconds > MaxDelayInSeconds) { result.Problems.Add($"{endpoint.EndpointName} - has a timeout that has further away date than allowed {MaxDelayInSeconds} seconds (8.5 years)."); } using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { foreach (var destination in endpoint.Destinations) { try { channel.QueueDeclarePassive(destination); } catch (Exception) { result.Problems.Add($"There is no queue for destination {destination}."); continue; } try { channel.ExchangeDeclarePassive("nsb.delay-delivery"); } catch (Exception) { result.Problems.Add("The delivery infrastructure on rabbit broker does not exist. It means that the endpoint is running old version of Rabbit Transport package."); return(new ValueTask <MigrationCheckResult>(result)); } if (CheckIfEndpointIsUsingConventionalRoutingTopology(destination)) { channel.ExchangeBind(destination, "nsb.delay-delivery", $"#.{destination}"); } else { channel.QueueBind(destination, "nsb.delay-delivery", $"#.{destination}"); } } } return(new ValueTask <MigrationCheckResult>(result)); }
public async ValueTask <MigrationCheckResult> AbleToMigrate(EndpointInfo endpoint) { var migrationCheckResult = new MigrationCheckResult(); try { await EnsureConnectionOpen(); } catch (Exception e) { migrationCheckResult.Problems.Add($"Unable to connect to the server or database using the provided connection string. Verify the connection string. The following exception occured: {e.Message}"); return(migrationCheckResult); } var databaseName = connection.Database; try { await MsmqQueueCreator.CreateStagingQueue(connection, MsmqSqlConstants.TimeoutMigrationStagingTable, schema, databaseName, preview : true); } catch (Exception e) { migrationCheckResult.Problems.Add($"Attempt to verify whether the timeout migration staging table '{MsmqSqlConstants.TimeoutMigrationStagingTable}' could be created during migration mode failed. The following exception occured: {e.Message}"); } var endpointDelayedTableName = MsmqSqlConstants.DelayedTableName(endpoint.EndpointName); if (!await MsmqQueueCreator .DoesDelayedDeliveryTableExist(connection, endpointDelayedTableName, schema, databaseName) .ConfigureAwait(false)) { migrationCheckResult.Problems.Add($"Could not find delayed queue table with name '{endpointDelayedTableName}' for the endpoint '{endpoint.EndpointName}'"); } return(migrationCheckResult); }