diff --git a/samples/Sample.Kafka.PostgreSql/Startup.cs b/samples/Sample.Kafka.PostgreSql/Startup.cs index 640abd626..a80094601 100644 --- a/samples/Sample.Kafka.PostgreSql/Startup.cs +++ b/samples/Sample.Kafka.PostgreSql/Startup.cs @@ -10,7 +10,7 @@ public void ConfigureServices(IServiceCollection services) services.AddCap(x => { //docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres - x.UsePostgreSql("User ID=postgres;Password=mysecretpassword;Host=localhost;Port=5432;Database=cap;"); + x.UsePostgreSql("User ID=postgres;Password=mysecretpassword;Host=localhost;Port=5432;Database=postgres;"); //docker run --name kafka -p 9092:9092 -d bashj79/kafka-kraft x.UseKafka("localhost:9092"); @@ -28,5 +28,5 @@ public void Configure(IApplicationBuilder app) endpoints.MapControllers(); }); } - } + } } \ No newline at end of file diff --git a/samples/Sample.RabbitMQ.SqlServer/AppDbContext.cs b/samples/Sample.RabbitMQ.SqlServer/AppDbContext.cs index 5e57854b4..0f5fe9c1f 100644 --- a/samples/Sample.RabbitMQ.SqlServer/AppDbContext.cs +++ b/samples/Sample.RabbitMQ.SqlServer/AppDbContext.cs @@ -16,7 +16,7 @@ public override string ToString() public class AppDbContext : DbContext { - public const string ConnectionString = "Server=127.0.0.1;Database=AppDB;User Id=sa;Password=pass"; + public const string ConnectionString = "Server=127.0.0.1;Database=tempdb;User Id=sa;Password=yourStrong(!)Password;TrustServerCertificate=True"; public DbSet Persons { get; set; } diff --git a/samples/Sample.RabbitMQ.SqlServer/Controllers/ValuesController.cs b/samples/Sample.RabbitMQ.SqlServer/Controllers/ValuesController.cs index ab9322d69..4ee1a3856 100644 --- a/samples/Sample.RabbitMQ.SqlServer/Controllers/ValuesController.cs +++ b/samples/Sample.RabbitMQ.SqlServer/Controllers/ValuesController.cs @@ -80,16 +80,16 @@ await _capBus.PublishDelayAsync(TimeSpan.FromSeconds(delaySeconds), "sample.rabb } [Route("~/adonet/transaction")] - public IActionResult AdonetWithTransaction() + public async Task AdonetWithTransaction() { using (var connection = new SqlConnection(AppDbContext.ConnectionString)) { - using (var transaction = connection.BeginTransaction(_capBus, true)) + using (var transaction = await connection.BeginTransactionAsync(_capBus, true)) { //your business code - connection.Execute("insert into test(name) values('test')", transaction: transaction); + await connection.ExecuteAsync("insert into test(name) values('test')", transaction: transaction); - _capBus.Publish("sample.rabbitmq.sqlserver", new Person() + await _capBus.PublishAsync("sample.rabbitmq.sqlserver", new Person() { Id = 123, Name = "Bar" diff --git a/samples/Sample.RabbitMQ.SqlServer/Startup.cs b/samples/Sample.RabbitMQ.SqlServer/Startup.cs index 1b4a1d6ff..42ef3e02a 100644 --- a/samples/Sample.RabbitMQ.SqlServer/Startup.cs +++ b/samples/Sample.RabbitMQ.SqlServer/Startup.cs @@ -1,5 +1,4 @@ -using DotNetCore.CAP; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; namespace Sample.RabbitMQ.SqlServer @@ -8,6 +7,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + //docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -e "MSSQL_PID=Evaluation" -p 1433:1433 --name sqlpreview --hostname sqlpreview -d mcr.microsoft.com/mssql/server:2022-preview-ubuntu-22.04 services.AddDbContext(); //services @@ -17,17 +17,11 @@ public void ConfigureServices(IServiceCollection services) services.AddCap(x => { x.UseEntityFramework(); - x.UseRabbitMQ(opt => - { - opt.HostName = "localhost"; - opt.BasicQosOptions = new RabbitMQOptions.BasicQos(1); - }); + x.UseRabbitMQ("localhost"); x.UseDashboard(); - //x.ConsumerThreadCount = 4; - x.EnableConsumerPrefetch = true; + + x.EnablePublishParallelSend = true; - //x.FailedRetryCount = 5; - //x.UseDispatchingPerGroup = true; //x.FailedThresholdCallback = failed => //{ // var logger = failed.ServiceProvider.GetRequiredService>(); diff --git a/samples/Sample.RabbitMQ.SqlServer/appsettings.json b/samples/Sample.RabbitMQ.SqlServer/appsettings.json index e6164420d..5ec73ff5b 100644 --- a/samples/Sample.RabbitMQ.SqlServer/appsettings.json +++ b/samples/Sample.RabbitMQ.SqlServer/appsettings.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Error" + "Default": "Information" } } } diff --git a/src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlOptions.cs b/src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlOptions.cs index 10b735f80..20e8b054c 100644 --- a/src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlOptions.cs +++ b/src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlOptions.cs @@ -29,7 +29,9 @@ public class PostgreSqlOptions : EFOptions /// internal NpgsqlConnection CreateConnection() { +#pragma warning disable CS0618 // Type or member is obsolete return DataSource != null ? DataSource.CreateConnection() : new NpgsqlConnection(ConnectionString); +#pragma warning restore CS0618 // Type or member is obsolete } }