CAP uses Microsoft.Extensions.DependencyInjection for configuration injection.
### Cap Options
## CAP Configs
You can use the following methods to configure some configuration items in the CAP, for example:
...
...
@@ -27,7 +27,7 @@ CapOptions provides a callback function for `FailedCallback` to handle failed me
The type of FailedCallback is `Action<MessageType,string,string>`. The first parameter is the message type (send or receive), the second parameter is the name of the message, and the third parameter is the content of the message.
### RabbitMQ Options
## RabbitMQ Configs
The CAP uses the CapOptions extension to implement the RabbitMQ configuration function. Therefore, the configuration of the RabbitMQ is used as follows:
If you are using Entityframework as a message persistence store, then you can customize some configuration when configuring the CAP EntityFramework configuration item.
...
...
@@ -94,7 +94,7 @@ Schema | Cap table schema | string | Cap (SQL Server)
Schema | Cap table schema | string | cap (PostgreSql)
TableNamePrefix | Cap table name prefix | string | cap (MySql)
### SqlServer Options
### SqlServer Configs
Note that if you are using EntityFramewrok, you do not use this configuration item.
...
...
@@ -114,7 +114,7 @@ NAME | DESCRIPTION | TYPE | DEFAULT
With the popularity of microservices architecture, more and more people are trying to use microservices to architect their systems. In this we encounter problems such as distributed transactions. To solve these problems, I did not find simplicity and Easy to use solution, so I decided to create such a library to solve this problem.
...
...
@@ -8,7 +8,7 @@ The original CAP was to solve the transaction problems in the distributed system
Now in addition to solving distributed transaction problems, CAP's other important function is to use it as an EventBus. It has all of the features of EventBus and provides a more simplified way to handle publish/subscribe in EventBus.
### Persistence
## Persistence
The CAP relies on the local database for persistence of messages. The CAP uses this method to deal with situations in which all messages are lost due to environmental or network anomalies. The reliability of messages is the cornerstone of distributed transactions, so messages cannot be lost under any circumstances.
...
...
@@ -28,7 +28,7 @@ For message persistence in RabbitMQ, CAP uses a consumer queue with message pers
Since Kafka is inherently designed to persist messages using files, Kafka ensures that messages are correctly persisted without loss after the message enters Kafka.
### Communication Data Streams
## Communication Data Streams
The flow of messages in the CAP is roughly as follows:
...
...
@@ -42,7 +42,7 @@ The flow of messages in the CAP is roughly as follows:
In the 2.2 and later versions, we adjusted the flow of some messages. We removed the Queue table in the database and used the memory queue instead. For details, see: [Improve the implementation mechanism of queue mode](https://github.com/dotnetcore/CAP/issues/96)
### Consistency
## Consistency
The CAP uses the ultimate consistency as a consistent solution. This solution follows the CAP theory. The following is the description of the CAP theory.
### Any IM group(e.g Tencent QQ group) to learn and chat about CAP?
## Any IM group(e.g Tencent QQ group) to learn and chat about CAP?
None for that. Better than wasting much time in IM group, I hope developers could be capable of independent thinking more, and solve problems yourselves with referenced documents, even create issues or send emails when errors are remaining present.
### Does it require certain different databases, one each for productor and resumer in CAP?
## Does it require certain different databases, one each for productor and resumer in CAP?
Not requird differences necessary, a given advice is that using a special database for each program.
Otherwise, look at Q&A below.
### How to use the same database for different programs?
## How to use the same database for different programs?
defining a prefix name of table in `ConfigureServices` method。
...
...
@@ -31,9 +31,10 @@ public void ConfigureServices(IServiceCollection services)
}
```
NOTE:different prefixed names cause SLB to no effect.
!!!NOTE
Different prefixed names cause SLB to no effect.
### If don't care about message missing, can message productor exist without any database, for the reason of sending message only.
## If don't care about message missing, can message productor exist without any database, for the reason of sending message only.
CAP is a library based on .Net standard, which is a solution to deal with distributed transactions, also has the function of EventBus, it is lightweight, easy to use, and efficiently.
# Getting Stared
## Usage Scenarios
...
...
@@ -193,7 +191,4 @@ public void ConfigureServices(IServiceCollection services)
Users can get a ICapPublisher interface from the ASP.NET Core DI container to publish a message .It is initialized by configurations in the `ConfigureServices` and `configure` method in the Startup.cs file,just like the way to initialize a `MiddleWare` in ASP.NET Core.
### Message Table
## Message Table
After initialized, CAP will create two tables in the client side,they are `Cap.Published` and `Cap.Received`. Please noted that different databases may deal letter case differently,if you do not explicitly specify the Schema or the TableName Prefix before project startup,the default names are the ones mentioned above.
...
...
@@ -22,7 +23,7 @@ Version later than 2.2, CAP will retry after 4 minutes if the status is `Schedu
>Before version 2.2,CAP retry 100 times for `Failed` messages by default.
### Message format5
## Message format
CAP use JSON to transfer message,the following is CAP's messaging object model:
...
...
@@ -52,7 +53,7 @@ CallbackName | the subscriber which is used to call back | string
CAP use the same algorithms as MongoDB ObjectId's distributed Id generation algorithms.
### EventBus
## EventBus
EventBus adopt the publish-subscribe messaging style to communicate with different components,and there is no need to register it in component explicitly.
...
...
@@ -67,7 +68,7 @@ We say that CAP implement all the features in Eventbus,EventBus has two features
In CAP,send a message can be regarded as an "Event",When CAP is used in an ASP.NET Core applicaiton,the application has the ablity to publish as well as receive messages.
### Retry
## Retry
Retry plays a very important role in CAP's infrastructure,CAP will retry for Failed messages.CAP has the following retry strategies:
...
...
@@ -83,7 +84,7 @@ As metioned above,when the retry count comes to a certain number,CAP will not re
When consumer received messages,specified method in the consumer will be executed,if exceptions are thrown during this course,CAP will retry,the retry strategy is the same as above `Retry on sending`.
### Data clean out
## Data clean out
table to store messages in database has an `ExpiresAt` field to mark the expiration time of the message. CAP will set `ExpiresAt` value as **1 hour** for `Successed` messages and **15days** for `Failed` messages.
For the processing of distributed transactions, this CAP library matches the "Asynchronous recovery events" scenario.
### Asynchronous recovery events
## Asynchronous recovery events
As known as the name "native message table", this is a classic solution, originally from EBay, and referenced links about it are at the end of this section. This is also one of the most popular solutions in the business development.