Consumer Aware 调用消费者线程安全

Consumer Aware call on consumer thread safety

我正在查看 spring kafka 文档,我有点困惑的是一句话:

The Consumer object is not thread-safe. You must only invoke its methods on the thread that calls the listener.

我在 Consumer 对象上使用此方法的唯一方法是在用 KafkaListener 注释的方法中。如果我调用那个方法,它会是线程安全的吗?那么有人可以解释一下这句话吗?

是;只要您在调用线程上调用它,它就是安全的;这是安全的:

@KafkaListener(topics = "foo")
public void listen(String in, Consumer<?, ?> consumer) {
    ...
    executor.execute(() -> consumer.seek(...));
    ...
}