Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KafkaExamples
spring-boot-kafka-consumer-example
Commits
0ec76acb
Commit
0ec76acb
authored
5 years ago
by
NareshKodumoori
Browse files
Options
Download
Email Patches
Plain Diff
Adding two consumers
parent
bda2b214
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/techprimers/kafka/springbootkafkaconsumerexample/config/KafkaConfiguration.java
+8
-4
...ngbootkafkaconsumerexample/config/KafkaConfiguration.java
with
8 additions
and
4 deletions
+8
-4
src/main/java/com/techprimers/kafka/springbootkafkaconsumerexample/config/KafkaConfiguration.java
+
8
-
4
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
Supports
Markdown
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