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
f8759398
Commit
f8759398
authored
Jul 31, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix multiple subscribing only received one message bug.
parent
2eaca664
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
14 deletions
+11
-14
KafkaConsumerClient.cs
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
+7
-7
IConsumerClient.cs
src/DotNetCore.CAP/IConsumerClient.cs
+2
-3
IConsumerHandler.Default.cs
src/DotNetCore.CAP/IConsumerHandler.Default.cs
+2
-4
No files found.
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
View file @
f8759398
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading
;
using
Confluent.Kafka
;
...
...
@@ -25,19 +26,18 @@ namespace DotNetCore.CAP.Kafka
StringDeserializer
=
new
StringDeserializer
(
Encoding
.
UTF8
);
}
public
void
Subscribe
(
string
topic
)
public
void
Subscribe
(
IEnumerable
<
string
>
topics
)
{
Subscribe
(
topic
,
0
);
}
if
(
topics
==
null
)
throw
new
ArgumentNullException
(
nameof
(
topics
));
public
void
Subscribe
(
string
topicName
,
int
partition
)
{
if
(
_consumerClient
==
null
)
{
InitKafkaClient
();
}
_consumerClient
.
Assignment
.
Add
(
new
TopicPartition
(
topicName
,
partition
));
_consumerClient
.
Subscribe
(
topicName
);
//_consumerClient.Assign(topics.Select(x=> new TopicPartition(x, 0)));
_consumerClient
.
Subscribe
(
topics
);
}
public
void
Listening
(
TimeSpan
timeout
,
CancellationToken
cancellationToken
)
...
...
src/DotNetCore.CAP/IConsumerClient.cs
View file @
f8759398
using
System
;
using
System.Collections.Generic
;
using
System.Threading
;
namespace
DotNetCore.CAP
...
...
@@ -8,9 +9,7 @@ namespace DotNetCore.CAP
/// </summary>
public
interface
IConsumerClient
:
IDisposable
{
void
Subscribe
(
string
topic
);
void
Subscribe
(
string
topic
,
int
partition
);
void
Subscribe
(
IEnumerable
<
string
>
topics
);
void
Listening
(
TimeSpan
timeout
,
CancellationToken
cancellationToken
);
...
...
src/DotNetCore.CAP/IConsumerHandler.Default.cs
View file @
f8759398
using
System
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Infrastructure
;
...
...
@@ -56,10 +57,7 @@ namespace DotNetCore.CAP
{
RegisterMessageProcessor
(
client
);
foreach
(
var
item
in
matchGroup
.
Value
)
{
client
.
Subscribe
(
item
.
Attribute
.
Name
);
}
client
.
Subscribe
(
matchGroup
.
Value
.
Select
(
x
=>
x
.
Attribute
.
Name
));
client
.
Listening
(
_pollingDelay
,
_cts
.
Token
);
}
...
...
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