做外贸哪个网站好,哪个网站做新中式,网络营销有几种方式,wordpress动静分离oss代码Spring Integration的“ Hello World ” –考虑一个简单的程序#xff0c;以使用Spring Integration将“ Hello World”打印到控制台#xff0c;并在此过程中访问一些企业集成模式概念 在进入程序本身之前#xff0c;快速回顾一下消息传递概念将很有用–消息传递是一种集成样… Spring Integration的“ Hello World ” –考虑一个简单的程序以使用Spring Integration将“ Hello World”打印到控制台并在此过程中访问一些企业集成模式概念 在进入程序本身之前快速回顾一下消息传递概念将很有用–消息传递是一种集成样式其中两个独立的应用程序通过中介相互通信–中介被称为“消息传递系统”。 企业集成模式描述了基于消息的应用程序集成中常见的与集成相关的问题及其推荐的解决方案。 例如。 考虑企业集成模式之一– 消息通道 引用《 企业集成模式》一书 “消息传递频道”正在尝试解决的问题是 企业具有两个需要进行通信的独立应用程序最好使用消息传递进行通信。 一个应用程序如何通过消息传递与另一应用程序通信 解决方案是 使用消息通道连接应用程序其中一个应用程序将信息写入该通道而另一个应用程序从该通道读取该信息。 所有其他企业集成模式均以相同的方式描述。 快速访问Enterprise Integration Patterns的原因是要设置上下文– Spring Integration与Enterprise Integration Patterns非常紧密地结合在一起并且是前面提到的“消息系统”。 现在来看使用Spring Integration的Hello World 首先是一个小的junit RunWith(SpringJUnit4ClassRunner.class)
ContextConfiguration(helloworld.xml)
public class HelloWorldTest {AutowiredQualifier(messageChannel)MessageChannel messageChannel;Testpublic void testHelloWorld() {MessageString helloWorld new GenericMessageString(Hello World);messageChannel.send(helloWorld);}
} 在这里一个MessageChannel被连接到测试中第一个应用程序这里是Junit向Message Channel发送一条Message在这种情况下为字符串“ Hello World”然后从“ Message Channel”中读取消息并写入将消息发送给系统。 现在让我们看一下“某物”如何从消息通道中提取消息并将其写到系统的其余部分 ?xml version1.0 encodingUTF-8?
beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:inthttp://www.springframework.org/schema/integrationxmlns:int-streamhttp://www.springframework.org/schema/integration/streamxsi:schemaLocationhttp://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsdhttp://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-2.1.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdint:channel idmessageChannel/int:channelint-stream:stdout-channel-adapter channelmessageChannel append-newlinetrue//beans 上面是使用Spring Custom名称空间这里是Integration命名空间描述的Spring Integration流。 创建了一个“消息通道”即想象中的“消息通道”将“ Hello World”“消息”放入“消息通道”“通道适配器”从中获取消息并将其打印到标准输出中。 这是一个小程序但是它使用了三种企业集成模式- 消息 “ Hello World”它是发送到消息传递系统的信息包是先前介绍的“ 消息通道 ”而新的是消息传递。 Channel Adapter 这里是一个出站通道适配器用于将消息传递系统连接到应用程序在本例中为系统输出进一步显示了Spring Integration如何与带有其Spring自定义名称空间的Enterprise Integration Patterns术语保持紧密的一致。 这个简单的程序介绍了Spring Integration在接下来的几节课中我将使用更多示例来更详细地介绍Spring Integration。 参考文献 1. Spring Integration参考 http //static.springsource.org/spring-integration/reference/htmlsingle/ 2.企业集成模式 http : //www.eaipatterns.com/index.html 3. EIP的Visio模板 http //www.eaipatterns.com/downloads.html 参考 all和其他博客中的JCG合作伙伴 Biju Kunjummen提供的SpringSpring IntegrationEnterprise Development 。 翻译自: https://www.javacodegeeks.com/2012/07/spring-integration-session-1-hello.html