Skip to content

Commit

Permalink
[type:feat]add kafka logging e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakiuncle committed Jan 19, 2025
1 parent 88c0c20 commit 26ffd1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
networks:
- shenyu
ports:
- "9092:9092"
- "31092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: shenyu-zk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ private ShenYuScenarioSpec testKafkaHello() {
try {
Thread.sleep(1000 * 30);
request.request(Method.GET, "/http/order/findById?id=23");
Properties props = new Properties();
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
StringDeserializer.class.getName());
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
StringDeserializer.class.getName());
props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "shenyu-kafka:9092");
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
Properties properties = new Properties();
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:31092"); // Kafka 服务器地址
properties.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); // 消费者组ID
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties);
consumer.subscribe(Arrays.asList(TOPIC));
Thread.sleep(1000 * 30);
AtomicReference<Boolean> keepCosuming = new AtomicReference<>(true);
Expand Down

0 comments on commit 26ffd1d

Please sign in to comment.