即使Kakfa发生故障,应用程序也会启动

时间:2019-12-19 08:04:32

标签: spring-cloud-stream spring-cloud-sleuth

我一直在研究春季云搜索,以将迹线推至zipkin,我们正在spring-cloud-starter-stream-kafkaspring-cloud-sleuth-stream的帮助下将迹线推至Kafka

以下是我添加到应用程序中的依赖项

compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-sleuth', version: '1.0.0.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-sleuth-stream', version: '1.2.4.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-stream-kafka', version: '1.2.0.RELEASE'

我的应用程序属性中只有kafka代理,默认情况下,它会将跟踪信息推送到sleuth主题spring.cloud.stream.kafka.binder.brokers=locahost:9092

到目前为止,一切都正常运行,但是我无法确定如果Kafka出现故障,是否可以启动该应用程序?

从日志中我看到应用程序已启动,但是由于它将无法连接到kafka,我们将无法访问任何端点(在下面添加了一些日志)。正在寻找此解决方案,因为推送跟踪不是我的应用程序的主要功能。

Started testApp in 0.299 seconds (JVM running for 20.241)
[WARN] 2019-12-19 13:27:56,183 main org.apache.kafka.clients.producer.ProducerConfig - {} - The configuration 'key.deserializer' was supplied but isn't a known config.
[WARN] 2019-12-19 13:27:56,183 main org.apache.kafka.clients.producer.ProducerConfig - {} - The configuration 'value.deserializer' was supplied but isn't a known config.
[INFO] 2019-12-19 13:27:56,184 main org.apache.kafka.common.utils.AppInfoParser - {} - Kafka version : 0.11.0.0
[INFO] 2019-12-19 13:27:56,184 main org.apache.kafka.common.utils.AppInfoParser - {} - Kafka commitId : cb8625948210849f
[WARN] 2019-12-19 13:27:56,225 kafka-producer-network-thread | producer-1 org.apache.kafka.clients.NetworkClient - {} - Connection to node -1 could not be established. Broker may not be available.
[WARN] 2019-12-19 13:27:56,335 kafka-producer-network-thread | producer-1 org.apache.kafka.clients.NetworkClient - {} - Connection to node -1 could not be established. Broker may not be available.
[WARN] 2019-12-19 13:27:56,390 kafka-producer-network-thread | producer-1 org.apache.kafka.clients.NetworkClient - {} - Connection to node -1 could not be established. Broker may not be available.

1 个答案:

答案 0 :(得分:1)

您的版本是错误的。请不要自己设置版本,请使用如下所示的Spring Cloud BOM(spring-cloud-dependencies)依赖性管理

<?php

if(isset($_GET['act']) && $_GET['act'] == 'login' && isset($_GET['email']) && isset($_GET['password']) ){
        $result_of_login_check = db_query("SELECT * FROM members WHERE email = '$email' AND password = '$password'");

        if (mysqli_num_rows($result_of_login_check) == 1) {

            $result_row = mysqli_fetch_assoc($result_of_login_check);

            $user_id = $result_row['ID'];

            $_SESSION["user"] = $user_id;

            header("Location:/profile");
        }
}

此外-添加启动器就足够了。您已经在给定的版本中添加了一个启动器,然后又在另一个版本中添加了核心依赖项,这没有任何意义。

最后一点-版本1.x已弃用,不再维护。当前版本是2.2.0.RELEASE,发行火车版本是Hoxton.RELEASE