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
75de50d4
Commit
75de50d4
authored
Jul 28, 2017
by
Savorboard
Committed by
GitHub
Jul 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19 from alexinea/master
thanks alexinea!
parents
926769d3
4c5da09d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
13 deletions
+17
-13
CAP.KafkaOptions.cs
src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs
+10
-8
KafkaConsumerClient.cs
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
+3
-2
KafkaConsumerClientFactory.cs
src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
+3
-2
PublishQueueExecutor.cs
src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs
+1
-1
No files found.
src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs
View file @
75de50d4
...
...
@@ -21,32 +21,34 @@ namespace DotNetCore.CAP
/// Topic configuration parameters are specified via the "default.topic.config" sub-dictionary config parameter.
/// </para>
/// </summary>
public
IDictionary
<
string
,
object
>
MainConfig
{
get
;
private
set
;
}
public
readonly
IDictionary
<
string
,
object
>
MainConfig
;
/// <summary>
/// The `bootstrap.servers` item config of
`MainConfig`
.
/// The `bootstrap.servers` item config of
<see cref="MainConfig"/>
.
/// <para>
/// Initial list of brokers as a CSV list of broker host or host:port.
/// </para>
/// </summary>
public
string
Servers
{
get
;
set
;
}
internal
IEnumerable
<
KeyValuePair
<
string
,
object
>>
As
Rd
kafkaConfig
()
internal
IEnumerable
<
KeyValuePair
<
string
,
object
>>
AskafkaConfig
()
{
if
(
MainConfig
.
ContainsKey
(
"bootstrap.servers"
))
{
return
MainConfig
.
AsEnumerable
();
}
if
(
string
.
IsNullOr
Empty
(
Servers
))
if
(
string
.
IsNullOr
WhiteSpace
(
Servers
))
{
throw
new
ArgumentNullException
(
nameof
(
Servers
));
}
else
{
MainConfig
.
Add
(
"bootstrap.servers"
,
Servers
);
}
MainConfig
.
Add
(
"bootstrap.servers"
,
Servers
);
MainConfig
[
"queue.buffering.max.ms"
]
=
"10"
;
MainConfig
[
"socket.blocking.max.ms"
]
=
"10"
;
MainConfig
[
"enable.auto.commit"
]
=
"false"
;
return
MainConfig
.
AsEnumerable
();
}
}
...
...
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
View file @
75de50d4
...
...
@@ -21,7 +21,7 @@ namespace DotNetCore.CAP.Kafka
public
KafkaConsumerClient
(
string
groupId
,
KafkaOptions
options
)
{
_groupId
=
groupId
;
_kafkaOptions
=
options
;
_kafkaOptions
=
options
??
throw
new
ArgumentNullException
(
nameof
(
options
))
;
StringDeserializer
=
new
StringDeserializer
(
Encoding
.
UTF8
);
}
...
...
@@ -65,7 +65,7 @@ namespace DotNetCore.CAP.Kafka
{
_kafkaOptions
.
MainConfig
.
Add
(
"group.id"
,
_groupId
);
var
config
=
_kafkaOptions
.
As
Rd
kafkaConfig
();
var
config
=
_kafkaOptions
.
AskafkaConfig
();
_consumerClient
=
new
Consumer
<
Null
,
string
>(
config
,
null
,
StringDeserializer
);
_consumerClient
.
OnMessage
+=
ConsumerClient_OnMessage
;
...
...
@@ -80,6 +80,7 @@ namespace DotNetCore.CAP.Kafka
Name
=
e
.
Topic
,
Content
=
e
.
Value
};
OnMessageReceieved
?.
Invoke
(
sender
,
message
);
}
...
...
src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
View file @
75de50d4
using
Microsoft.Extensions.Options
;
using
System
;
using
Microsoft.Extensions.Options
;
namespace
DotNetCore.CAP.Kafka
{
...
...
@@ -8,7 +9,7 @@ namespace DotNetCore.CAP.Kafka
public
KafkaConsumerClientFactory
(
IOptions
<
KafkaOptions
>
kafkaOptions
)
{
_kafkaOptions
=
kafkaOptions
.
Value
;
_kafkaOptions
=
kafkaOptions
?.
Value
??
throw
new
ArgumentNullException
(
nameof
(
kafkaOptions
))
;
}
public
IConsumerClient
Create
(
string
groupId
)
...
...
src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs
View file @
75de50d4
...
...
@@ -26,7 +26,7 @@ namespace DotNetCore.CAP.Kafka
{
try
{
var
config
=
_kafkaOptions
.
As
Rd
kafkaConfig
();
var
config
=
_kafkaOptions
.
AskafkaConfig
();
var
contentBytes
=
Encoding
.
UTF8
.
GetBytes
(
content
);
using
(
var
producer
=
new
Producer
(
config
))
{
...
...
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