我正在使用spring-kafka,如果我不设置ConcurrentKafkaListenerContainerFactory的并发,一切正常,当我将它设置为大于1的数字时,我得到一个异常:
javax.management.InstanceAlreadyExistsException: kafka.consumer:type=app-info,id=client-3
我的配置:
@Bean
public ConcurrentKafkaListenerContainerFactory<String, String>
kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory = new
ConcurrentKafkaListenerContainerFactory<String, String>();
factory.setConcurrency(kafkaConfig.getConcurrency());
factory.getContainerProperties().setAckMode(AckMode.MANUAL);
factory.setConsumerFactory(consumerFactory());
return factory;
}
特性:
kafka.enable-auto-commit=false
kafka.client-id=client-1
kafka.concurrency=2