【问题标题】:Spring Cloud Stream and GCP pub sub as binder getting stuckSpring Cloud Stream 和 GCP pub sub 作为 binder 卡住
【发布时间】:2019-07-08 20:25:37
【问题描述】:

我尝试在这里运行示例 https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-pubsub-binder-sample 我期待它在我的默认项目上创建一个主题。 Tomcat 服务已启动,但甚至没有加载 index.html 页面(应该有一条消息,如“Tomcat 在端口上启动:8080 (http) with context path ''”),所以它似乎卡住了,并且它发生在我添加后:

@Autowired
private Source source;

这是日志

2019-02-14 12:06:54.305  INFO 3560 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication on 2019-02-14 12:06:54.309  INFO 3560 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2019-02-14 12:06:55.362  INFO 3560 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be 
(http)
2019-02-14 12:06:56.246  INFO 3560 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-02-14 12:06:56.247  INFO 3560 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-02-14 12:06:56.257  INFO 3560 --- [           main] 2019-02-14 12:06:56.385  INFO 3560 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-02-14 12:06:56.385  INFO 3560 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2027 ms
2019-02-14 12:06:56.970  INFO 3560 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-02-14 12:06:57.079  INFO 3560 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2019-02-14 12:06:57.253  WARN 3560 --- [           main] c.g.a.oauth2.DefaultCredentialsProvider  : Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/.
2019-02-14 12:06:57.383  INFO 3560 --- [           main] o.s.c.g.a.c.GcpContextAutoConfiguration  : The default project ID is xxxxxx-xxxxx
2019-02-14 12:06:58.373  INFO 3560 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel nullChannel
2019-02-14 12:06:58.395  INFO 3560 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel output
2019-02-14 12:06:58.455  INFO 3560 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel errorChannel
2019-02-14 12:06:58.492  INFO 3560 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageHandler errorLogger
2019-02-14 12:06:58.525  INFO 3560 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2019-02-14 12:06:58.525  INFO 3560 --- [           main] o.s.i.channel.PublishSubscribeChannel    : Channel 'application.errorChannel' has 1 subscriber(s).
2019-02-14 12:06:58.525  INFO 3560 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : started _org.springframework.integration.errorLogger

会发生什么??

【问题讨论】:

    标签: spring-cloud-stream


    【解决方案1】:

    您是否在您的application.properties 中定义了spring.cloud.stream.bindings.input.destination? 如果未配置任何主题,活页夹将为您的主题创建匿名订阅,但它不会自行创建主题。

    【讨论】:

    • 我做了... spring.cloud.stream.bindings.input.destination=input spring.cloud.stream.bindings.output.destination=input spring.cloud.stream.bindings.input.group =输入子
    • 其实我错了,主题不是自动创建的;如果不存在,活页夹会创建一个主题。您能否检查一下您的 GCP 项目中是否创建了主题“input”和订阅“input.input-sub”?
    • 您还可以尝试使用额外的 Spring Boot 日志记录运行示例,以查看 PubSubBinderConfiguration 是否匹配:-Dlogging.level.org.springframework.boot.autoconfigure.logging=DEBUG
    • 实际上,从 pub/sub 的本质退一步,你是在代理后面吗?启动 errorLogger 是代码尝试连接到 pubsub.googleapis.com 之前发生的最后一件事。
    • 我已经使用 gcp 库(没有 Spring)实现了一个生产者并且它工作了......这就是我得到的额外日志记录 PubSubBinderConfiguration 匹配:-@ConditionalOnMissingBean(类型:org.springframework .cloud.stream.binder.Binder; SearchStrategy: all) 没有找到任何bean (OnBeanCondition)
    【解决方案2】:

    这是一个权限问题。 GOOGLE_APPLICATION_CREDENTIALS 环境设置不正确。

    【讨论】:

      猜你喜欢
      • 2019-07-07
      • 2022-01-13
      • 2019-07-03
      • 2020-08-21
      • 1970-01-01
      • 2019-04-19
      • 2018-12-16
      • 1970-01-01
      • 2019-11-03
      相关资源
      最近更新 更多