public async Task Can_migrate_timeouts() { var sourceEndpoint = NServiceBus.AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(AspSource)); var targetEndpoint = NServiceBus.AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(SqlTTarget)); await Scenario.Define <SourceContext>() .WithEndpoint <AspSource>(b => b.CustomConfig(ec => { SetupPersistence(ec); }) .When(async(session, c) => { var delayedMessage = new DelayedMessage(); var options = new SendOptions(); options.DelayDeliveryWith(TimeSpan.FromSeconds(15)); options.SetDestination(targetEndpoint); await session.Send(delayedMessage, options); await WaitUntilTheTimeoutsAreSavedInAsp(sourceEndpoint, 2); c.TimeoutSet = true; })) .Done(c => c.TimeoutSet) .Run(TimeSpan.FromSeconds(30)); var setupContext = await Scenario.Define <TargetContext>() .WithEndpoint <SqlTTarget>(b => b.CustomConfig(ec => { ec.OverrideLocalAddress(sourceEndpoint); ec.UseTransport <SqlServerTransport>() .ConnectionString(sqlConnectionString); })) .Done(c => c.EndpointsStarted) .Run(TimeSpan.FromSeconds(30)); var logger = new TestLoggingAdapter(setupContext); var timeoutStorage = CreateTimeoutStorage(sourceEndpoint); var timeoutTarget = new SqlTTimeoutsTarget(logger, sqlConnectionString, "dbo"); var migrationRunner = new MigrationRunner(logger, timeoutStorage, timeoutTarget); await migrationRunner.Run(DateTime.Now.AddDays(-10), EndpointFilter.SpecificEndpoint(sourceEndpoint), new Dictionary <string, string>()); var context = await Scenario.Define <TargetContext>() .WithEndpoint <SqlTTarget>(b => b.CustomConfig(ec => { ec.OverrideLocalAddress(sourceEndpoint); ec.UseTransport <SqlServerTransport>() .ConnectionString(sqlConnectionString); })) .Done(c => c.GotTheDelayedMessage) .Run(TimeSpan.FromSeconds(30)); Assert.True(context.GotTheDelayedMessage); }
public async Task Can_migrate_timeouts() { var sourceEndpoint = NServiceBus.AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(AspSource)); var targetEndpoint = NServiceBus.AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(AsqTarget)); await Scenario.Define <SourceContext>() .WithEndpoint <AspSource>(b => b.CustomConfig(ec => { SetupPersistence(ec); ec.UseSerialization <NewtonsoftSerializer>(); }) .When(async(session, c) => { var delayedMessage = new DelayedMessage(); var options = new SendOptions(); options.DelayDeliveryWith(TimeSpan.FromSeconds(15)); options.SetDestination(targetEndpoint); await session.Send(delayedMessage, options); await WaitUntilTheTimeoutsAreSavedInAsp(sourceEndpoint, 2); c.TimeoutSet = true; })) .Done(c => c.TimeoutSet) .Run(TimeSpan.FromSeconds(30)); var context = await Scenario.Define <TargetContext>() // Create the legacy endpoint to forward the delayed message to the reporting endpoint // This is needed as ASQ stores the delayed messages at the sending endpoint until // delivery is needed .WithEndpoint <AspSource>(b => b.CustomConfig(ec => { var transportConfig = ec.UseTransport <AzureStorageQueueTransport>(); transportConfig.ConnectionString(asqConnectionString); transportConfig.DisablePublishing(); transportConfig.DelayedDelivery().DisableTimeoutManager(); ec.UseSerialization <NewtonsoftSerializer>(); })) // Start the reporting endpoint to receive and process the delayed message .WithEndpoint <AsqTarget>(b => b.CustomConfig(ec => { var transportConfig = ec.UseTransport <AzureStorageQueueTransport>(); transportConfig.ConnectionString(asqConnectionString); transportConfig.DisablePublishing(); transportConfig.DelayedDelivery().DisableTimeoutManager(); ec.UseSerialization <NewtonsoftSerializer>(); }) .When(async(_, c) => { var logger = new TestLoggingAdapter(c); var timeoutStorage = CreateTimeoutStorage(sourceEndpoint); var timeoutsTarget = new ASQTarget(asqConnectionString, new DelayedDeliveryTableNameProvider()); var migrationRunner = new MigrationRunner(logger, timeoutStorage, timeoutsTarget); await migrationRunner.Run(DateTime.Now.AddDays(-10), EndpointFilter.SpecificEndpoint(sourceEndpoint), new Dictionary <string, string>()); })) .Done(c => c.GotTheDelayedMessage) .Run(TimeSpan.FromSeconds(30)); Assert.True(context.GotTheDelayedMessage); }