聚合器 - 将数组发布的对象转换为 JMS 文本消息

Aggregator - Convert Array Released Object to JMS Text Message

问题: spring 集成聚合器将聚合消息发布为数组列表。我如何将聚合响应作为单个 jms 消息发送?需要先用变压器吗?

聚合器:

<aggregator 
id="myAgg" 
input-channel="jmsInChannel"
output-channel="outputChannel" 
discard-channel="discardChannel"
ref="myAggBean" 
method="combineRespones"
expire-groups-upon-completion="true"
correlation-strategy-expression="#xpath(payload, '/test/name')"
release-strategy="myAggBean"
release-strategy-method="canRelease"
send-partial-result-on-expiry="false"
send-timeout="5000"
group-timeout="20000"/>

输出通道:

    <channel id="outputChannel">
    <int:queue/>
</channel>

出站适配器:

    <jms:outbound-channel-adapter channel="outputChannel"
    id="jmsOut"
    destination="outboundQueue"/>

更新 1:- 最初这个 post 有以下错误,但这是由于我的配置将消息发布到错误的队列。

错误: 原因:org.springframework.messaging.MessagingException:不支持的负载类型 [java.util.ArrayList]

你的问题不清楚

  • 如果您希望将发布的消息作为单独的文本消息发送到 JMS,请在聚合器和出站通道适配器之间添加 <splitter/>
  • 如果您希望列表作为一条消息发送,您将需要某种类型的转换器来按照您想要的方式格式化它。