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

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

我正在尝试设置一个非常基本的 Spring Cloud Task 示例,但我遇到了一个问题,任务启动器没有接收到事件(我认为)。

使用最基本的示例发送事件:

@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);
  }
}

我可以确认这确实按预期将 TaskLunchRequest 发送给了 Rabbit。

然而,在另一端使用同样简单的示例不会产生任何结果

@EnableTaskLauncher
@SpringBootApplication
public class Application {

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

以及依赖项:

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'

我期待 @EnableTaskLauncher 继续并根据传入的 maven url 启动一个新的 jar。

请注意,两个项目的 application.properties 都是空的。我没有定义任何通道或任何东西,因为我看过的示例应用程序的 none 也有任何特定的设置。

我还需要做些什么来完成这项工作吗?

设法从大量博客文章和 GitHub 示例中解决了这个问题。

看起来开箱即用 TaskLauncher 正在监听 input,我显然是通过 output 发送消息。

一个解决方案是在您的配置中定义两个通道

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

另一边

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

注意输出和输入的区别。