日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring集成–第1节– Hello World

發布時間:2023/12/3 javascript 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring集成–第1节– Hello World 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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 {@Autowired@Qualifier("messageChannel")MessageChannel messageChannel;@Testpublic void testHelloWorld() {Message<String> helloWorld = new GenericMessage<String>("Hello World");messageChannel.send(helloWorld);} }

在這里,一個MessageChannel被連接到測試中,第一個應用程序(這里是Junit),向Message Channel發送一條Message(在這種情況下為字符串“ Hello World”),然后從“ Message Channel”中讀取消息并寫入將消息發送給系統。

現在,讓我們看一下“某物”如何從消息通道中提取消息并將其寫到系統的其余部分:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:int="http://www.springframework.org/schema/integration"xmlns:int-stream="http://www.springframework.org/schema/integration/stream"xsi:schemaLocation="http://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.xsd"><int:channel id="messageChannel"></int:channel><int-stream:stdout-channel-adapter channel="messageChannel" append-newline="true"/></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提供的Spring,Spring Integration,Enterprise Development 。


翻譯自: https://www.javacodegeeks.com/2012/07/spring-integration-session-1-hello.html

總結

以上是生活随笔為你收集整理的Spring集成–第1节– Hello World的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。