@@ -7,8 +7,23 @@ namespace Sample.RabbitMQ.MySql | |||||
public int Id { get; set; } | public int Id { get; set; } | ||||
public string Name { get; set; } | public string Name { get; set; } | ||||
public override string ToString() | |||||
{ | |||||
return $"Name:{Name}, Id:{Id}"; | |||||
} | |||||
} | } | ||||
public class Person2 | |||||
{ | |||||
public int Id { get; set; } | |||||
public string Name { get; set; } | |||||
public override string ToString() | |||||
{ | |||||
return $"Name:{Name}, Id:{Id}"; | |||||
} | |||||
} | |||||
public class AppDbContext : DbContext | public class AppDbContext : DbContext | ||||
{ | { | ||||
public const string ConnectionString = "Server=192.168.2.120;Database=captest;UserId=root;Password=123123;"; | public const string ConnectionString = "Server=192.168.2.120;Database=captest;UserId=root;Password=123123;"; | ||||
@@ -1,4 +1,5 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | |||||
using System.Data; | using System.Data; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Dapper; | using Dapper; | ||||
@@ -21,7 +22,11 @@ namespace Sample.RabbitMQ.MySql.Controllers | |||||
[Route("~/without/transaction")] | [Route("~/without/transaction")] | ||||
public async Task<IActionResult> WithoutTransaction() | public async Task<IActionResult> WithoutTransaction() | ||||
{ | { | ||||
await _capBus.PublishAsync("sample.rabbitmq.mysql", DateTime.Now); | |||||
await _capBus.PublishAsync("sample.rabbitmq.mysql", new Person() | |||||
{ | |||||
Id = 123, | |||||
Name = "Bar" | |||||
}); | |||||
return Ok(); | return Ok(); | ||||
} | } | ||||
@@ -69,9 +74,9 @@ namespace Sample.RabbitMQ.MySql.Controllers | |||||
[NonAction] | [NonAction] | ||||
[CapSubscribe("sample.rabbitmq.mysql")] | [CapSubscribe("sample.rabbitmq.mysql")] | ||||
public void Subscriber(DateTime time) | |||||
public void Subscriber(Person2 p) | |||||
{ | { | ||||
Console.WriteLine($@"{DateTime.Now}, Subscriber invoked, Sent time:{time}"); | |||||
Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,5 +1,5 @@ | |||||
using Microsoft.AspNetCore; | |||||
using Microsoft.AspNetCore.Hosting; | |||||
using Microsoft.AspNetCore.Hosting; | |||||
using Microsoft.Extensions.Hosting; | |||||
namespace Sample.RabbitMQ.MySql | namespace Sample.RabbitMQ.MySql | ||||
{ | { | ||||
@@ -7,13 +7,14 @@ namespace Sample.RabbitMQ.MySql | |||||
{ | { | ||||
public static void Main(string[] args) | public static void Main(string[] args) | ||||
{ | { | ||||
BuildWebHost(args).Run(); | |||||
CreateHostBuilder(args).Build().Run(); | |||||
} | } | ||||
public static IWebHost BuildWebHost(string[] args) => | |||||
WebHost.CreateDefaultBuilder(args) | |||||
.UseStartup<Startup>() | |||||
.UseUrls("http://*:15173") | |||||
.Build(); | |||||
public static IHostBuilder CreateHostBuilder(string[] args) => | |||||
Host.CreateDefaultBuilder(args) | |||||
.ConfigureWebHostDefaults(webBuilder => | |||||
{ | |||||
webBuilder.UseStartup<Startup>(); | |||||
}); | |||||
} | } | ||||
} | } |
@@ -1,10 +1,11 @@ | |||||
{ | |||||
{ | |||||
"$schema": "http://json.schemastore.org/launchsettings.json", | |||||
"iisSettings": { | "iisSettings": { | ||||
"windowsAuthentication": false, | "windowsAuthentication": false, | ||||
"anonymousAuthentication": true, | "anonymousAuthentication": true, | ||||
"iisExpress": { | "iisExpress": { | ||||
"applicationUrl": "http://localhost:57171/", | |||||
"sslPort": 0 | |||||
"applicationUrl": "http://localhost:49558", | |||||
"sslPort": 44332 | |||||
} | } | ||||
}, | }, | ||||
"profiles": { | "profiles": { | ||||
@@ -20,10 +21,10 @@ | |||||
"commandName": "Project", | "commandName": "Project", | ||||
"launchBrowser": true, | "launchBrowser": true, | ||||
"launchUrl": "cap", | "launchUrl": "cap", | ||||
"applicationUrl": "http://localhost:5000", | |||||
"environmentVariables": { | "environmentVariables": { | ||||
"ASPNETCORE_ENVIRONMENT": "Production" | |||||
}, | |||||
"applicationUrl": "http://localhost:57173/" | |||||
"ASPNETCORE_ENVIRONMENT": "Development" | |||||
} | |||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,13 +1,12 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk.Web"> | <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||||
<TargetFramework>netcoreapp3.0</TargetFramework> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.AspNetCore.App" /> | |||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" /> | |||||
</ItemGroup> | |||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.6" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" /> | <ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" /> | ||||
<ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" /> | <ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" /> | ||||
@@ -1,9 +1,7 @@ | |||||
using System; | using System; | ||||
using DotNetCore.CAP.Messages; | using DotNetCore.CAP.Messages; | ||||
using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||
using Microsoft.AspNetCore.Hosting; | |||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.Extensions.Logging; | |||||
namespace Sample.RabbitMQ.MySql | namespace Sample.RabbitMQ.MySql | ||||
{ | { | ||||
@@ -26,12 +24,16 @@ namespace Sample.RabbitMQ.MySql | |||||
}; | }; | ||||
}); | }); | ||||
services.AddMvc(); | |||||
services.AddControllers(); | |||||
} | } | ||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | |||||
public void Configure(IApplicationBuilder app) | |||||
{ | { | ||||
app.UseMvc(); | |||||
app.UseRouting(); | |||||
app.UseEndpoints(endpoints => | |||||
{ | |||||
endpoints.MapControllers(); | |||||
}); | |||||
} | } | ||||
} | } | ||||
} | } |