简体   繁体   English

使用 Websphere 的 Spring 集成聚合示例

[英]Spring Integration Aggregation Example with Websphere

Issue: Stream input only works for 1 input sending to the aggregator for the output-channel 'out'.问题:流输入仅适用于发送到输出通道“out”的聚合器的 1 个输入。 Subsequent messages only go to the discard-channel 'logLateArrivers'.后续消息仅发送到丢弃通道“logLateArrivers”。 What condition is being used to send to the discard-channel?使用什么条件发送到丢弃通道?

Description: Trying to port the Spring integration example for basic jms using a aggegator using WebSphere.描述:尝试使用 WebSphere 使用聚合器移植基本 jms 的 Spring 集成示例。

UPDATE: - Turning on debug shows that the poller is working.更新: - 打开调试显示轮询器正在工作。 Messages are pulled and put to the MQ and the response is picked up.消息被拉取并放入 MQ 并接收响应。 However for the MQ scenario after the first set of messages, the AggregatingMessageHandler is not used.但是对于第一组消息之后的 MQ 场景,不使用 AggregatingMessageHandler。 Messages are sent to the 'logLateArrivers' adapter on the discard channel vs channel 'out' for output.消息被发送到丢弃通道与通道“输出”上的“logLateArrivers”适配器以进行输出。 I'm re-wording the issue statement to be more specific.我正在重新编写问题声明以使其更加具体。

Spring Integration Example: Spring Integration Github Example Spring 集成示例: Spring 集成 Github 示例

Output using Spring Integration Example:使用 Spring 集成示例的输出:

test1
test2
[TEST1, TEST1]
[TEST2, TEST2]

Output using Spring Integration with Websphere使用 Spring 与 Websphere 集成的输出

test1
test2
[TEST1, TEST2]
[TEST1, TEST2]

Ported Changes using Websphere MQ使用 Websphere MQ 移植更改

  1. common.xml通用文件

    <bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <property name="targetConnectionFactory"> <bean class="com.ibm.mq.jms.MQConnectionFactory"> <property name="channel" value="channelName" /> <property name="hostName" value="host1234" /> <property name="port" value="1111" /> <property name="queueManager" value="testqmgr" /> <property name="transportType" value="1" /> </bean> </property> <property name="sessionCacheSize" value="10"/> </bean> <bean id="requestQueue" class="com.ibm.mq.jms.MQQueue"> <constructor-arg value="requestQueue"/> </bean> <bean id="requestTopic" class="com.ibm.mq.jms.MQTopic"> <constructor-arg value="topic.demo"/> </bean> <bean id="replyQueue" class="com.ibm.mq.jms.MQQueue"> <constructor-arg value="replyQueue"/> </bean> <!-- Poller that is the stream in channel for console input --> <integration:poller id="poller" default="true" fixed-delay="1000"/>

  2. Aggregation.xml聚合.xml

     <int-stream:stdin-channel-adapter id="stdin" channel="stdinToJmsoutChannel"/> <int:channel id="stdinToJmsoutChannel"/> <int:chain input-channel="stdinToJmsoutChannel"> <int:header-enricher> <int:header name="jms_replyTo" ref="replyQueue" /> </int:header-enricher> <int-jms:outbound-channel-adapter destination="requestTopic" /> </int:chain> <int-jms:message-driven-channel-adapter channel="jmsReplyChannel" destination="replyQueue"/> <int:channel id="jmsReplyChannel" /> <int:aggregator input-channel="jmsReplyChannel" output-channel="out" group-timeout="5000" expire-groups-upon-timeout="false" send-partial-result-on-expiry="true" discard-channel="logLateArrivers" correlation-strategy-expression="headers['jms_correlationId']" release-strategy-expression="size() == 2"/> <int:logging-channel-adapter id="logLateArrivers" /> <!-- Subscribers --> <int-jms:inbound-gateway request-channel="upcase" request-destination="requestTopic" /> <int-jms:inbound-gateway request-channel="upcase" request-destination="requestTopic" /> <int:transformer input-channel="upcase" expression="payload.toUpperCase()" /> <!-- Profiles --> <beans profile="default"> <int-stream:stdout-channel-adapter id="out" append-newline="true"/> </beans> <beans profile="testCase"> <int:bridge input-channel="out" output-channel="queueChannel"/> <int:channel id="queueChannel"> <int:queue /> </int:channel> </beans>

The messages should be correlated on jms_correlationId .消息应该在jms_correlationId上相关jms_correlationId Turn on DEBUG logging and compare the message flow between the sample and your version.打开 DEBUG 日志记录并比较示例和您的版本之间的消息流。 Perhaps the correlation id is not being set up correctly.也许相关 ID 设置不正确。

The inbound gateways use this logic...入站网关使用此逻辑...

replyMessage.setJMSCorrelationID(requestMessage.getJMSMessageID());

So the messages associated with each request should get the same jms_correlationId when sent to the aggregator.因此,与每个请求关联的消息在发送到聚合器时应该获得相同的jms_correlationId

Your test indicates that both messages, somehow, have the same message id.您的测试表明这两条消息以某种方式具有相同的消息 ID。

EDIT编辑

Messages arriving with the same correlation id (in this case headers['jms_correlationId'] ) will be discarded (late arrivers), unless expire-groups-upon-completion="true" - which allows a new group to start instead of discarding.到达具有相同相关 id(在这种情况下headers['jms_correlationId'] )的消息将被丢弃(延迟到达),除非expire-groups-upon-completion="true" - 这允许一个新组开始而不是丢弃。 You need to figure out why the second group has the same correlation id as the first.您需要弄清楚为什么第二组与第一组具有相同的相关性 ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM