Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
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
DEMO
spring-boot
Commits
fddc8bd8
Commit
fddc8bd8
authored
May 10, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Kafka sample topic
parent
555dd3bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
SampleKafkaApplication.java
...ka/src/main/java/sample/kafka/SampleKafkaApplication.java
+8
-1
SampleKafkaApplicationTests.java
...c/test/java/sample/kafka/SampleKafkaApplicationTests.java
+1
-1
No files found.
spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleKafkaApplication.java
View file @
fddc8bd8
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -16,6 +16,8 @@
package
sample
.
kafka
;
import
org.apache.kafka.clients.admin.NewTopic
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
@@ -28,6 +30,11 @@ public class SampleKafkaApplication {
SpringApplication
.
run
(
SampleKafkaApplication
.
class
,
args
);
}
@Bean
public
NewTopic
kafkaTestTopic
()
{
return
new
NewTopic
(
"testTopic"
,
10
,
(
short
)
2
);
}
@Bean
public
ApplicationRunner
runner
(
Producer
producer
)
{
return
(
args
)
->
producer
.
send
(
new
SampleMessage
(
1
,
"A simple test message"
));
...
...
spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java
View file @
fddc8bd8
...
...
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@SpringBootTest
(
properties
=
"spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}"
)
@EmbeddedKafka
@EmbeddedKafka
(
topics
=
"testTopic"
)
class
SampleKafkaApplicationTests
{
@RegisterExtension
...
...
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