Kaynağa Gözat

update samples

master
yangxiaodong 7 yıl önce
ebeveyn
işleme
1a35a8b0ed
6 değiştirilmiş dosya ile 23 ekleme ve 17 silme
  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 Dosyayı Görüntüle

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


+ 10
- 4
samples/Sample.Kafka/Controllers/ValuesController.cs Dosyayı Görüntüle

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


samples/Sample.Kafka/Migrations/20170624095008_CreateDatabase.Designer.cs → samples/Sample.Kafka/Migrations/20170629074148_InitCreate.Designer.cs Dosyayı Görüntüle

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

samples/Sample.Kafka/Migrations/20170624095008_CreateDatabase.cs → samples/Sample.Kafka/Migrations/20170629074148_InitCreate.cs Dosyayı Görüntüle

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

+ 2
- 2
samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs Dosyayı Görüntüle

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


+ 2
- 2
samples/Sample.Kafka/Startup.cs Dosyayı Görüntüle

@@ -24,8 +24,8 @@ namespace Sample.Kafka
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>();
services.AddConsistency()
services.AddConsistency()
.AddEntityFrameworkStores<AppDbContext>()
.AddRabbitMQ(x =>
{


Yükleniyor…
İptal
Kaydet