Я пишу крайний случай, чтобы узнать, работает ли сервер kafka или нет, поэтому я написал планировщик
@Service
@AllArgsConstructor
public class KafkaConnectionVerificationScheduler {
private KafkaMessageDrivenChannelAdapter kafkaMessageDrivenChannelAdapter;
@Scheduled(fixedDelayString = "${check.kafka.connectivity}")
public void verifyIfKafkaServerIsRunning() throws IOException {
if (!kafkaMessageDrivenChannelAdapter.isRunning()) {
//Kafka server is not running, so flag it and stop all request to start new connection
}
}
}
Но когда я запускаю сервер, я получаю сообщение об ошибке:
Description:
Parameter 0 of constructor in com.betstars.betsyncadapter.app.service.scheduler.KafkaConnectionVerificationScheduler required a bean of type 'org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter' in your configuration.
Мой pom.xml:
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-kafka</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
Другие мои библиотеки:
kumarman$ mvn dependency:tree | grep spring
[INFO] +- org.springframework.kafka:spring-kafka:jar:1.1.6.RELEASE:compile
[INFO] | +- org.springframework:spring-messaging:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework.retry:spring-retry:jar:1.2.1.RELEASE:compile
[INFO] +- org.springframework.kafka:spring-kafka-test:jar:1.1.6.RELEASE:test
[INFO] | +- org.springframework:spring-beans:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:4.3.11.RELEASE:test
[INFO] +- org.springframework.integration:spring-integration-core:jar:4.3.12.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.11.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:4.3.11.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.3.11.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-websocket:jar:1.5.7.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.7.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.5.7.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.7.RELEASE:compile
[INFO] | | \- org.springframework.boot:spring-boot-starter-logging:jar:1.5.7.RELEASE:compile
[INFO] | \- org.springframework:spring-websocket:jar:4.3.11.RELEASE:compile
[INFO] +- org.springframework.integration:spring-integration-kafka:jar:2.3.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-cache:jar:1.5.7.RELEASE:compile
[INFO] | \- org.springframework:spring-context-support:jar:4.3.11.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.7.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.7.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.7.RELEASE:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.7.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.13.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.3.11.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.11.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.5.7.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.7.RELEASE:compile
[INFO] | +- org.springframework:spring-web:jar:4.3.11.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.3.11.RELEASE:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.7.0:compile
[INFO] | \- io.springfox:springfox-spring-web:jar:2.7.0:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.7.0:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.7.0:compile
[INFO] | | \- io.springfox:springfox-core:jar:2.7.0:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.7.0:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.7.0:compile
[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.7.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.7.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.7.RELEASE:test
[INFO] +- org.springframework.cloud:spring-cloud-starter-zipkin:jar:1.3.3.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-starter-sleuth:jar:1.3.3.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-starter:jar:1.3.3.RELEASE:compile
[INFO] | | | +- org.springframework.cloud:spring-cloud-context:jar:1.3.3.RELEASE:compile
[INFO] | | | \- org.springframework.security:spring-security-rsa:jar:1.0.3.RELEASE:compile
[INFO] | | \- org.springframework.cloud:spring-cloud-sleuth-core:jar:1.3.3.RELEASE:compile
[INFO] | \- org.springframework.cloud:spring-cloud-sleuth-zipkin:jar:1.3.3.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-commons:jar:1.3.3.RELEASE:compile
[INFO] | | +- org.springframework.security:spring-security-crypto:jar:4.2.3.RELEASE:compile
[INFO] \- io.prometheus:simpleclient_spring_boot:jar:0.0.18:compile
[
Сервер успешно запущен после замены KafkaMessageDrivenChannelAdapter на KafkaListenerEndpointRegistry, но kafkaListenerEndpointRegistry.isR.всегда ложное, даже если сервер работает, и мы можем отправить сообщение.