diff --git a/.gitignore b/.gitignore index 639b399241e394db1e3d71974da4fb96e0078743..05e27e0bb70fe7559f83ca617a7dbef9fc310a02 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,5 @@ buildNumber.properties .mvn/timing.properties .mvn/wrapper/maven-wrapper.jar +/.idea/.name +/.idea/vcs.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000000000000000000000000000000000000..523849b74459f597d170cfeff24a150965c51a2b --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +demo-parent \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..ed3c7f419ccf77853c5b7c777a91951f099053fb --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..63fd03358dfa2da1caba690cfffa56acf29f878e --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000000000000000000000000000000000..6560a98983ec708cf9d8b5c5c3776d7bd39c475b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..abde0f9e07d1380d124bb83d7db573b753ce63cc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..d2b7a749a57c52a1adb1e37dd2d24315c6e635ae --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/demo-parent.iml b/demo-parent.iml new file mode 100644 index 0000000000000000000000000000000000000000..8cffef8f8c4301df1a8a7a3f088e426b49ce1220 --- /dev/null +++ b/demo-parent.iml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kafka/kafka.iml b/kafka/kafka.iml new file mode 100644 index 0000000000000000000000000000000000000000..85ab1e7569283dbd96f1ec46a2719b900479c0e8 --- /dev/null +++ b/kafka/kafka.iml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/consumer/TestConsumer.java b/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/consumer/TestConsumer.java index 8c92b45ed3dcbc05f823850b6209fc5c8177be01..0459282455f46d3ca800e6163d8ae9df464cc1e9 100644 --- a/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/consumer/TestConsumer.java +++ b/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/consumer/TestConsumer.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; * @author fengyuchenglun * @version 1.0.0 */ -//@Component +@Component public class TestConsumer { /** @@ -19,7 +19,7 @@ public class TestConsumer { * @param record the record * @throws Exception the exception */ - @KafkaListener(topics = "topic_first") + @KafkaListener(topics = "topic_second") public void listen(ConsumerRecord record) throws Exception { System.out.printf("topic = %s, offset = %d, value = %s \n", record.topic(), record.offset(), record.value()); } diff --git a/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/listener/AppListener.java b/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/listener/AppListener.java index f92353de94fd6d6eb60829ae81df82138f9dee6e..fee2774b1152311fd8e99bb6f986f03a61a936d5 100644 --- a/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/listener/AppListener.java +++ b/kafka/src/main/java/com/duanledexianxianxian/demo/kafka/listener/AppListener.java @@ -46,7 +46,7 @@ public class AppListener implements ApplicationListener { }); try { - Thread.sleep(5000); + Thread.sleep(new Random().nextInt(6) * 1000); } catch (InterruptedException e) { e.printStackTrace(); } @@ -56,8 +56,8 @@ public class AppListener implements ApplicationListener { private void sendData(int i) { Student student = new Student(); - student.setStudentId("duanledexianxianxian" + i); - student.setName(RandomStringUtils.randomAlphabetic(10)); + student.setStudentId(String.valueOf(i)); + student.setName("duanledexianxianxian" + new Random().nextInt(20)); student.setAge(new Random().nextInt(19) + 6); student.setSex(Byte.valueOf(String.valueOf((new Random().nextInt(2))))); log.info("Thread:{} Send Data:{}", Thread.currentThread().getName(), student);