Commit 1a35a8b0 authored by yangxiaodong's avatar yangxiaodong

update samples

parent fdf69c12
......@@ -22,8 +22,8 @@ namespace Sample.Kafka
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<CapSentMessage>().Property(x => x.StateName).HasMaxLength(50);
modelBuilder.Entity<CapReceivedMessage>().Property(x => x.StateName).HasMaxLength(50);
modelBuilder.Entity<CapSentMessage>().Property(x => x.StatusName).HasMaxLength(50);
modelBuilder.Entity<CapReceivedMessage>().Property(x => x.StatusName).HasMaxLength(50);
base.OnModelCreating(modelBuilder);
}
......
......@@ -2,6 +2,7 @@
using System.Threading.Tasks;
using DotNetCore.CAP;
using DotNetCore.CAP.Kafka;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
namespace Sample.Kafka.Controllers
......@@ -11,23 +12,28 @@ namespace Sample.Kafka.Controllers
{
private readonly ICapProducerService _producer;
public ValuesController(ICapProducerService producer) {
public ValuesController(ICapProducerService producer)
{
_producer = producer;
}
[Route("/")]
public IActionResult Index() {
public IActionResult Index()
{
return Ok();
}
public string ServerPath => ((IHostingEnvironment)HttpContext.RequestServices.GetService(typeof(IHostingEnvironment))).ContentRootPath;
[KafkaTopic("zzwl.topic.finace.callBack", IsOneWay = true, GroupOrExchange = "test")]
[NonAction]
public void KafkaTest() {
public void KafkaTest()
{
Console.WriteLine("kafka test invoked");
}
[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}");
return Ok();
}
......
......@@ -8,8 +8,8 @@ using Sample.Kafka;
namespace Sample.Kafka.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20170624095008_CreateDatabase")]
partial class CreateDatabase
[Migration("20170629074148_InitCreate")]
partial class InitCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
......@@ -32,7 +32,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries");
b.Property<string>("StateName")
b.Property<string>("StatusName")
.HasMaxLength(50);
b.HasKey("Id");
......@@ -55,7 +55,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries");
b.Property<string>("StateName")
b.Property<string>("StatusName")
.HasMaxLength(50);
b.HasKey("Id");
......
......@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Sample.Kafka.Migrations
{
public partial class CreateDatabase : Migration
public partial class InitCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
......@@ -18,7 +18,7 @@ namespace Sample.Kafka.Migrations
KeyName = table.Column<string>(nullable: true),
LastRun = table.Column<DateTime>(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 =>
{
......@@ -35,7 +35,7 @@ namespace Sample.Kafka.Migrations
KeyName = table.Column<string>(nullable: true),
LastRun = table.Column<DateTime>(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 =>
{
......
......@@ -31,7 +31,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries");
b.Property<string>("StateName")
b.Property<string>("StatusName")
.HasMaxLength(50);
b.HasKey("Id");
......@@ -54,7 +54,7 @@ namespace Sample.Kafka.Migrations
b.Property<int>("Retries");
b.Property<string>("StateName")
b.Property<string>("StatusName")
.HasMaxLength(50);
b.HasKey("Id");
......
......@@ -24,8 +24,8 @@ namespace Sample.Kafka
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>();
services.AddConsistency()
services.AddConsistency()
.AddEntityFrameworkStores<AppDbContext>()
.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