php网站服务器配置,it培训教育机构,ftp上传php网站,广告公司简介宣传册Spring Integration为集成系统所涉及的某些复杂性提供了非常好的抽象-Spring Integration从Integration的角度来看非常适合Facade的定义-简化了对复杂底层系统的访问。 为了说明这一点#xff0c;请考虑一个简单的系统#xff0c;该系统仅接收一条消息#xff0c;然后将其发… Spring Integration为集成系统所涉及的某些复杂性提供了非常好的抽象-Spring Integration从Integration的角度来看非常适合Facade的定义-简化了对复杂底层系统的访问。 为了说明这一点请考虑一个简单的系统该系统仅接收一条消息然后将其发送回大写称其为Echo网关 public interface EchoGateway { String echo(String message);
} 并为此进行测试 Testpublic void testEcho() {String response echoGateway.echo(Hello);assertThat(response, is(HELLO));} 到目前为止听起来很简单使用spring集成的实现将通过转换为大写字母并返回增强后的消息来接受“消息”并对其进行“转换”。 ?xml version1.0 encodingUTF-8?
beans:beans xmlnshttp://www.springframework.org/schema/integrationxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:beanshttp://www.springframework.org/schema/beansxsi:schemaLocationhttp://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdchannel idrequestChannel/gateway idechoGateway service-interfacerube.simple.EchoGateway default-request-channelrequestChannel /transformer input-channelrequestChannel expressionpayload.toUpperCase() / /beans:beans 做工精美 Spring Integration的优点在于即使Integration场景变得复杂它呈现给应用程序的外观仍然保持简单 考虑一个Rube Goldberg集成方案 首先是描述旋流的图表 那么它到底是做什么的 它接收到这样的消息“来自Spring整合的你好” 将其拆分为单个单词您好来自springintegeg 将每个单词发送到ActiveMQ队列 从队列中单词片段由浓缩器拾取以大写每个单词 将响应放回响应队列 根据单词的原始顺序对其进行重新排序 聚合成一个句子“ HELLO FROM SPRING INTEG” 返回到应用程序。 这是这种流程的Spring Integration配置的样子 ?xml version1.0 encodingUTF-8?
beans:beans xmlnshttp://www.springframework.org/schema/integrationxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:int-jmshttp://www.springframework.org/schema/integration/jmsxmlns:beanshttp://www.springframework.org/schema/beansxsi:schemaLocationhttp://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsdhttp://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsdhttp://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.1.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdbeans:import resourcebroker.xml/channel idrequestChannelqueue/ /channelchannel idresponseChannelqueue//channelgateway idechoGateway service-interfacerube.complicated.EchoGateway default-request-channelrequestChannel default-reply-channelresponseChannel default-reply-timeout5000 /channel idtoJmsOutbound/splitter input-channelrequestChannel output-channeltoJmsOutbound expressionpayload.split(\s)/splitterchannel idsequenceChannel/channelint-jms:outbound-gateway request-channeltoJmsOutbound reply-channelsequenceChannel request-destinationamq.outbound extract-request-payloadtrue /channel idenhanceMessageChannel/channel idtoReplyQueueChannel/int-jms:inbound-gateway request-channelenhanceMessageChannel request-destinationamq.outbound reply-channeltoReplyQueueChannel/transformer input-channelenhanceMessageChannel expression(payload ).toUpperCase() output-channeltoReplyQueueChannel/resequencer input-channelsequenceChannel output-channelaggregateChannel release-partial-sequencesfalse/resequenceraggregator input-channelaggregateChannel output-channelresponseChannel expressionT(com.google.common.base.Joiner).on( ).join(![payload].toArray())/poller idpoller fixed-delay500 defaulttrue//beans:beans 这个流程有太多的复杂性因此Rube Goldberg但是Spring Integration提供给应用程序的外观仍然非常简单。 Testpublic void testEcho() throws Exception{String amessage Hello from Spring Integration;String response echoGateway.echo(amessage);assertThat(response, is(HELLO FROM SPRING INTEGRATION));} 我认为这是Spring Integration的本质 我在https://github.com/bijukunjummen/rg-si.git上有此代码的github存储库 参考 all和其他博客中的Rube Goldberg Spring Integration来自我们的JCG合作伙伴 Biju Kunjummen。 翻译自: https://www.javacodegeeks.com/2012/06/rube-goldberg-spring-integration_22.html