Browse Source

update samples

master
yangxiaodong 7 years ago
parent
commit
1a35a8b0ed
6 changed files with 23 additions and 17 deletions
  1. +2
    -2
      samples/Sample.Kafka/AppDbContext.cs
  2. +10
    -4
      samples/Sample.Kafka/Controllers/ValuesController.cs
  3. +4
    -4
      samples/Sample.Kafka/Migrations/20170629074148_InitCreate.Designer.cs
  4. +3
    -3
      samples/Sample.Kafka/Migrations/20170629074148_InitCreate.cs
  5. +2
    -2
      samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs
  6. +2
    -2
      samples/Sample.Kafka/Startup.cs

+ 2
- 2
samples/Sample.Kafka/AppDbContext.cs View File

@@ -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<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); base.OnModelCreating(modelBuilder);
} }


+ 10
- 4
samples/Sample.Kafka/Controllers/ValuesController.cs View File

@@ -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
{ {
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();
} }


samples/Sample.Kafka/Migrations/20170624095008_CreateDatabase.Designer.cs → samples/Sample.Kafka/Migrations/20170629074148_InitCreate.Designer.cs View File

@@ -8,8 +8,8 @@ using Sample.Kafka;
namespace Sample.Kafka.Migrations namespace Sample.Kafka.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20170624095008_CreateDatabase")]
partial class CreateDatabase
[Migration("20170629074148_InitCreate")]
partial class InitCreate
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
@@ -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


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");

samples/Sample.Kafka/Migrations/20170624095008_CreateDatabase.cs → samples/Sample.Kafka/Migrations/20170629074148_InitCreate.cs View File

@@ -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
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
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 =>
{ {

+ 2
- 2
samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs View File

@@ -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


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");


+ 2
- 2
samples/Sample.Kafka/Startup.cs View File

@@ -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 =>
{ {


Loading…
Cancel
Save