0

我的系统管道为“IBM MQ 队列--> Springboot 应用程序(消息格式化程序)--> Kafka topic-1(消息队列)--> Springboot 应用程序(消息转换器)--> --> Kafka topic-2(消息队列)”。

我的要求是测试在 IBM MQ 中生成并通过管道处理的消息的端到端处理时间。我有一个带有 JMS 客户端的 JMeter 负载测试脚本,它生成大量通过管道泵送的消息。Dynatrace Kafka 监控尚未实现,但这里使用了 Confluent Control Center for Kafka 监控。

您能否建议可能的选项来衡量 Springboot 应用程序(通过 DevOps Jenkins 管道部署的消息格式化程序和消息转换器应用程序)处理的消息的单个和端到端处理时间?

4

1 回答 1

1

从理论上讲,您可以使用JSR223 Test Elements中的Kafka Client Consumer代码从JMeter 本身获取 Kafka 主题中未决消息的数量

示例代码:

KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
consumer.subscribe(Collections.singletonList("test"));
while(true) {
    ConsumerRecords<String, String> records = consumer.poll(100);
    for (ConsumerRecord<String, String> record : records) {
        System.out.printf("offset = %d, key = %s, value = %s%n", record.offset(), record.key(), record.value());

        // after each message, query the number of messages of the topic
        Set<TopicPartition> partitions = consumer.assignment();
        Map<TopicPartition, Long> offsets = consumer.endOffsets(partitions);
        for(TopicPartition partition : offsets.keySet()) {
            System.out.printf("partition %s is at %d\n", partition.topic(), offsets.get(partition));
        }
    }
}

这些值可以使用速记存储到示例变量中,并作为自定义图表绘制到JMeter HTML 报告仪表板中。vars

于 2019-11-26T08:53:23.560 回答