Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
spring-boot-kafka-consumer-example
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
KafkaExamples
spring-boot-kafka-consumer-example
Commits
0ec76acb
Commit
0ec76acb
authored
5 years ago
by
NareshKodumoori
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding two consumers
parent
bda2b214
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
KafkaConfiguration.java
...ngbootkafkaconsumerexample/config/KafkaConfiguration.java
+8
-4
No files found.
src/main/java/com/techprimers/kafka/springbootkafkaconsumerexample/config/KafkaConfiguration.java
View file @
0ec76acb
...
...
@@ -18,9 +18,11 @@ import java.util.Map;
@Configuration
public
class
KafkaConfiguration
{
private
Map
<
String
,
Object
>
config
;
@Bean
public
ConsumerFactory
<
String
,
String
>
consumerFactory
(){
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
config
=
new
HashMap
<>();
config
.
put
(
ConsumerConfig
.
BOOTSTRAP_SERVERS_CONFIG
,
"127.0.0.1:9092"
);
config
.
put
(
ConsumerConfig
.
GROUP_ID_CONFIG
,
"group_id"
);
config
.
put
(
ConsumerConfig
.
KEY_DESERIALIZER_CLASS_CONFIG
,
StringDeserializer
.
class
);
...
...
@@ -37,12 +39,14 @@ public class KafkaConfiguration {
@Bean
public
ConsumerFactory
<
String
,
User
>
userConsumerFactory
()
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
config
=
new
HashMap
<>();
config
.
put
(
ConsumerConfig
.
BOOTSTRAP_SERVERS_CONFIG
,
"127.0.0.1:9092"
);
config
.
put
(
ConsumerConfig
.
GROUP_ID_CONFIG
,
"group_json"
);
config
.
put
(
ConsumerConfig
.
ENABLE_AUTO_COMMIT_CONFIG
,
"false"
);
config
.
put
(
ConsumerConfig
.
AUTO_OFFSET_RESET_CONFIG
,
"earliest"
);
config
.
put
(
ConsumerConfig
.
KEY_DESERIALIZER_CLASS_CONFIG
,
StringDeserializer
.
class
);
config
.
put
(
ConsumerConfig
.
VALUE_DESERIALIZER_CLASS_CONFIG
,
JsonDeserializer
.
class
);
return
new
DefaultKafkaConsumerFactory
<>(
config
,
new
StringDeserializer
(),
new
JsonDeserializer
<>(
User
.
class
));
return
new
DefaultKafkaConsumerFactory
<>(
config
,
new
StringDeserializer
(),
new
JsonDeserializer
<>(
User
.
class
,
false
));
}
@Bean
...
...
@@ -52,4 +56,4 @@ public class KafkaConfiguration {
return
factory
;
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
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