Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
1528bf8e
Commit
1528bf8e
authored
Jul 20, 2017
by
Savorboard
Committed by
GitHub
Jul 20, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11 from kiss96803/develop
Update README.md in develop
parents
a03f4952
0381a79e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
12 deletions
+39
-12
README.md
README.md
+39
-12
No files found.
README.md
View file @
1528bf8e
...
...
@@ -2,8 +2,7 @@
<a
href=
"https://github.com/dotnetcore/CAP/blob/develop/README.zh-cn.md"
>
中文
</a>
</p>
# CAP
# CAP
[

](https://travis-ci.org/dotnetcore/CAP)
[

](https://ci.appveyor.com/project/yuleyule66/cap)
[

](https://www.nuget.org/packages/DotNetCore.CAP/)
...
...
@@ -29,26 +28,30 @@ This is a diagram of the CAP working in the ASP.NET Core MicroService architectu
## Getting Started
### NuGet
(Coming soon)
### NuGet
You can run the following command to install the CAP in your project.
```
PM> Install-Package DotNetCore.CAP -Pre
```
If your Message Queue is using Kafka, you can:
```
PM> Install-Package DotNetCore.CAP.Kafka -Pre
```
or RabbitMQ
:
If your Message Queue is using RabbitMQ, you can
:
```
PM> Install-Package DotNetCore.CAP.RabbitMQ -Pre
```
CAP provides EntityFramework as default database store extension :
CAP provides EntityFramework as default database store extension
(The MySQL version is under development)
:
```
PM> Install-Package DotNetCore.CAP.
EntityFrameworkCore
-Pre
PM> Install-Package DotNetCore.CAP.
SqlServer
-Pre
```
### Configuration
...
...
@@ -60,11 +63,23 @@ public void ConfigureServices(IServiceCollection services)
{
......
services
.
AddDbContext
<
AppDbContext
>();
services
.
AddDbContext
<
AppDbContext
>();
services
.
AddCap
()
.
AddEntityFrameworkStores
<
AppDbContext
>()
.
AddKafka
(
x
=>
x
.
Servers
=
"localhost:9092"
);
services
.
AddCap
(
x
=>
{
// If your SqlServer is using EF for data operations, you need to add the following configuration:
// Notice: You don't need to config x.UseSqlServer(""") again!
x
.
UseEntityFramework
<
AppDbContext
>();
// If you are using Dapper,you need to add the config:
x
.
UseSqlServer
(
"Your ConnectionStrings"
);
// If your Message Queue is using RabbitMQ you need to add the config:
x
.
UseRabbitMQ
(
"localhost"
);
// If your Message Queue is using Kafka you need to add the config:
x
.
UseKafka
(
"localhost"
);
});
}
public
void
Configure
(
IApplicationBuilder
app
)
...
...
@@ -94,11 +109,23 @@ public class PublishController : Controller
[
Route
(
"~/checkAccount"
)]
public
async
Task
<
IActionResult
>
PublishMessage
()
{
//Specifies the message header and content to be sent
//
Specifies the message header and content to be sent
await
_publisher
.
PublishAsync
(
"xxx.services.account.check"
,
new
Person
{
Name
=
"Foo"
,
Age
=
11
});
return
Ok
();
}
[
Route
(
"~/checkAccountWithTrans"
)]
public
async
Task
<
IActionResult
>
PublishMessageWithTransaction
([
FromServices
]
AppDbContext
dbContext
)
{
using
(
var
trans
=
dbContext
.
Database
.
BeginTransaction
())
{
await
_publisher
.
PublishAsync
(
"xxx.services.account.check"
,
new
Person
{
Name
=
"Foo"
,
Age
=
11
});
trans
.
Commit
();
}
return
Ok
();
}
}
```
...
...
@@ -148,7 +175,7 @@ namespace xxx.Service
public
class
SubscriberService
:
ISubscriberService
,
ICapSubscribe
{
[
CapSubscribe
(
"xxx.services.account.check"
)]
[
KafkaTopic
(
"xxx.services.account.check"
)]
public
void
CheckReceivedMessage
(
Person
person
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment