yangxiaodong 7 лет назад
Родитель
Сommit
081fcd421b
1 измененных файлов: 10 добавлений и 12 удалений
  1. +10
    -12
      README.md

+ 10
- 12
README.md Просмотреть файл

@@ -16,7 +16,7 @@ CAP has the function of Message Presistence, and it makes messages reliability w

This is a diagram of the CAP working in the ASP.NET Core MicroService architecture:

![](http://images2015.cnblogs.com/blog/250417/201706/250417-20170630143600289-1065294295.png)
![](http://images2015.cnblogs.com/blog/250417/201707/250417-20170705175827128-1203291469.png)

> The solid line in the figure represents the user code, and the dotted line represents the internal implementation of the CAP.

@@ -29,19 +29,19 @@ You can run the following command to install the CAP in your project.
If your Message Queue is using Kafka, you can:

```
PM> Install-Package DotNetCore.CAP.Kafka
PM> Install-Package DotNetCore.CAP.Kafka -Pre
```

or RabbitMQ:

```
PM> Install-Package DotNetCore.CAP.RabbitMQ
PM> Install-Package DotNetCore.CAP.RabbitMQ -Pre
```

CAP provides EntityFramework as default database store extension :

```
PM> Install-Package DotNetCore.CAP.EntityFrameworkCore
PM> Install-Package DotNetCore.CAP.EntityFrameworkCore -Pre
```

### Configuration
@@ -57,7 +57,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddCap()
.AddEntityFrameworkStores<AppDbContext>()
.AddKafka(x => x.Servers = "localhost:9453");
.AddKafka(x => x.Servers = "localhost:9092");
}

public void Configure(IApplicationBuilder app)
@@ -100,9 +100,7 @@ public class PublishController : Controller

**Action Method**

Add Attribute on Action to subscribe message:

If you are using Kafka the Attribute is `[KafkaTopic()]`, and RabbitMQ is `[RabbitMQTopic()]`
Add the Attribute `[CapSubscribe()]` on Action to subscribe message:

```cs
public class PublishController : Controller
@@ -116,7 +114,7 @@ public class PublishController : Controller


[NoAction]
[KafkaTopic("xxx.services.account.check")]
[CapSubscribe("xxx.services.account.check")]
public async Task CheckReceivedMessage(Person person)
{
Console.WriteLine(person.Name);
@@ -129,7 +127,7 @@ public class PublishController : Controller

**Service Method**

If your subscribe method is not in the Controller,then your subscribe class need to Inheritance `IConsumerService`:
If your subscribe method is not in the Controller,then your subscribe class need to Inheritance `ICapSubscribe`:

```cs

@@ -141,9 +139,9 @@ namespace xxx.Service
}


public class SubscriberService: ISubscriberService, IConsumerService
public class SubscriberService: ISubscriberService, ICapSubscribe
{
[KafkaTopic("xxx.services.account.check")]
[CapSubscribe("xxx.services.account.check")]
public void CheckReceivedMessage(Person person)
{


Загрузка…
Отмена
Сохранить