@@ -1,13 +1,13 @@ | |||||
using Microsoft.EntityFrameworkCore; | using Microsoft.EntityFrameworkCore; | ||||
namespace Sample.Kafka | |||||
namespace Sample.RabbitMQ.SqlServer | |||||
{ | { | ||||
public class AppDbContext : DbContext | public class AppDbContext : DbContext | ||||
{ | { | ||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||||
{ | { | ||||
//optionsBuilder.UseSqlServer("Server=192.168.2.206;Initial Catalog=Test;User Id=cmswuliu;Password=h7xY81agBn*Veiu3;MultipleActiveResultSets=True"); | //optionsBuilder.UseSqlServer("Server=192.168.2.206;Initial Catalog=Test;User Id=cmswuliu;Password=h7xY81agBn*Veiu3;MultipleActiveResultSets=True"); | ||||
optionsBuilder.UseSqlServer("Server=DESKTOP-M9R8T31;Initial Catalog=Sample.Kafka.SqlServer;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True"); | |||||
//optionsBuilder.UseSqlServer("Server=DESKTOP-M9R8T31;Initial Catalog=Sample.Kafka.SqlServer;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True"); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
using DotNetCore.CAP; | using DotNetCore.CAP; | ||||
using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||
namespace Sample.Kafka.Controllers | |||||
namespace Sample.RabbitMQ.SqlServer.Controllers | |||||
{ | { | ||||
[Route("api/[controller]")] | [Route("api/[controller]")] | ||||
public class ValuesController : Controller, ICapSubscribe | public class ValuesController : Controller, ICapSubscribe | ||||
@@ -22,6 +22,7 @@ namespace Sample.Kafka.Controllers | |||||
public IActionResult PublishMessage() | public IActionResult PublishMessage() | ||||
{ | { | ||||
_capBus.Publish("sample.rabbitmq.mysql", ""); | _capBus.Publish("sample.rabbitmq.mysql", ""); | ||||
return Ok(); | return Ok(); | ||||
} | } | ||||
@@ -31,13 +32,15 @@ namespace Sample.Kafka.Controllers | |||||
using (var trans = await _dbContext.Database.BeginTransactionAsync()) | using (var trans = await _dbContext.Database.BeginTransactionAsync()) | ||||
{ | { | ||||
await _capBus.PublishAsync("sample.rabbitmq.mysql", ""); | await _capBus.PublishAsync("sample.rabbitmq.mysql", ""); | ||||
trans.Commit(); | trans.Commit(); | ||||
} | } | ||||
return Ok(); | return Ok(); | ||||
} | } | ||||
[NonAction] | [NonAction] | ||||
[CapSubscribe("sample.kafka.sqlserver", Group = "test")] | |||||
[CapSubscribe("sample.kafka.sqlserver3")] | |||||
[CapSubscribe("sample.kafka.sqlserver4")] | |||||
public void KafkaTest() | public void KafkaTest() | ||||
{ | { | ||||
Console.WriteLine("[sample.kafka.sqlserver] message received"); | Console.WriteLine("[sample.kafka.sqlserver] message received"); |
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Builder; | |||||
using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||
using Microsoft.Extensions.Configuration; | using Microsoft.Extensions.Configuration; | ||||
namespace Sample.Kafka | |||||
namespace Sample.RabbitMQ.SqlServer | |||||
{ | { | ||||
public class Program | public class Program | ||||
{ | { |
@@ -1,26 +1,24 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk.Web"> | <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>netcoreapp1.1</TargetFramework> | |||||
<AssemblyName>Sample.Kafka.SqlServer</AssemblyName> | |||||
<TargetFramework>netcoreapp2.0</TargetFramework> | |||||
<AssemblyName>Sample.RabbitMQ.SqlServer</AssemblyName> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" /> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" /> | |||||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> | |||||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\..\src\DotNetCore.CAP.Kafka\DotNetCore.CAP.Kafka.csproj" /> | |||||
<ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" /> | |||||
<ProjectReference Include="..\..\src\DotNetCore.CAP.SqlServer\DotNetCore.CAP.SqlServer.csproj" /> | <ProjectReference Include="..\..\src\DotNetCore.CAP.SqlServer\DotNetCore.CAP.SqlServer.csproj" /> | ||||
<ProjectReference Include="..\..\src\DotNetCore.CAP\DotNetCore.CAP.csproj" /> | <ProjectReference Include="..\..\src\DotNetCore.CAP\DotNetCore.CAP.csproj" /> | ||||
</ItemGroup> | </ItemGroup> |
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Hosting; | |||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||
namespace Sample.Kafka | |||||
namespace Sample.RabbitMQ.SqlServer | |||||
{ | { | ||||
public class Startup | public class Startup | ||||
{ | { | ||||
@@ -14,7 +14,7 @@ namespace Sample.Kafka | |||||
services.AddCap(x => | services.AddCap(x => | ||||
{ | { | ||||
x.UseEntityFramework<AppDbContext>(); | x.UseEntityFramework<AppDbContext>(); | ||||
x.UseKafka("localhost:9092"); | |||||
x.UseRabbitMQ("localhost"); | |||||
}); | }); | ||||
services.AddMvc(); | services.AddMvc(); |