ソースを参照

update readme

master
Savorboard 7年前
コミット
43ee6268ed
2個のファイルの変更15行の追加23行の削除
  1. +4
    -5
      README.md
  2. +11
    -18
      README.zh-cn.md

+ 4
- 5
README.md ファイルの表示

@@ -94,7 +94,7 @@ public void Configure(IApplicationBuilder app)

Inject `ICapPublisher` in your Controller, then use the `ICapPublisher` to send message

```cs
```c#
public class PublishController : Controller
{
private readonly AppDbContext _dbContext;
@@ -109,9 +109,9 @@ public class PublishController : Controller
{
using (var trans = dbContext.Database.BeginTransaction())
{
// your business code
// your business code

//Achieving atomicity between original database operation and the publish event log thanks to a local transaction
//Achieving atomicity between original database operation and the publish event log thanks to a local transaction
await publisher.PublishAsync("xxx.services.account.check", new Person { Name = "Foo", Age = 11 });

trans.Commit();
@@ -128,10 +128,9 @@ public class PublishController : Controller

Add the Attribute `[CapSubscribe()]` on Action to subscribe message:

```cs
```c#
public class PublishController : Controller
{
[NoAction]
[CapSubscribe("xxx.services.account.check")]
public async Task CheckReceivedMessage(Person person)
{


+ 11
- 18
README.zh-cn.md ファイルの表示

@@ -97,32 +97,25 @@ public void Configure(IApplicationBuilder app)
```c#
public class PublishController : Controller
{
private readonly ICapPublisher _publisher;

public PublishController(ICapPublisher publisher)
{
_publisher = publisher;
}
private readonly AppDbContext _dbContext;


[Route("~/checkAccount")]
public async Task<IActionResult> PublishMessage()
public PublishController(AppDbContext dbContext)
{
//指定发送的消息头和内容
await _publisher.PublishAsync("xxx.services.account.check", new Person { Name = "Foo", Age = 11 });

return Ok();
_dbContext = dbContext;
}

[Route("~/checkAccountWithTrans")]
public async Task<IActionResult> PublishMessageWithTransaction([FromServices]AppDbContext dbContext)
public async Task<IActionResult> PublishMessageWithTransaction([FromServices]ICapPublisher publisher)
{
using (var trans = dbContext.Database.BeginTransaction())
{
await _publisher.PublishAsync("xxx.services.account.check", new Person { Name = "Foo", Age = 11 });
using (var trans = dbContext.Database.BeginTransaction())
{
// your business code

//Achieving atomicity between original database operation and the publish event log thanks to a local transaction
await publisher.PublishAsync("xxx.services.account.check", new Person { Name = "Foo", Age = 11 });

trans.Commit();
}
}
return Ok();
}
}


読み込み中…
キャンセル
保存