简体   繁体   English

Spring Cloud Task Launcher 不响应发送到 Rabbit 的新事件

[英]Spring Cloud Task Launcher doesn't respond to new events sent to Rabbit

I'm trying to setup a very basic Spring Cloud Task example but I'm having a problem with the Task Launcher not receiving the events (I think).我正在尝试设置一个非常基本的 Spring Cloud Task 示例,但是我遇到了 Task Launcher 没有接收到事件的问题(我认为)。

Using the most basic sample to send events:使用最基本的示例发送事件:

@RestController
@EnableBinding(Source.class)
@SpringBootApplication
@RequiredArgsConstructor
public class Application {

  private final Source source;

  public static void main(final String[] args) {
    SpringApplication.run(Application.class, args);
  }

  @RequestMapping(path = "/task", method = RequestMethod.GET)
  public void sendRequest() {

    final TaskLaunchRequest request =
        new TaskLaunchRequest(
            "maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE",
            null,
            null,
            null,
            null);

    final GenericMessage<TaskLaunchRequest> genericMessage = new GenericMessage<>(request);

    this.source.output().send(genericMessage);
  }
}

I can confirm this does send the TaskLunchRequest to Rabbit as expected.我可以确认这确实按预期将TaskLunchRequest发送到 Rabbit。

However using an equally simple example on the other end yields no results但是,在另一端使用同样简单的示例不会产生任何结果

@EnableTaskLauncher
@SpringBootApplication
public class Application {

  public static void main(final String[] args) {
    SpringApplication.run(Application.class, args);
  }
}

And the dependencies:以及依赖项:

implementation 'org.springframework.cloud:spring-cloud-starter-task'
implementation 'org.springframework.cloud:spring-cloud-starter-stream-rabbit'
implementation 'org.springframework.cloud:spring-cloud-deployer-local:1.3.7.RELEASE'

I was expecting the @EnableTaskLauncher to go ahead and start a new jar based on the maven url passed in.我期待@EnableTaskLauncher继续并根据传入的 maven url 启动一个新的 jar。

Note the application.properties for both projects are empty.注意两个项目的application.properties都是空的。 I've not defined any channels or anything as none of the sample applications I've looked at have anything specific set either.我没有定义任何通道或任何东西,因为我看过的示例应用程序也没有任何特定的设置。

Is there anything further I need to do to make this work?我还需要做些什么来完成这项工作吗?

Managed to work this out from a large number of blog posts and GitHub samples.设法从大量博客文章和 GitHub 示例中解决了这个问题。

Looks like out the box the TaskLauncher is listening on input and I was obviously sending messages out via output .看起来TaskLauncher正在侦听input而我显然是通过output发送消息。

A solution is to define both channels in your configuration as such一个解决方案是在您的配置中定义两个通道

spring:
  cloud:
    stream:
      bindings:
        output:
          destination: task-launcher

And on the other side而在另一边

spring:
  cloud:
    stream:
      bindings:
        input:
          destination: task-launcher

Note the difference between output and input.注意输出和输入之间的区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM