This commit is contained in:
Mariusz Pacek committed 2018-03-14 09:07:05 +01:00
1 parent b9f39bd708
commit 0ea913646a
3 files changed
+9 -6

No files matched your search

BIN
View File
Binary file not shown.
@@ -14,7 +14,11 @@ public class Sender {
private KafkaTemplate<String,String> kafkaTemplate; private KafkaTemplate<String,String> kafkaTemplate;
public void send(String topic, String payload){ public void send(String topic, String payload){
log.info("sending payload='{}' to topic ='{}'",payload,topic); int i=10;
kafkaTemplate.send(topic,payload); while(i>0) {
log.info("sending payload='{}' to topic ='{}'", payload, topic);
kafkaTemplate.send(topic, payload);
i--;
}
} }
} }
@@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import kafka.server.KafkaServer;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -12,7 +11,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.kafka.test.context.EmbeddedKafka;
import org.springframework.kafka.test.rule.KafkaEmbedded; import org.springframework.kafka.test.rule.KafkaEmbedded;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
@@ -21,6 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest @SpringBootTest
@DirtiesContext @DirtiesContext
public class SpringKafkaApplicationTest { public class SpringKafkaApplicationTest {
private static final Logger log = LoggerFactory.getLogger(SpringKafkaApplicationTest.class); private static final Logger log = LoggerFactory.getLogger(SpringKafkaApplicationTest.class);
private static String BOOT_TOPIC = "boot.t"; private static String BOOT_TOPIC = "boot.t";
@@ -31,8 +30,8 @@ public class SpringKafkaApplicationTest {
private Consumer receiver; private Consumer receiver;
@ClassRule @ClassRule
public static KafkaEmbedded embeddedKafka = public static KafkaEmbedded embeddedKafka = new KafkaEmbedded(1, true, BOOT_TOPIC);
new KafkaEmbedded(1, true, BOOT_TOPIC);
@Test @Test
public void testReceive() throws Exception { public void testReceive() throws Exception {
sender.send(BOOT_TOPIC, "Hello Boot!"); sender.send(BOOT_TOPIC, "Hello Boot!");