我正在使用Spring Integration 2.我有以下场景。 'MassMessageObject',由正文字段和收件人列表组成。我正在实现一个拆分器,为列表中的每个收件人创建一个“BasicMessageObject”。问题是分路器的输出通道只接收到第一条消息。例如:
MassMessageObject> [正文:您好,收件人{A,B}] 正在创建BasicMessageObject的List {[正文:你好,收件人:A],[正文:你好,收件人:B]}。
连接到输出通道的端点正在接收'[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}] ....
答案 0 :(得分:1)
我有同样的问题。将任务执行程序添加到拆分器的传出通道使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>