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
1a35a8b0
Commit
1a35a8b0
authored
Jun 29, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update samples
parent
fdf69c12
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
17 deletions
+23
-17
AppDbContext.cs
samples/Sample.Kafka/AppDbContext.cs
+2
-2
ValuesController.cs
samples/Sample.Kafka/Controllers/ValuesController.cs
+10
-4
20170629074148_InitCreate.Designer.cs
...le.Kafka/Migrations/20170629074148_InitCreate.Designer.cs
+4
-4
20170629074148_InitCreate.cs
samples/Sample.Kafka/Migrations/20170629074148_InitCreate.cs
+3
-3
AppDbContextModelSnapshot.cs
samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs
+2
-2
Startup.cs
samples/Sample.Kafka/Startup.cs
+2
-2
No files found.
samples/Sample.Kafka/AppDbContext.cs
View file @
1a35a8b0
...
...
@@ -22,8 +22,8 @@ namespace Sample.Kafka
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
modelBuilder
.
Entity
<
CapSentMessage
>().
Property
(
x
=>
x
.
Stat
e
Name
).
HasMaxLength
(
50
);
modelBuilder
.
Entity
<
CapReceivedMessage
>().
Property
(
x
=>
x
.
Stat
e
Name
).
HasMaxLength
(
50
);
modelBuilder
.
Entity
<
CapSentMessage
>().
Property
(
x
=>
x
.
Stat
us
Name
).
HasMaxLength
(
50
);
modelBuilder
.
Entity
<
CapReceivedMessage
>().
Property
(
x
=>
x
.
Stat
us
Name
).
HasMaxLength
(
50
);
base
.
OnModelCreating
(
modelBuilder
);
}
...
...
samples/Sample.Kafka/Controllers/ValuesController.cs
View file @
1a35a8b0
...
...
@@ -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/2017062
4095008_CreateDatabas
e.Designer.cs
→
samples/Sample.Kafka/Migrations/2017062
9074148_InitCreat
e.Designer.cs
View file @
1a35a8b0
...
...
@@ -8,8 +8,8 @@ using Sample.Kafka;
namespace
Sample.Kafka.Migrations
{
[
DbContext
(
typeof
(
AppDbContext
))]
[
Migration
(
"2017062
4095008_CreateDatabas
e"
)]
partial
class
CreateDatabas
e
[
Migration
(
"2017062
9074148_InitCreat
e"
)]
partial
class
InitCreat
e
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
...
...
@@ -32,7 +32,7 @@ namespace Sample.Kafka.Migrations
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"Stat
e
Name"
)
b
.
Property
<
string
>(
"Stat
us
Name"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
...
...
@@ -55,7 +55,7 @@ namespace Sample.Kafka.Migrations
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"Stat
e
Name"
)
b
.
Property
<
string
>(
"Stat
us
Name"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
...
...
samples/Sample.Kafka/Migrations/2017062
4095008_CreateDatabas
e.cs
→
samples/Sample.Kafka/Migrations/2017062
9074148_InitCreat
e.cs
View file @
1a35a8b0
...
...
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace
Sample.Kafka.Migrations
{
public
partial
class
CreateDatabas
e
:
Migration
public
partial
class
InitCreat
e
:
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
),
Stat
e
Name
=
table
.
Column
<
string
>(
maxLength
:
50
,
nullable
:
true
)
Stat
us
Name
=
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
),
Stat
e
Name
=
table
.
Column
<
string
>(
maxLength
:
50
,
nullable
:
true
)
Stat
us
Name
=
table
.
Column
<
string
>(
maxLength
:
50
,
nullable
:
true
)
},
constraints
:
table
=>
{
...
...
samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs
View file @
1a35a8b0
...
...
@@ -31,7 +31,7 @@ namespace Sample.Kafka.Migrations
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"Stat
e
Name"
)
b
.
Property
<
string
>(
"Stat
us
Name"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
...
...
@@ -54,7 +54,7 @@ namespace Sample.Kafka.Migrations
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"Stat
e
Name"
)
b
.
Property
<
string
>(
"Stat
us
Name"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
...
...
samples/Sample.Kafka/Startup.cs
View file @
1a35a8b0
...
...
@@ -24,8 +24,8 @@ namespace Sample.Kafka
public
void
ConfigureServices
(
IServiceCollection
services
)
{
services
.
AddDbContext
<
AppDbContext
>();
services
.
AddConsistency
()
services
.
AddConsistency
()
.
AddEntityFrameworkStores
<
AppDbContext
>()
.
AddRabbitMQ
(
x
=>
{
...
...
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