Commit 1a35a8b0 authored by yangxiaodong's avatar yangxiaodong

update samples

parent fdf69c12
...@@ -22,8 +22,8 @@ namespace Sample.Kafka ...@@ -22,8 +22,8 @@ namespace Sample.Kafka
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<CapSentMessage>().Property(x => x.StateName).HasMaxLength(50); modelBuilder.Entity<CapSentMessage>().Property(x => x.StatusName).HasMaxLength(50);
modelBuilder.Entity<CapReceivedMessage>().Property(x => x.StateName).HasMaxLength(50); modelBuilder.Entity<CapReceivedMessage>().Property(x => x.StatusName).HasMaxLength(50);
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using DotNetCore.CAP; using DotNetCore.CAP;
using DotNetCore.CAP.Kafka; using DotNetCore.CAP.Kafka;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace Sample.Kafka.Controllers namespace Sample.Kafka.Controllers
...@@ -11,23 +12,28 @@ namespace Sample.Kafka.Controllers ...@@ -11,23 +12,28 @@ namespace Sample.Kafka.Controllers
{ {
private readonly ICapProducerService _producer; private readonly ICapProducerService _producer;
public ValuesController(ICapProducerService producer) { public ValuesController(ICapProducerService producer)
{
_producer = producer; _producer = producer;
} }
[Route("/")] [Route("/")]
public IActionResult Index() { public IActionResult Index()
{
return Ok(); return Ok();
} }
public string ServerPath => ((IHostingEnvironment)HttpContext.RequestServices.GetService(typeof(IHostingEnvironment))).ContentRootPath;
[KafkaTopic("zzwl.topic.finace.callBack", IsOneWay = true, GroupOrExchange = "test")] [KafkaTopic("zzwl.topic.finace.callBack", IsOneWay = true, GroupOrExchange = "test")]
[NonAction] [NonAction]
public void KafkaTest() { public void KafkaTest()
{
Console.WriteLine("kafka test invoked"); Console.WriteLine("kafka test invoked");
} }
[Route("~/send")] [Route("~/send")]
public async Task<IActionResult> SendTopic() { public async Task<IActionResult> SendTopic()
{
await _producer.SendAsync("zzwl.topic.finace.callBack", "{\"msgBody\":\"{\\\"dealno\\\":null,\\\"businesstype\\\":\\\"1\\\",\\\"serialno\\\":\\\"435ldfhj345\\\",\\\"bankno\\\":\\\"650001\\\",\\\"amt\\\":20.0,\\\"virtualstatus\\\":1,\\\"paystatus\\\":1}\",\"callbackTopicName\":\"zzwl.topic.finace.callBack\",\"createId\":null,\"retryLimit\":0}"); await _producer.SendAsync("zzwl.topic.finace.callBack", "{\"msgBody\":\"{\\\"dealno\\\":null,\\\"businesstype\\\":\\\"1\\\",\\\"serialno\\\":\\\"435ldfhj345\\\",\\\"bankno\\\":\\\"650001\\\",\\\"amt\\\":20.0,\\\"virtualstatus\\\":1,\\\"paystatus\\\":1}\",\"callbackTopicName\":\"zzwl.topic.finace.callBack\",\"createId\":null,\"retryLimit\":0}");
return Ok(); return Ok();
} }
......
...@@ -8,8 +8,8 @@ using Sample.Kafka; ...@@ -8,8 +8,8 @@ using Sample.Kafka;
namespace Sample.Kafka.Migrations namespace Sample.Kafka.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20170624095008_CreateDatabase")] [Migration("20170629074148_InitCreate")]
partial class CreateDatabase partial class InitCreate
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
...@@ -32,7 +32,7 @@ namespace Sample.Kafka.Migrations ...@@ -32,7 +32,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries"); b.Property<int>("Retries");
b.Property<string>("StateName") b.Property<string>("StatusName")
.HasMaxLength(50); .HasMaxLength(50);
b.HasKey("Id"); b.HasKey("Id");
...@@ -55,7 +55,7 @@ namespace Sample.Kafka.Migrations ...@@ -55,7 +55,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries"); b.Property<int>("Retries");
b.Property<string>("StateName") b.Property<string>("StatusName")
.HasMaxLength(50); .HasMaxLength(50);
b.HasKey("Id"); b.HasKey("Id");
......
...@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations; ...@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Sample.Kafka.Migrations namespace Sample.Kafka.Migrations
{ {
public partial class CreateDatabase : Migration public partial class InitCreate : Migration
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
...@@ -18,7 +18,7 @@ namespace Sample.Kafka.Migrations ...@@ -18,7 +18,7 @@ namespace Sample.Kafka.Migrations
KeyName = table.Column<string>(nullable: true), KeyName = table.Column<string>(nullable: true),
LastRun = table.Column<DateTime>(nullable: false), LastRun = table.Column<DateTime>(nullable: false),
Retries = table.Column<int>(nullable: false), Retries = table.Column<int>(nullable: false),
StateName = table.Column<string>(maxLength: 50, nullable: true) StatusName = table.Column<string>(maxLength: 50, nullable: true)
}, },
constraints: table => constraints: table =>
{ {
...@@ -35,7 +35,7 @@ namespace Sample.Kafka.Migrations ...@@ -35,7 +35,7 @@ namespace Sample.Kafka.Migrations
KeyName = table.Column<string>(nullable: true), KeyName = table.Column<string>(nullable: true),
LastRun = table.Column<DateTime>(nullable: false), LastRun = table.Column<DateTime>(nullable: false),
Retries = table.Column<int>(nullable: false), Retries = table.Column<int>(nullable: false),
StateName = table.Column<string>(maxLength: 50, nullable: true) StatusName = table.Column<string>(maxLength: 50, nullable: true)
}, },
constraints: table => constraints: table =>
{ {
......
...@@ -31,7 +31,7 @@ namespace Sample.Kafka.Migrations ...@@ -31,7 +31,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries"); b.Property<int>("Retries");
b.Property<string>("StateName") b.Property<string>("StatusName")
.HasMaxLength(50); .HasMaxLength(50);
b.HasKey("Id"); b.HasKey("Id");
...@@ -54,7 +54,7 @@ namespace Sample.Kafka.Migrations ...@@ -54,7 +54,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries"); b.Property<int>("Retries");
b.Property<string>("StateName") b.Property<string>("StatusName")
.HasMaxLength(50); .HasMaxLength(50);
b.HasKey("Id"); b.HasKey("Id");
......
...@@ -24,8 +24,8 @@ namespace Sample.Kafka ...@@ -24,8 +24,8 @@ namespace Sample.Kafka
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddDbContext<AppDbContext>(); services.AddDbContext<AppDbContext>();
services.AddConsistency() services.AddConsistency()
.AddEntityFrameworkStores<AppDbContext>() .AddEntityFrameworkStores<AppDbContext>()
.AddRabbitMQ(x => .AddRabbitMQ(x =>
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment