【问题标题】:Task executor not stopping任务执行器没有停止
【发布时间】:2017-08-09 08:07:40
【问题描述】:

在我的代码:spring-integration 中,有一个分散收集通道,分散通道使用任务执行器并行调用两个微服务并在收集通道中收集响应。我使用记录器通道在分散收集通道中记录请求响应。我可以看到两个服务的响应来收集频道,但卡在那里而不是下一个频道。我怀疑收集通道的发布策略可能不起作用,但如果我不使用线程(任务执行器),同样的工作。提出一些建议。谢谢。

【问题讨论】:

  • 如果有一些简单的代码可以在我们这边播放会很棒。听起来与 Scatter-Gather 无关,但您在 scatter 阶段以某种方式丢失了相关标头。

标签: multithreading parallel-processing spring-integration threadpoolexecutor


【解决方案1】:

我认为您在一些持久消息存储之间存在,因此在消息序列化期间删除了 replyChannel 标头。

我建议您使用<header-enricher>header-channels-to-string 选项将replyChannel 转换为字符串表示形式。

同时,您可以在 Scatter-Gather 中就该问题提出 JIRA。我们可以将字符串转换作为开箱即用的功能,就像现在 gatherResultChannel 一样:

PollableChannel gatherResultChannel = new QueueChannel();

Object gatherResultChannelName = this.replyChannelRegistry.channelToChannelName(gatherResultChannel);

Message<?> scatterMessage = getMessageBuilderFactory()
            .fromMessage(requestMessage)
            .setHeader(GATHER_RESULT_CHANNEL, gatherResultChannelName)
            .setReplyChannel(this.gatherChannel)
            .build();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-12
    • 2019-02-24
    • 1970-01-01
    • 2012-03-28
    相关资源
    最近更新 更多