gpt4 book ai didi

java - Spring Integration 2 - Splitter 仅返回第一个元素

转载 作者:太空宇宙 更新时间:2023-11-04 08:16:44 26 4
gpt4 key购买 nike

我正在使用 Spring Integration 2。我有以下场景。一个“MassMessageObject”,由正文字段和收件人列表组成。我正在实现一个拆分器来为列表中的每个收件人创建一个“BasicMessageObject”。问题是分离器的输出 channel 只接收到第一条消息。例如:

MassMessageObject> [正文:您好,收件人{A,B}]正在创建 BasicMessageObject 列表{[正文:您好,收件人:A],[正文:您好,收件人:B]}。

连接到输出 channel 的端点正在接收“[body: Hello,recipient: A]”,但未接收“[body: Hello,recipient: B]”。

以下是我的应用程序上下文:

<int:splitter input-channel="mass_receiving_channel"
output-channel="receiving_channel"
method="splitMessages"
ref="massMessageSplitter"/>

<!-- Main Chain. The one that will lead to the messageTypeRouter -->
<int:chain input-channel="receiving_channel" output-channel="sms_channel">
<int:service-activator ref="saveMessageToDB" method="saveMessageToDB"/>
<int:gateway request-channel="message_type_router_channel"/>
</int:chain>

下面是分割器...

public List<BasicMessageObject> splitMessages(final GenericMessage message) {
List<BasicMessageObject> messages = new ArrayList<BasicMessageObject>();
// DOING STUFF HERE
return messages;
}
}





[springframework.integration.jms.ChannelPublishingJmsMessageListener:234] - converted JMS Message [ActiveMQObjectMessage {commandId = 6, responseRequired = true, messageId = ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1, originalDestination = null, originalTransactionId = null, producerId = ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2, destination = queue://mass_messaging_queue, transactionId = null, expiration = 0, timestamp = 1335249128840, arrival = 0, brokerInTime = 1335249128841, brokerOutTime = 1335249128842, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@39673d71, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false}] to integration Message payload [com.connexo.icubeplus3.dispatcher.connector.messageobjects.SmsMassMessageObject@28f2e328]
[springframework.integration.channel.DirectChannel:224] - preSend on channel 'mass_receiving_channel', message: [Payload=com.connexo.icubeplus3.dispatcher.connector.messageobjects.SmsMassMessageObject@28f2e328][Headers={timestamp=1335249128882, id=fb9904da-f5b1-49e0-af25-6711015f1365, jms_redelivered=false, jms_messageId=ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1}]
[springframework.integration.splitter.MethodInvokingSplitter:72] - org.springframework.integration.splitter.MethodInvokingSplitter@56de9984 received message: [Payload=com.connexo.icubeplus3.dispatcher.connector.messageobjects.SmsMassMessageObject@28f2e328][Headers={timestamp=1335249128882, id=fb9904da-f5b1-49e0-af25-6711015f1365, jms_redelivered=false, jms_messageId=ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1}]
[springframework.integration.splitter.MethodInvokingSplitter:157] - handler 'org.springframework.integration.splitter.MethodInvokingSplitter@56de9984' sending reply Message: [Payload=[SMS] [sender: icube+] [destination: +35611111111] [messageIdentifier: 1234] [clientId: 1]][Headers={timestamp=1335249137537, id=566d7d54-f4cc-4896-8d39-d95636c20a57, correlationId=fb9904da-f5b1-49e0-af25-6711015f1365, jms_redelivered=false, sequenceSize=4, sequenceNumber=1, jms_messageId=ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1}]
[springframework.integration.channel.DirectChannel:224] - preSend on channel 'receiving_channel', message: [Payload=[SMS] [sender: icube+] [destination: +35611111111] [messageIdentifier: 1234] clientId: 1]][Headers={timestamp=1335249137537, id=566d7d54-f4cc-4896-8d39-d95636c20a57, correlationId=fb9904da-f5b1-49e0-af25-6711015f1365, jms_redelivered=false, sequenceSize=4, sequenceNumber=1, jms_messageId=ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1}]
[springframework.integration.handler.MessageHandlerChain:72] - org.springframework.integration.handler.MessageHandlerChain#0 received message: [Payload=[SMS] [sender: icube+] [destination: +35611111111] [messageIdentifier: 1234] [clientId: 1]][Headers={timestamp=1335249137537, id=566d7d54-f4cc-4896-8d39-d95636c20a57, correlationId=fb9904da-f5b1-49e0-af25-6711015f1365, jms_redelivered=false, sequenceSize=4, sequenceNumber=1, jms_messageId=ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1}]
[springframework.integration.handler.ServiceActivatingHandler:72] - ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@27b71c12] received message: [Payload=[SMS] [sender: icube+] [destination: +35611111111] [messageIdentifier: 1234] [clientId: 1]][Headers={timestamp=1335249137537, id=566d7d54-f4cc-4896-8d39-d95636c20a57, correlationId=fb9904da-f5b1-49e0-af25-6711015f1365, jms_redelivered=false, sequenceSize=4, sequenceNumber=1, jms_messageId=ID:PC-CMICALLEF-61953-1335249128607-0:0:1:2:1}] ....

最佳答案

我也遇到了同样的问题。将任务执行器添加到拆分器的传出 channel 使 Spring 能够传递来自拆分器的所有消息:

<splitter input-channel="incoming-splitter" output-channel="outgoing-splitter"/>

<channel id="outgoing-splitter">
<dispatcher task-executor="taskExecutor"/>
</channel>

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<!-- Use 1 for sequential processing -->
<property name="corePoolSize" value="1"/>
<property name="maxPoolSize" value="1"/>
<property name="threadNamePrefix" value="Splitter Message Handler "/>
<property name="waitForTasksToCompleteOnShutdown" value="true"/>
</bean>

关于java - Spring Integration 2 - Splitter 仅返回第一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10283677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com