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
a29f8abf
Commit
a29f8abf
authored
May 28, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update samples.
parent
be5e406d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
4 deletions
+47
-4
AppDbContext.cs
samples/Sample.Kafka/AppDbContext.cs
+15
-0
ValuesController.cs
samples/Sample.Kafka/Controllers/ValuesController.cs
+19
-1
Sample.Kafka.csproj
samples/Sample.Kafka/Sample.Kafka.csproj
+4
-0
Startup.cs
samples/Sample.Kafka/Startup.cs
+9
-3
No files found.
samples/Sample.Kafka/
Entity/AppKafkaLog
.cs
→
samples/Sample.Kafka/
AppDbContext
.cs
View file @
a29f8abf
...
...
@@ -2,10 +2,14 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Infrastructure
;
using
JetBrains.Annotations
;
using
Microsoft.EntityFrameworkCore
;
namespace
Sample.Kafka
.Entity
namespace
Sample.Kafka
{
public
class
App
KafkaLog
public
class
App
DbContext
:
DbContext
{
public
DbSet
<
ConsistencyMessage
>
Messages
{
get
;
set
;
}
}
}
samples/Sample.Kafka/Controllers/ValuesController.cs
View file @
a29f8abf
...
...
@@ -4,6 +4,7 @@ using System.Linq;
using
System.Threading.Tasks
;
using
Cap.Consistency.Consumer
;
using
Cap.Consistency.Kafka
;
using
Cap.Consistency.Producer
;
using
Microsoft.AspNetCore.Mvc
;
namespace
Sample.Kafka.Controllers
...
...
@@ -11,10 +12,27 @@ namespace Sample.Kafka.Controllers
[
Route
(
"api/[controller]"
)]
public
class
ValuesController
:
Controller
,
IConsumerService
{
private
readonly
IProducerClient
_producer
;
[
KafkaTopic
(
"zzwl.topic.finace.callBack"
,
IsOneWay
=
true
)]
public
ValuesController
(
IProducerClient
producer
)
{
_producer
=
producer
;
}
[
Route
(
"/"
)]
public
IActionResult
Index
()
{
return
Ok
();
}
[
KafkaTopic
(
"zzwl.topic.finace.callBack"
,
IsOneWay
=
true
,
GroupOrExchange
=
"test"
)]
[
NonAction
]
public
void
KafkaTest
()
{
Console
.
WriteLine
(
"kafka test invoked"
);
}
[
Route
(
"~/send"
)]
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/Sample.Kafka.csproj
View file @
a29f8abf
...
...
@@ -11,13 +11,17 @@
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Cap.Consistency.EntityFrameworkCore\Cap.Consistency.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\Cap.Consistency.Kafka\Cap.Consistency.Kafka.csproj" />
<ProjectReference Include="..\..\src\Cap.Consistency.RabbitMQ\Cap.Consistency.RabbitMQ.csproj" />
<ProjectReference Include="..\..\src\Cap.Consistency\Cap.Consistency.csproj" />
</ItemGroup>
...
...
samples/Sample.Kafka/Startup.cs
View file @
a29f8abf
...
...
@@ -5,10 +5,10 @@ using System.Threading.Tasks;
using
Cap.Consistency.Infrastructure
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
Sample.Kafka.Entity
;
namespace
Sample.Kafka
{
...
...
@@ -27,12 +27,18 @@ namespace Sample.Kafka
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
{
services
.
AddDbContext
<
AppDbContext
>();
services
.
AddConsistency
<
ConsistencyMessage
>()
.
AddEntityFrameworkStores
<
AppDbContext
>()
.
AddKafka
();
// Add framework services.
services
.
AddMvc
();
services
.
AddConsistency
<
ConsistencyMessage
>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public
void
Configure
(
IApplicationBuilder
app
,
IHostingEnvironment
env
,
ILoggerFactory
loggerFactory
)
{
loggerFactory
.
AddConsole
(
Configuration
.
GetSection
(
"Logging"
));
...
...
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