コード例 #1
0
    static async Task AsyncMain()
    {
        var defaultFactory = LogManager.Use <DefaultFactory>();

        defaultFactory.Level(LogLevel.Warn);

        Console.Title = "Samples.RenameSaga.Version2";

        Console.WriteLine("Renaming SQL tables:");
        Console.WriteLine("    from Samples_RenameSaga_MyReplySagaVersion1 to Samples_RenameSaga_MyReplySagaVersion2");
        Console.WriteLine("    from Samples_RenameSaga_MyTimeoutSagaVersion1 to Samples_RenameSaga_MyTimeoutSagaVersion2");

        #region renameTables

        var connectionString = @"Data Source=.\SqlExpress;Initial Catalog=Samples.SqlPersistence.RenameSaga;Integrated Security=True";
        using (var connection = new SqlConnection(connectionString))
        {
            await connection.OpenAsync()
            .ConfigureAwait(false);

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "exec sp_rename 'Samples_RenameSaga_MyReplySagaVersion1', 'Samples_RenameSaga_MyReplySagaVersion2'";
                await command.ExecuteNonQueryAsync()
                .ConfigureAwait(false);
            }
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "exec sp_rename 'Samples_RenameSaga_MyTimeoutSagaVersion1', 'Samples_RenameSaga_MyTimeoutSagaVersion2'";
                await command.ExecuteNonQueryAsync()
                .ConfigureAwait(false);
            }
        }

        #endregion

        var endpointConfiguration = new EndpointConfiguration("Samples.RenameSaga");
        await SharedConfiguration.Apply(endpointConfiguration)
        .ConfigureAwait(false);

        #region registerMutator

        endpointConfiguration.RegisterComponents(
            registration: components =>
        {
            components.ConfigureComponent <ReplyMutator>(DependencyLifecycle.InstancePerCall);
        });

        #endregion

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        Console.WriteLine("Waiting to receive timeout and reply. Should happen withing 10 seconds");
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
コード例 #2
0
    static async Task Main()
    {
        //required to prevent possible occurrence of .NET Core issue https://github.com/dotnet/coreclr/issues/12668
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
        Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");

        var defaultFactory = LogManager.Use <DefaultFactory>();

        defaultFactory.Level(LogLevel.Warn);

        Console.Title = "Samples.RenameSaga.Version2";

        Console.WriteLine("Renaming SQL tables:");
        Console.WriteLine("    from Samples_RenameSaga_MyReplySagaVersion1 to Samples_RenameSaga_MyReplySagaVersion2");
        Console.WriteLine("    from Samples_RenameSaga_MyTimeoutSagaVersion1 to Samples_RenameSaga_MyTimeoutSagaVersion2");

        #region renameTables

        var connectionString = @"Data Source=.\SqlExpress;Initial Catalog=NsbSamplesSqlPersistenceRenameSaga;Integrated Security=True";
        using (var connection = new SqlConnection(connectionString))
        {
            await connection.OpenAsync()
            .ConfigureAwait(false);

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "exec sp_rename 'Samples_RenameSaga_MyReplySagaVersion1', 'Samples_RenameSaga_MyReplySagaVersion2'";
                await command.ExecuteNonQueryAsync()
                .ConfigureAwait(false);
            }
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "exec sp_rename 'Samples_RenameSaga_MyTimeoutSagaVersion1', 'Samples_RenameSaga_MyTimeoutSagaVersion2'";
                await command.ExecuteNonQueryAsync()
                .ConfigureAwait(false);
            }
        }

        #endregion

        var endpointConfiguration = new EndpointConfiguration("Samples.RenameSaga");
        SharedConfiguration.Apply(endpointConfiguration);

        #region registerMutator

        endpointConfiguration.RegisterMessageMutator(new ReplyMutator());

        #endregion

        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        Console.WriteLine("Waiting to receive timeout and reply. Should happen within 10 seconds");
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
コード例 #3
0
    static async Task Main()
    {
        //required to prevent possible occurrence of .NET Core issue https://github.com/dotnet/coreclr/issues/12668
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
        Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");

        var defaultFactory = LogManager.Use <DefaultFactory>();

        defaultFactory.Level(LogLevel.Warn);

        Console.Title = "Samples.RenameSaga.Version1";

        var endpointConfiguration = new EndpointConfiguration("Samples.RenameSaga");

        SharedConfiguration.Apply(endpointConfiguration);

        endpointConfiguration.PurgeOnStartup(true);
        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        Console.WriteLine("Version1 of Sagas starting. Will exit in 5 seconds. After exist start Phase 2 Endpoint.");

        #region startSagas
        var startReplySaga = new StartReplySaga
        {
            TheId = Guid.NewGuid()
        };
        await endpointInstance.SendLocal(startReplySaga)
        .ConfigureAwait(false);

        var startTimeoutSaga = new StartTimeoutSaga
        {
            TheId = Guid.NewGuid()
        };
        await endpointInstance.SendLocal(startTimeoutSaga)
        .ConfigureAwait(false);

        #endregion

        await Task.Delay(TimeSpan.FromSeconds(5))
        .ConfigureAwait(false);

        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }
コード例 #4
0
    static async Task AsyncMain()
    {
        var defaultFactory = LogManager.Use <DefaultFactory>();

        defaultFactory.Level(LogLevel.Warn);

        Console.Title = "Samples.RenameSaga.Version1";

        var endpointConfiguration = new EndpointConfiguration("Samples.RenameSaga");

        await SharedConfiguration.Apply(endpointConfiguration)
        .ConfigureAwait(false);

        endpointConfiguration.PurgeOnStartup(true);
        var endpointInstance = await Endpoint.Start(endpointConfiguration)
                               .ConfigureAwait(false);

        Console.WriteLine("Version1 of Sagas starting. Will exit in 5 seconds. After exist start Phase 2 Endpoint.");

        #region startSagas
        var startReplySaga = new StartReplySaga
        {
            TheId = Guid.NewGuid()
        };
        await endpointInstance.SendLocal(startReplySaga)
        .ConfigureAwait(false);

        var startTimeoutSaga = new StartTimeoutSaga
        {
            TheId = Guid.NewGuid()
        };
        await endpointInstance.SendLocal(startTimeoutSaga)
        .ConfigureAwait(false);

        #endregion

        await Task.Delay(TimeSpan.FromSeconds(5))
        .ConfigureAwait(false);

        await endpointInstance.Stop()
        .ConfigureAwait(false);
    }