锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲第一区香蕉_国产a,亚洲av极品无码专区在线观看,亚洲精品日韩专区silk http://m.tkk7.com/paulwong/category/51928.htmlzh-cnFri, 21 Jan 2022 02:24:41 GMTFri, 21 Jan 2022 02:24:41 GMT60SPRING INTEGRATION - 闆嗙兢閫変富銆佸垎甯冨紡閿?/title><link>http://m.tkk7.com/paulwong/archive/2022/01/20/439381.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Thu, 20 Jan 2022 05:49:00 GMT</pubDate><guid>http://m.tkk7.com/paulwong/archive/2022/01/20/439381.html</guid><wfw:comment>http://m.tkk7.com/paulwong/comments/439381.html</wfw:comment><comments>http://m.tkk7.com/paulwong/archive/2022/01/20/439381.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/paulwong/comments/commentRss/439381.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/paulwong/services/trackbacks/439381.html</trackback:ping><description><![CDATA[闆嗙兢閫氬父鏄湁澶氫釜鐩稿悓鐨勫疄渚嬶紝浣嗗浜庡畾鏃朵換鍔″満鏅紝鍙笇鏈涙湁涓涓疄渚嬪伐浣滃嵆鍙紝濡傛灉榪欎釜瀹炰緥鎸備簡錛屽叾浠栧疄渚嬪彲浠ラ《鏇褲?br /><br />榪欎釜闂鐨勬柟妗堝垯鏄泦緹ら変富錛屼竴涓泦緹や腑錛屽彧鏈変竴涓狶EADER錛岀敱LEADER璐熻矗鎵ц瀹氭椂浠誨姟宸ヤ綔銆傚綋LEADER琚彇娑堟椂錛屼細鍦ㄥ墿涓嬬殑瀹炰緥涓啀閫塋EADER銆?br /><br />鎸佹湁鍒嗗竷寮忛攣鐨勫疄渚嬪垯鏄疞EADER銆?br /><br />SPRING INTEGRATION JDBC 鍒欏凡鎻愪緵鐩稿叧鍔熻兘銆?br /><br />pom.xml<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->        <span style="color: #0000FF; "><</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br />           <span style="color: #0000FF; "><</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span>org.springframework.integration<span style="color: #0000FF; "></</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span><br />           <span style="color: #0000FF; "><</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span>spring-integration-jdbc<span style="color: #0000FF; "></</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span><br />        <span style="color: #0000FF; "></</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br /><br />        <span style="color: #0000FF; "><</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span>org.springframework.boot<span style="color: #0000FF; "></</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span>spring-boot-starter-jdbc<span style="color: #0000FF; "></</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span><br />        <span style="color: #0000FF; "></</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br /><br />        <span style="color: #0000FF; "><</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br />           <span style="color: #0000FF; "><</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span>org.flywaydb<span style="color: #0000FF; "></</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span><br />           <span style="color: #0000FF; "><</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span>flyway-core<span style="color: #0000FF; "></</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span><br />        <span style="color: #0000FF; "></</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br />        <br />        <span style="color: #0000FF; "><</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span>org.mariadb.jdbc<span style="color: #0000FF; "></</span><span style="color: #800000; ">groupId</span><span style="color: #0000FF; ">></span><br />            <span style="color: #0000FF; "><</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span>mariadb-java-client<span style="color: #0000FF; "></</span><span style="color: #800000; ">artifactId</span><span style="color: #0000FF; ">></span><br />        <span style="color: #0000FF; "></</span><span style="color: #800000; ">dependency</span><span style="color: #0000FF; ">></span></div><br />LeaderElectionIntegrationConfig.java<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> java.util.List;<br /><span style="color: #0000FF; ">import</span> java.util.concurrent.CopyOnWriteArrayList;<br /><br /><span style="color: #0000FF; ">import</span> javax.sql.DataSource;<br /><br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Bean;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Configuration;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.jdbc.lock.DefaultLockRepository;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.jdbc.lock.JdbcLockRegistry;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.jdbc.lock.LockRepository;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.support.leader.LockRegistryLeaderInitiator;<br /><br /><span style="color: #0000FF; ">import</span> com.paul.integration.leader.ControlBusGateway;<br /><span style="color: #0000FF; ">import</span> com.paul.integration.leader.MyCandidate;<br /><br />@Configuration<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> LeaderElectionIntegrationConfig {<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> List<String> needToStartupAdapterList(){<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> CopyOnWriteArrayList<>();<br />    }<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> DefaultLockRepository defaultLockRepository(DataSource dataSource){<br />        DefaultLockRepository defaultLockRepository =<br />                <span style="color: #0000FF; ">new</span> DefaultLockRepository(dataSource);<br /><span style="color: #008000; ">//</span><span style="color: #008000; ">        defaultLockRepository.setTimeToLive(60_000);</span><span style="color: #008000; "><br /></span>        <span style="color: #0000FF; ">return</span> defaultLockRepository;<br />    }<br /><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> JdbcLockRegistry jdbcLockRegistry(LockRepository lockRepository){<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> JdbcLockRegistry(lockRepository);<br />    }<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> MyCandidate myCandidate(<br />        ControlBusGateway controlBusGateway,<br />        List<String> needToStartupAdapterList<br />    ) {<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> MyCandidate(controlBusGateway, needToStartupAdapterList);<br />    }<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> LockRegistryLeaderInitiator leaderInitiator() {<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> LockRegistryLeaderInitiator(<br />                    jdbcLockRegistry(<span style="color: #0000FF; ">null</span>), myCandidate(<span style="color: #0000FF; ">null</span>, <span style="color: #0000FF; ">null</span>)<br />               );<br />    }<br />    <br />    <br />}</div><br /><br /><div>MyCandidate.java</div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> java.util.List;<br /><br /><span style="color: #0000FF; ">import</span> org.slf4j.Logger;<br /><span style="color: #0000FF; ">import</span> org.slf4j.LoggerFactory;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.leader.Context;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.leader.DefaultCandidate;<br /><br /><span style="color: #0000FF; ">import</span> com.novacredit.mcra.mcracommon.integration.gateway.ControlBusGateway;<br /><br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> MyCandidate <span style="color: #0000FF; ">extends</span> DefaultCandidate{<br />    <br />    <span style="color: #0000FF; ">private</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">final</span> Logger LOG = LoggerFactory.getLogger(MyCandidate.<span style="color: #0000FF; ">class</span>);<br />    <br />    <span style="color: #0000FF; ">private</span> List<String> needToStartupAdapterList;<br />    <br />    <span style="color: #0000FF; ">private</span> ControlBusGateway controlBusGateway;<br />    <br />    <span style="color: #0000FF; ">public</span> MyCandidate(<br />        ControlBusGateway controlBusGateway,<br />        List<String> needToStartupAdapterList<br />    ) {<br />        <span style="color: #0000FF; ">this</span>.controlBusGateway = controlBusGateway;<br />        <span style="color: #0000FF; ">this</span>.needToStartupAdapterList = needToStartupAdapterList;<br />    }<br />    <br />    @Override<br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> onGranted(Context context) {<br />        <span style="color: #0000FF; ">super</span>.onGranted(context);<br />        LOG.info("*** Leadership granted ***");<br />        LOG.info("STARTING MONGODB POLLER");<br />        needToStartupAdapterList<br />            .forEach(<br />                c -> {<br /><span style="color: #008000; ">//</span><span style="color: #008000; ">                    c = "@'testIntegrationFlow.org.springframework.integration.config."<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                            + "SourcePollingChannelAdapterFactoryBean#0'";</span><span style="color: #008000; "><br /></span>                    String command = c + ".start()";<br />                    LOG.info("-----{}", command);<br />                    controlBusGateway.sendCommand(command);<br />                }<br />             );<br />        LOG.info("STARTUP MESSAGE SENT");<br /><br />    }<br /><br />    @Override<br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> onRevoked(Context context) {<br />        <span style="color: #0000FF; ">super</span>.onRevoked(context);<br />        LOG.info("*** Leadership revoked ***");<br />        LOG.info("STOPPING MONGODB POLLER");<br />        needToStartupAdapterList<br />            .forEach(<br />                c -> {<br /><span style="color: #008000; ">//</span><span style="color: #008000; ">                    c = "@'testIntegrationConfig.testIntegrationFlow."<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                            + "mongoMessageSource.inboundChannelAdapter'";</span><span style="color: #008000; "><br /></span>                    String command = c + ".stop()";<br />                    LOG.info("-----{}", command);<br /><span style="color: #008000; ">//</span><span style="color: #008000; ">                    controlBusGateway.sendCommand(command);</span><span style="color: #008000; "><br /></span>                }<br />             );<br />        LOG.info("SHUTDOWN MESSAGE SENT");<br />    }<br /><br />}</div><br /><br />ControlBusIntegrationConfig.java<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Bean;<br /><span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Configuration;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.dsl.IntegrationFlow;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.dsl.IntegrationFlows;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.dsl.MessageChannels;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.gateway.GatewayProxyFactoryBean;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.handler.LoggingHandler;<br /><span style="color: #0000FF; ">import</span> org.springframework.messaging.MessageChannel;<br /><br /><span style="color: #0000FF; ">import</span> com.paul.integration.gateway.ControlBusGateway;<br /><br />@Configuration<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> ControlBusIntegrationConfig {<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> MessageChannel controlBusChannel() {<br />        <span style="color: #0000FF; ">return</span> MessageChannels.direct().get();<br />    }<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> IntegrationFlow controlBusFlow() {<br />        <span style="color: #0000FF; ">return</span> IntegrationFlows.from(controlBusChannel())<br />                    .log(LoggingHandler.Level.INFO, "controlBusChannel")<br />                    .controlBus()<br />                    .get();<br />    }<br />    <br />    @Bean<br />    <span style="color: #0000FF; ">public</span> GatewayProxyFactoryBean controlBusGateway() {<br />        GatewayProxyFactoryBean gateway = <span style="color: #0000FF; ">new</span> GatewayProxyFactoryBean(ControlBusGateway.<span style="color: #0000FF; ">class</span>);<br />        gateway.setDefaultRequestChannel(controlBusChannel());<br />        gateway.setDefaultRequestTimeout(300l);<br />        gateway.setDefaultReplyTimeout(300l);<br />        <span style="color: #0000FF; ">return</span> gateway;<br />    }<br />    <br />}</div><br /><br />ControlBusGateway.java<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">interface</span> ControlBusGateway {<br />    <br />    <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">void</span> sendCommand(String command);<br /><br />}</div><br /><br />鍚勪釜搴旂敤瀹炰緥榪愯鏃訛紝鍏朵腑鐨凩ockRegistryLeaderInitiator浼氳嚜鍔ㄨ繍琛岋紝鎶㈠ずLEADER鏁版嵁錛屾渶緇堝彧鏈変竴涓疄渚嬪ず鍙栥備箣鍚庡啀鎵цMyCandidate涓殑浠g爜銆?br /><br /><br /><br /><br /><br /><br /><br /><img src ="http://m.tkk7.com/paulwong/aggbug/439381.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/paulwong/" target="_blank">paulwong</a> 2022-01-20 13:49 <a href="http://m.tkk7.com/paulwong/archive/2022/01/20/439381.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>EVEN DRIVEN - SPRING CLOUD STREAM 3.x - Functional Programming Modelhttp://m.tkk7.com/paulwong/archive/2021/11/10/436035.htmlpaulwongpaulwongWed, 10 Nov 2021 07:10:00 GMThttp://m.tkk7.com/paulwong/archive/2021/11/10/436035.htmlhttp://m.tkk7.com/paulwong/comments/436035.htmlhttp://m.tkk7.com/paulwong/archive/2021/11/10/436035.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/436035.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/436035.htmlSPRING CLOUD STREAM 3.x 鐗堟湰鏃訛紝涔嬪墠鐨勪竴浜涚紪紼嬫ā寮忥紝濡侤Enablebindding錛孈StreamListenner絳夋敞閲婅搴熷純浜嗭紝榪欐槸鐢變簬涓浜涙鏋剁殑浠g爜蹇呴渶鐢辯敤鎴風紪鍐欙紝濡傞厤緗鏋剁敤鐨処nput MessageChannel錛孫utput  MessageChannel錛岃繛鎺essageHandler涓嶮essageChannel絳夛紝琚涓轟笉蹇呰鐨勫姩浣溿備負浜嗙畝鍖栫敤鎴蜂唬鐮侊紝浜庢槸鎺ㄥ嚭Functional Programming Model銆?br />
寮曞叆浜嗘柊鍚嶈瘝錛歋upplier銆丗unction涓嶤onsumer銆傚疄闄呬笂榪欏嚑涓被鍙涓篈dapter錛屽鏋滀箣鍓嶅凡緇忔湁瀛樺湪鐨凷ervice綾伙紝涓旀柟娉曞悕涓哄悇縐嶅悇鏍鳳紝鍙互閲嶆柊鍖呰鎴怱upplier銆丗unction涓嶤onsumer錛屽茍鍦ㄥ浐瀹氱殑鏂規硶鍚嶏細apply/get/accept涓皟鐢⊿ervice鐨勬柟娉曘?br />

Supplier

褰撳湪閰嶇疆鏂囦歡涓敞鍏ユ綾誨瀷鐨凚ean錛屽茍鍦╯pring.cloud.stream.function.definition鍔犲叆姝ean鐨勫悕縐幫紝SPRING CLOUD STREAM灝變細甯綘鐢熸垚涓涓狾utput  MessageChannel錛屽茍榪炴帴涓婃Bean錛屽悗緇彧闇瑕佸湪BINDDING涓姞鍏ュ搴旂殑Destination Name錛屽嵆鍙悜BROKER鍙戞秷鎭簡銆?br />

Consumer

褰撳湪閰嶇疆鏂囦歡涓敞鍏ユ綾誨瀷鐨凚ean錛屽茍鍦╯pring.cloud.stream.function.definition鍔犲叆姝ean鐨勫悕縐幫紝SPRING CLOUD STREAM灝變細甯綘鐢熸垚涓涓狪nput  MessageChannel錛屽茍榪炴帴涓婃Bean錛屽悗緇彧闇瑕佸湪BINDDING涓姞鍏ュ搴旂殑Destination Name錛屽嵆鍙敹鍒癇ROKER鎺ㄩ佸叧浜庢Destination鐨勬秷鎭簡銆?br />

Function

褰撳湪閰嶇疆鏂囦歡涓敞鍏ユ綾誨瀷鐨凚ean錛屽茍鍦╯pring.cloud.stream.function.definition鍔犲叆姝ean鐨勫悕縐幫紝SPRING CLOUD STREAM灝變細甯綘鐢熸垚涓涓狪nput鍜孫utput  MessageChannel錛屽茍榪炴帴涓婃Bean錛屽悗緇彧闇瑕佸湪BINDDING涓垎鍒Input鍜孫utput MessageChannel鍔犲叆瀵瑰簲鐨凞estination Name1/Name2錛屽嵆鍙敹鍒癇ROKER鎺ㄩ佸叧浜庢Destination鐨勬秷鎭紝涔熷彲浠ュ悜BROKER鍙戞秷鎭簡銆?br />

涓嶴PRING INTEGRATION鐨勬暣鍚?/h2>濡傛灉瑕佸娑堟伅榪涜澶嶆潅澶勭悊錛屽鎷嗗垎娑堟伅銆佽仛鍚堟秷鎭両F ELSE娑堟伅絳夛紝灝辮鍊熷姪SPRING INTEGRATION浜嗐?br />
@Bean
    public IntegrationFlow upperCaseFlow(LoanService loanService) {
        return IntegrationFlows
                    //turn this IntegrationFlow as a gateway, here is a Function interface 
                    
//with loadCheckerFunction as bean name
                    .from(LoadCheckerFunction.class, gateway -> gateway.beanName("loadCheckerFunction"))
                    .handle(loanService, "check")
                    .logAndReply(LoggingHandler.Level.WARN);
    }

    public interface LoadCheckerFunction extends Function<Loan, Loan>{

    }

IntegrationFlows.from(Class<?> serviceInterface)鏄彲浠ュ皢鏈琁ntegrationFlow鍖呰鎴恠erviceInterface鐨勫疄鐜扮被錛屽鏋滆皟鐢ㄦ鎺ュ彛錛屾渶緇堜細榪斿洖IntegrationFlow鏈鍚庝竴涓楠ょ殑瀹炰綋錛屽鏋滆繖涓猻erviceInterface鏄疐unction鐨勮瘽錛屽垰濂藉拰SPRING CLOUD STREAM瀵規帴涓娿?br />
鍚庣畫鍦╯pring.cloud.stream.function.definition鍔犲叆姝ean鐨勫悕縐發oadCheckerFunction錛孲PRING CLOUD STREAM灝變細甯綘鐢熸垚涓涓狪nput鍜孫utput  MessageChannel錛屽茍榪炴帴涓婃Bean錛屽啀鍦˙INDDING涓垎鍒Input鍜孫utput MessageChannel鍔犲叆瀵瑰簲鐨凞estination Name1/Name2錛屽嵆鍙敹鍒癇ROKER鎺ㄩ佸叧浜庢Destination鐨勬秷鎭紝涔熷彲浠ュ悜BROKER鍙戞秷鎭?br />
application.yaml
# This setting can increase or decrease the rate of message production (1000 = 1s)
# spring.cloud.stream.poller.fixed-delay=1000

# This setting can control which function method in our code will be triggered if there are multiple
# spring.cloud.function.definition=supplyLoan

# Give the autogenerated binding a friendlier name

spring:
   application:
      name: loan-check-rabbit
   banner:
      location: classpath:/banner-rabbit.txt
   cloud:
      stream:
         function.definition: loadCheckerFunction
         #BindingProperties
         bindings:
            loadCheckerFunction-in-0:
               destination: queue.pretty.log.messages
               binder: local_rabbit
            loadCheckerFunction-out-0:
               destination: queue.pretty.approved.messages
               binder: local_rabbit
         #BinderProperties
         binders:
            local_rabbit:
               type: rabbit
               environment:
                  spring:
                     rabbitmq:
                        host: 10.80.27.69
                        port: 5672
                        username: guest
                        password: guest
                        virtual-host: my-virtual-host

Reference

https://spring.io/blog/2019/10/25/spring-cloud-stream-and-spring-integration

paulwong 2021-11-10 15:10 鍙戣〃璇勮
]]>
SPRING INTEGRATION - ENRICHhttp://m.tkk7.com/paulwong/archive/2021/09/21/435976.htmlpaulwongpaulwongTue, 21 Sep 2021 05:40:00 GMThttp://m.tkk7.com/paulwong/archive/2021/09/21/435976.htmlhttp://m.tkk7.com/paulwong/comments/435976.htmlhttp://m.tkk7.com/paulwong/archive/2021/09/21/435976.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435976.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435976.html
package org.springframework.integration.stackoverflow.enricher;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.Transformers;
import org.springframework.integration.http.dsl.Http;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class SpringIntegrationEnricherApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringIntegrationEnricherApplication.class, args);
    }

    @Bean
    public IntegrationFlow jsonEnricherFlow(RestTemplate restTemplate) {
        return IntegrationFlows.from(Function.class)
                .transform(Transformers.fromJson(Map.class))
                .enrich((enricher) -> enricher
                        .<Map<String, ?>>requestPayload((message) ->
                                ((List<?>) message.getPayload().get("attributeIds"))
                                        .stream()
                                        .map(Object::toString)
                                        .collect(Collectors.joining(",")))
                        .requestSubFlow((subFlow) ->
                                subFlow.handle(
                                        Http.outboundGateway("/attributes?id={ids}", restTemplate)
                                                .httpMethod(HttpMethod.GET)
                                                .expectedResponseType(Map.class)
                                                .uriVariable("ids", "payload")))
                        .propertyExpression("attributes", "payload.attributes"))
                .<Map<String, ?>, Map<String, ?>>transform(
                        (payload) -> {
                            payload.remove("attributeIds");
                            return payload;
                        })
                .transform(Transformers.toJson())
                .get();
    }

}

https://stackoverflow.com/questions/58205432/spring-integration-enrich-transform-message-using-rest-call

https://www.tabnine.com/web/assistant/code/rs/5c781b6ae70f87000197ab9f#L312



paulwong 2021-09-21 13:40 鍙戣〃璇勮
]]>
SPRING INTEGRATION RETRYhttp://m.tkk7.com/paulwong/archive/2021/08/23/435950.htmlpaulwongpaulwongMon, 23 Aug 2021 05:01:00 GMThttp://m.tkk7.com/paulwong/archive/2021/08/23/435950.htmlhttp://m.tkk7.com/paulwong/comments/435950.htmlhttp://m.tkk7.com/paulwong/archive/2021/08/23/435950.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435950.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435950.html 榛樿鏄噸璇?嬈★紝姣忔閲嶈瘯闂撮殧鏄?0縐掋?br />
@SpringBootApplication
public class SpringIntegrationDslHttpRetryApplication {

    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext =
                SpringApplication.run(SpringIntegrationDslHttpRetryApplication.class, args);
        Function<Object, Object> function = applicationContext.getBean(Function.class);
        function.apply("foo");
    }

    @Bean
    public IntegrationFlow httpRetryFlow() {
        return IntegrationFlows.from(Function.class)
                .handle(Http.outboundGateway("http://localhost:11111")
                                .httpMethod(HttpMethod.GET)
                                .expectedResponseType(String.class),
                        e -> e.advice(retryAdvice()))
                .get();
    }

    @Bean
    public RequestHandlerRetryAdvice retryAdvice() {
        return new RequestHandlerRetryAdvice();
    }

}

#鎵撳嵃鏃ュ織
logging.level.org.springframework.retry=debug

Reference:
https://docs.spring.io/spring-integration/reference/html/handler-advice.html#retry-advice
https://stackoverflow.com/questions/49784360/configure-error-handling-and-retry-for-http-outboundgateway-spring-dsl
https://stackoverflow.com/questions/50262862/requesthandlerretryadvice-with-httprequestexecutingmessagehandler-not-working
https://stackoverflow.com/questions/63689856/spring-integration-http-outbound-gateway-retry-based-on-reply-content
https://blog.csdn.net/cunfen8879/article/details/112552420




paulwong 2021-08-23 13:01 鍙戣〃璇勮
]]>
JSR-303 Bean Validationhttp://m.tkk7.com/paulwong/archive/2021/01/28/435786.htmlpaulwongpaulwongThu, 28 Jan 2021 02:35:00 GMThttp://m.tkk7.com/paulwong/archive/2021/01/28/435786.htmlhttp://m.tkk7.com/paulwong/comments/435786.htmlhttp://m.tkk7.com/paulwong/archive/2021/01/28/435786.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435786.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435786.html
JSR-303 Bean Validation鍒欐彁渚涗簡榪欐牱鐨勪究鎹楓?br />
鍙鍦↗AVA BEAN涓渶瑕侀獙璇佺殑瀛楁鍔燖NotNull榪欑鏍囩錛岀劧鍚庡湪SERVISE涓殑杈撳叆鍙傛暟涓姞@Valid鏍囩錛屽垯灝辨縺媧婚獙璇佹祦紼嬨?br />涔熷彲浠ョ紪紼嬬殑鏂瑰紡鑷繁楠岃瘉錛?br />
@MessageEndpoint
//@Validated
public class MqMessageCcdValidator {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(MqMessageCcdValidator.class);
    
    @Autowired
    private Validator validator;
    
    @ServiceActivator
    public MqMessage<CcdRequest> validate(/* @Valid */ Message<MqMessage<CcdRequest>> requestMessage) {
        Set<ConstraintViolation<MqMessage<CcdRequest>>> set = validator.validate(requestMessage.getPayload());
        if(CollectionUtils.isNotEmpty(set)) {
            CompositeException compositeException = new CompositeException();
            set.forEach(
                constraintViolation -> {
                                            LOGGER.info("{}", constraintViolation);
                                            ReqInfoValidationException exception =
                                                    new ReqInfoValidationException(constraintViolation.getMessage());
                                            compositeException.addException(exception);
                                       }
            );
            throw new MessageHandlingException(requestMessage, compositeException);
        }
        
        return requestMessage.getPayload();
    }

}

鑷畾涔夐獙璇佽鍒?br />鍙敤鏍囩鏉ュ仛錛屼互涓嬩負楠岃瘉鎵嬫満鍙風殑瑙勫垯錛?br />
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.Pattern;

@Retention(RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
@Constraint(validatedBy = {})
@ReportAsSingleViolation
@Pattern(regexp = "^1[3-9]\\d{9}$")
public @interface ChinaPhone {
    String message() default "Invalid Chinese mobile No.";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
}

濡傛灉姣旇緝澶嶆潅鐨勯獙璇佽鍒欙紝鍒欏弬瑙侊細
https://reflectoring.io/bean-validation-with-spring-boot/#implementing-a-custom-validator

How to use Java Bean Validation in Spring Boot
https://nullbeans.com/how-to-use-java-bean-validation-in-spring-boot/

Complete Guide to Validation With Spring Boot
https://reflectoring.io/bean-validation-with-spring-boot/

Spring JMS Validate Messages using JSR-303 Bean Validation
https://memorynotfound.com/spring-jms-validate-messages-jsr-303-bean-validation/

Spring REST Validation Example
https://mkyong.com/spring-boot/spring-rest-validation-example/

Spring Boot 鏁村悎 Bean Validation 鏍¢獙鏁版嵁

https://blog.csdn.net/wangzhihao1994/article/details/108403732


paulwong 2021-01-28 10:35 鍙戣〃璇勮
]]>
SPRING INTEGRATION SCATTERGATHERhttp://m.tkk7.com/paulwong/archive/2021/01/28/435785.htmlpaulwongpaulwongThu, 28 Jan 2021 02:11:00 GMThttp://m.tkk7.com/paulwong/archive/2021/01/28/435785.htmlhttp://m.tkk7.com/paulwong/comments/435785.htmlhttp://m.tkk7.com/paulwong/archive/2021/01/28/435785.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435785.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435785.html
  1. 椋熷涓嬪崟錛屾湁楗搧銆侀鐗┿佺敎鐐?br />
  2. 渚嶅簲鎺ュ崟錛屼紶閫佺粰鍘ㄦ埧
  3. 鍘ㄦ埧鍒嗕笁涓瓙嫻佺▼澶勭悊錛屽嵆楗搧銆侀鐗┿佺敎鐐瑰瓙嫻佺▼
  4. 絳夊緟涓変釜瀛愭祦紼嬪鐞嗗畬錛屽悎騫舵垚涓浠戒氦浠?
  5. 濡傛灉鍘ㄦ埧鍙戠幇鏌愰鐗╂瑺緙猴紝浼氶氱煡渚嶅簲錛屽睍寮閿欒澶勭悊錛屽嵆閫氱煡椋熷鏇存敼椋熺墿錛屽啀浜ょ粰鍘ㄦ埧
  6. 渚嶅簲灝嗕氦浠樺搧浼犻佺粰椋熷
鏈変竴涓富嫻佺▼銆佷笁涓瓙嫻佺▼鍜屼竴涓仛鍚堟祦紼嬶紝鑱氬悎嫻佺▼浼氳仛鍚堜笁涓瓙嫻佺▼鐨勪駭鐗╋紝閫氱煡涓繪祦紼嬶紝鍐嶅線涓嬭蛋銆?br />騫朵笖涓繪祦紼嬩細鎰熺煡瀛愭祦紼嬬殑閿欒錛屽茍浼氫氦緇欑浉搴旈敊璇鐞嗘祦紼嬪鐞嗭紝涓斿皢緇撴灉鍐嶄氦緇欒仛鍚堟祦紼嬨?br />
瀵瑰簲SPRING INTEGRATION 鐨凷CATTERGATHER妯″紡錛?br />
@Bean
public IntegrationFlow scatterGatherAndExecutorChannelSubFlow(TaskExecutor taskExecutor) {
    return f -> f
            .scatterGather(
                    scatterer -> scatterer
                            .applySequence(true)
                            .recipientFlow(f1 -> f1.transform(p -> "Sub-flow#1"))
                            .recipientFlow(f2 -> f2
                                    .channel(c -> c.executor(taskExecutor))
                                    .transform(p -> {
                                        throw new RuntimeException("Sub-flow#2");
                                    })),
                    null,
                    s -> s.errorChannel("scatterGatherErrorChannel"));
}

@ServiceActivator(inputChannel = "scatterGatherErrorChannel")
public Message<?> processAsyncScatterError(MessagingException payload) {
    return MessageBuilder.withPayload(payload.getCause().getCause())
            .copyHeaders(payload.getFailedMessage().getHeaders())
            .build();
}

https://github.com/adnanmamajiwala/spring-integration-sample/tree/master/dsl-scatter-gather/src/main/java/com/si/dsl/scattergather

https://docs.spring.io/spring-integration/docs/5.1.x/reference/html/#scatter-gather

paulwong 2021-01-28 10:11 鍙戣〃璇勮
]]>
SPRING INTEGRATION HEADER闂http://m.tkk7.com/paulwong/archive/2020/10/20/435696.htmlpaulwongpaulwongTue, 20 Oct 2020 06:56:00 GMThttp://m.tkk7.com/paulwong/archive/2020/10/20/435696.htmlhttp://m.tkk7.com/paulwong/comments/435696.htmlhttp://m.tkk7.com/paulwong/archive/2020/10/20/435696.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435696.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435696.html
.headerFilter("Api-Key", "Content-Type", "X-Powered-By", "Content-Language", "Transfer-Encoding", "Cache-Control", "Keep-Alive", "Set-Cookie")

https://stackoverflow.com/questions/50608415/cwsia0112e-the-property-name-keep-alive-is-not-a-valid-java-identifier

paulwong 2020-10-20 14:56 鍙戣〃璇勮
]]>
Error handling in spring integration - How to get all the errors thrown in multiple threads and send them to the error-channelhttp://m.tkk7.com/paulwong/archive/2020/10/15/435693.htmlpaulwongpaulwongThu, 15 Oct 2020 11:21:00 GMThttp://m.tkk7.com/paulwong/archive/2020/10/15/435693.htmlhttp://m.tkk7.com/paulwong/comments/435693.htmlhttp://m.tkk7.com/paulwong/archive/2020/10/15/435693.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435693.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435693.html
@Bean
public IntegrationFlow provisionUserFlow() {
return
    IntegrationFlows.from("input.channel")
    .publishSubscribeChannel(Executors.newCachedThreadPool(),
        s -> s.applySequence(true)
            .subscribe(f -> f.enrichHeaders(e -> e.header(MessageHeaders.ERROR_CHANNEL, "errorChannel", true))
                .handle(provisionerA, "provision")
                .channel("aggregatorChannel")
            )
            .subscribe(f -> f.enrichHeaders(e -> e.header(MessageHeaders.ERROR_CHANNEL, "errorChannel", true))
                .handle(provisionerB, "provision")
                .channel("aggregatorChannel"))
            )
        .get();
}

@Bean
public IntegrationFlow aggregateFlow() {
    return IntegrationFlows.from("aggregatorChannel")
                    .channel( aggregatorChannel)
                    .aggregate( a -> a.processor( collect, "aggregatingMethod"))
                    .get();
}

@Transformer( inputChannel = "errorChannel", outputChannel = "aggregatorChannel")
public Message<?> errorChannelHandler(ErrorMessage errorMessage) throws RuntimeException {

    Message<?> failedMessage =  ((MessagingException) errorMessage.getPayload()).getFailedMessage();

    Exception exception = (Exception) errorMessage.getPayload();

    return  MessageBuilder.withPayload( exception.getMessage())
                                       .copyHeadersIfAbsent( failedMessage.getHeaders() )
                                       .build();
}


https://stackoverflow.com/q/46495127/11790720



paulwong 2020-10-15 19:21 鍙戣〃璇勮
]]>
SPRING INTEGRATION瀛怓LOWhttp://m.tkk7.com/paulwong/archive/2020/10/15/435692.htmlpaulwongpaulwongThu, 15 Oct 2020 03:29:00 GMThttp://m.tkk7.com/paulwong/archive/2020/10/15/435692.htmlhttp://m.tkk7.com/paulwong/comments/435692.htmlhttp://m.tkk7.com/paulwong/archive/2020/10/15/435692.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435692.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435692.html split涔嬪悗錛屽彲浠ュ皢message鍒嗙粰涓嶅悓鐨勫瓙flow澶勭悊錛岄厤緗涓嬶細
@Bean
public IntegrationFlow parallelSplitRouteAggregateFlow() {
    return IntegrationFlows
            .from(Http.inboundGateway("/trigger"))
            .handle((p, h) -> Arrays.asList(1, 2, 3))
            .split()
            .channel(MessageChannels.executor(Executors.newCachedThreadPool()))
            .<Integer, Boolean>route(o -> o % 2 == 0, m -> m
                    .subFlowMapping(true, sf -> sf.gateway(oddFlow()))
                    .subFlowMapping(false, sf -> sf.gateway(evenFlow())))
            .aggregate()
            .get();
}

@Bean
public IntegrationFlow oddFlow() {
    return flow -> flow.<Integer>handle((payload, headers) -> "odd");
}

@Bean
public IntegrationFlow evenFlow() {
    return flow -> flow.<Integer>handle((payload, headers) -> "even");
}


https://stackoverflow.com/questions/50121384/spring-integration-parallel-split-route-aggregate-flow-fails-due-to-one-way-mess

paulwong 2020-10-15 11:29 鍙戣〃璇勮
]]>
SPRING INTEGRATION ERROR HANDLINGhttp://m.tkk7.com/paulwong/archive/2020/01/10/435027.htmlpaulwongpaulwongFri, 10 Jan 2020 07:32:00 GMThttp://m.tkk7.com/paulwong/archive/2020/01/10/435027.htmlhttp://m.tkk7.com/paulwong/comments/435027.htmlhttp://m.tkk7.com/paulwong/archive/2020/01/10/435027.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/435027.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/435027.htmlhttps://github.com/zakyalvan/spring-integration-java-dsl-learn

package com.jwebs.learn.errorhandling;

import java.util.Random;

import javax.jms.ConnectionFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.channel.PublishSubscribeChannel;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.core.Pollers;
import org.springframework.integration.dsl.jms.Jms;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessagingException;

/**
 * Show how to handle error in spring integration flow.
 * Please note, errorChannel in spring integration only applicable to
 * error thrown in asynch component.
 * 
 * 
@author zakyalvan
 
*/
@SpringBootApplication
@IntegrationComponentScan
public class ErrorHandlingApplication {
    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(ErrorHandlingApplication.class)
                .web(false)
                .run(args);
        
        Runtime.getRuntime().addShutdownHook(new Thread(() -> applicationContext.close()));
        
        System.out.println("Pres enter key to exit");
        System.in.read();
        System.exit(0);
    }

    @Autowired
    private ConnectionFactory connectionFactory;
    
    @Bean
    public MessageSource<Integer> randomIntegerMessageSource() {
        return () -> MessageBuilder.withPayload(new Random().nextInt()).build();
    }
    
    @Bean
    public IntegrationFlow withErrorFlow() {
        return IntegrationFlows.from(randomIntegerMessageSource(), spec -> spec.poller(Pollers.fixedDelay(1000)))
                    .handle(Jms.outboundGateway(connectionFactory)
                    .requestDestination("processor.input")
                    .replyContainer(spec -> spec.sessionTransacted(true)))
                    .get();
    }
    
    @Autowired
    @Qualifier("errorChannel")
    private PublishSubscribeChannel errorChannel;
    
    @Bean
    public IntegrationFlow errorHandlingFlow() {
        return IntegrationFlows.from(errorChannel)
                .handle(message -> System.out.println("@@@@@@@@@@@@@@@@@@@@@" + ((MessagingException) message.getPayload()).getFailedMessage().getPayload()))
                .get();
    }
}


paulwong 2020-01-10 15:32 鍙戣〃璇勮
]]>
EIP in SPRING INTEGRATIONhttp://m.tkk7.com/paulwong/archive/2019/10/25/434882.htmlpaulwongpaulwongFri, 25 Oct 2019 03:03:00 GMThttp://m.tkk7.com/paulwong/archive/2019/10/25/434882.htmlhttp://m.tkk7.com/paulwong/comments/434882.htmlhttp://m.tkk7.com/paulwong/archive/2019/10/25/434882.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434882.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434882.html
  • idempotent receiver
騫傜瓑鍨嬶紝鍚屼竴涓狹ESSAGE錛屽MESSAGE ID閮戒竴鏍鳳紝鍦∕ESSAGING緋葷粺涓笉綆¤繍琛屽灝戞錛岀粨鏋滈兘涓鏍鳳紝涓哄暐錛熷洜涓洪噸澶嶇殑MESSAGE錛岄兘琚拷鐣ヤ簡銆?br /> 鏂規錛?br /> 娑堟伅琚鐞嗗悗錛屼粠娑堟伅涓彇鍑篒D錛屾斁鍏ETA-DATA-STORE涓紝鍚庣畫澶勭悊娑堟伅鏃訛紝瑕佷粠META-DATA-STORE涓鏌ユ槸鍚︽湁鍊箋?br />
涓嬮潰榪欎釜鏂規錛孖D鐨勫瓨鍌ㄥ拰鍒ゆ柇鏄惁閲嶅娑堟伅閮藉湪涓涓狪NTERCEPTOR涓悶瀹氥?br /> https://stackoverflow.com/questions/50401460/spring-integration-dsl-configure-idempotent-receiver-to-identify-duplicates
https://www.javacodegeeks.com/2015/09/monitoring-and-management.html


claim-check
灝哅ESSAGE鐨凱AYLOAD瀛樺湪STORE涓紝榪斿洖涓涓狪D錛岃繖涓狪D鍗砪laim-check錛屽鏋滈渶瑕佸彇MESSAGE鐨凞ETAIl鏃訛紝鍙粠STORE涓彇鍑篗ESSAGE銆?br />https://github.com/spring-projects/spring-integration/blob/master/src/reference/asciidoc/claim-check.adoc




paulwong 2019-10-25 11:03 鍙戣〃璇勮
]]>
SPRING INTEGRATION LESSONShttp://m.tkk7.com/paulwong/archive/2019/10/25/434881.htmlpaulwongpaulwongFri, 25 Oct 2019 01:45:00 GMThttp://m.tkk7.com/paulwong/archive/2019/10/25/434881.htmlhttp://m.tkk7.com/paulwong/comments/434881.htmlhttp://m.tkk7.com/paulwong/archive/2019/10/25/434881.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434881.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434881.htmlLessons

Introduction to Enterprise Application Integration

In our first lesson, you will get introduced to the concepts of Enterprise Application Integration. You will learn about the and Enterprise integration patterns that can be applied to simplify integration between different platforms and the Integration strategies that can be followed for this purpose. Finally, we will discuss how and why to implement a Message driven architecture and how to achieve both Synchronous and asynchronous communication among nodes.

Spring Integration Fundamentals

In this lesson, you will get to understand how Spring Integration works under the hood. The core concepts of Spring Integration messaging system (like message channels and endpoints) will be introduced. Additionally, the components that build the framework will be discussed, including the channel adapters, transformers, filters, routers etc. Finally, the two distinct methods of communication (synchronous and asynchronous) are explained and the lesson ends with a discussion on error handling.

Spring Integration and Web Services

In this lesson, we will focus on the integration with external web services. Spring Integration comes with the necessary functionality (adapters, channels etc.) to support web services out of the box. A full example is built from scratch in order to better understand the topic.

Enterprise Messaging

In this lesson, we will focus on integrating our application with JMS messaging. For this purpose, we will use Active MQ, which will be our broker. We will show examples of sending and receiving JMS messages by using the Spring Integration JMS channel adapters. Following these examples, we will see some ways of customizing these invocations by configuring message conversion and destination resolution.

Spring Integration Full Example

In this lesson, we will wrap everything up by providing a complete application that uses several of the components provided by Spring Integration in order to provide a service to its users. We will discuss the system architecture, the actual implementation and the relevant error handling.

Monitoring and Management

In this lesson, we will examine different mechanisms of monitoring or gathering more information about what is going on within the messaging system. Some of these mechanisms consist of managing or monitoring the application through MBeans, which are part of the JMX specification. Another mechanism discussed in this chapter is how we will implement the EIP idempotent receiver pattern using a metadata store. Finally, the last mechanism described is the control bus. This will let us send messages that will invoke operations on components in the application context.



paulwong 2019-10-25 09:45 鍙戣〃璇勮
]]>
SPRING INTEGRATION DSL DEMOhttp://m.tkk7.com/paulwong/archive/2019/10/23/434878.htmlpaulwongpaulwongWed, 23 Oct 2019 03:55:00 GMThttp://m.tkk7.com/paulwong/archive/2019/10/23/434878.htmlhttp://m.tkk7.com/paulwong/comments/434878.htmlhttp://m.tkk7.com/paulwong/archive/2019/10/23/434878.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434878.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434878.htmlhttps://github.com/spring-projects/spring-integration/tree/master/src/reference/asciidoc

paulwong 2019-10-23 11:55 鍙戣〃璇勮
]]>
Spring Integration 涓枃鎵嬪唽 - GOODhttp://m.tkk7.com/paulwong/archive/2019/10/11/434799.htmlpaulwongpaulwongFri, 11 Oct 2019 02:28:00 GMThttp://m.tkk7.com/paulwong/archive/2019/10/11/434799.htmlhttp://m.tkk7.com/paulwong/comments/434799.htmlhttp://m.tkk7.com/paulwong/archive/2019/10/11/434799.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434799.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434799.htmlSpring Integration 涓枃鎵嬪唽 (1)


Spring Integration 涓枃鎵嬪唽 (2)

paulwong 2019-10-11 10:28 鍙戣〃璇勮
]]>
鍦⊿PRING INTEGRATION涓墜鍔ㄥ紑濮嬪拰鍋滄JMS LISTENERhttp://m.tkk7.com/paulwong/archive/2019/10/09/434781.htmlpaulwongpaulwongWed, 09 Oct 2019 09:16:00 GMThttp://m.tkk7.com/paulwong/archive/2019/10/09/434781.htmlhttp://m.tkk7.com/paulwong/comments/434781.htmlhttp://m.tkk7.com/paulwong/archive/2019/10/09/434781.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434781.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434781.html
SPRING INTEGRATION鏄疄鐜頒簡EIP妯″紡鐨勪竴縐嶆鏋訛紝鍗充嬌鐢–HANNEL鍜孞MS-INBOUND-ADAPTER銆丣MS-OUTBOUND-ADAPTER錛屽畬鍏ㄨ劚紱諱簡JmsTemplate鐨凙PI銆?br />
濡傛灉闇瑕佸疄鐜拌繖縐嶅満鏅細浠嶣ROKER鍙栦竴鏉℃秷鎭紝澶勭悊娑堟伅錛屼笖澶勭悊閫斾腑涓嶈鍐嶄粠BROKER鍐嶅彇娑堟伅錛屽鐞嗗畬鍚庡啀鍙栨秷鎭紝鍐嶅鐞嗐?br />
榪欐牱瑕佹眰鎵嬪姩寮濮嬪拰鍋滄JMS LISTENER錛屽嵆鎵嬪姩寮濮嬪拰鍋滄JMS-INBOUND-ADAPTER銆丣MS-OUTBOUND-ADAPTER銆?br />
@Bean
@InboundChannelAdapter(value = "loaderResponseChannel")
public MessageSource loaderResponseSource() throws Exception {
    return Jms
            .inboundAdapter(oracleConnectionFactory())
            .configureJmsTemplate(
                    t -> t.deliveryPersistent(true)
                            .jmsMessageConverter(jacksonJmsMessageConverter())
            ).destination(jmsInbound).get();
}

褰撲嬌鐢ˊInboundChannelAdapter鏃訛紝浼氳嚜鍔ㄦ敞鍐屼竴涓猄ourcePollingChannelAdapter 錛屼絾榪欎釜鍚嶅瓧姣旇緝闀匡細configrationName.loaderResponseSource.inboundChannelAdapter銆?br />
鍛煎彨榪欎釜瀹炰緥鐨剆tart()鍜宻top()鏂規硶鍗沖彲銆?br />
@Bean
public IntegrationFlow controlBusFlow() {
    return IntegrationFlows.from("controlBus")
              .controlBus()
              .get();
}

Message operation = MessageBuilder.withPayload("@configrationName.loaderResponseSource.inboundChannelAdapter.start()").build();
operationChannel.send(operation)

https://stackoverflow.com/questions/45632469/shutdown-spring-integration-with-jms-inboundadapter

https://docs.spring.io/spring-integration/docs/5.0.7.RELEASE/reference/html/system-management-chapter.html#control-bus

https://github.com/spring-projects/spring-integration-java-dsl/blob/master/src/test/java/org/springframework/integration/dsl/test/jms/JmsTests.java

https://stackoverflow.com/questions/50428552/how-to-stop-or-suspend-polling-after-batch-job-fail


paulwong 2019-10-09 17:16 鍙戣〃璇勮
]]>
Enterprise Integration Patternshttp://m.tkk7.com/paulwong/archive/2019/07/18/434231.htmlpaulwongpaulwongThu, 18 Jul 2019 06:11:00 GMThttp://m.tkk7.com/paulwong/archive/2019/07/18/434231.htmlhttp://m.tkk7.com/paulwong/comments/434231.htmlhttp://m.tkk7.com/paulwong/archive/2019/07/18/434231.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434231.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434231.htmlWhy Enterprise Integration Patterns?

Enterprise integration is too complex to be solved with a simple 'cookbook' approach. Instead, patterns can provide guidance by documenting the kind of experience that usually lives only in architects' heads: they are accepted solutions to recurring problems within a given context. Patterns are abstract enough to apply to most integration technologies, but specific enough to provide hands-on guidance to designers and architects. Patterns also provide a vocabulary for developers to efficiently describe their solution.

Patterns are not 'invented'; they are harvested from repeated use in practice. If you have built integration solutions, it is likely that you have used some of these patterns, maybe in slight variations and maybe calling them by a different name. The purpose of this site is not to "invent" new approaches, but to present a coherent collection of relevant and proven patterns, which in total form an integration pattern language.

Despite the 700+ pages, our book covers only a fraction of patterns (and the problems to be solved) in the integration space. The current patterns focus on Messaging, which forms the basis of most other integration patterns. We have started to harvest more patterns but are realizing (once again) how much work documenting these patterns really is. So please stay tuned.

Messaging Patterns

We have documented 65 messaging patterns, organized as follows:



https://www.enterpriseintegrationpatterns.com/patterns/messaging/index.html

paulwong 2019-07-18 14:11 鍙戣〃璇勮
]]>
SPRING BATCH & SPRING INTEGRATION TUTORIALhttp://m.tkk7.com/paulwong/archive/2019/07/18/434230.htmlpaulwongpaulwongThu, 18 Jul 2019 05:21:00 GMThttp://m.tkk7.com/paulwong/archive/2019/07/18/434230.htmlhttp://m.tkk7.com/paulwong/comments/434230.htmlhttp://m.tkk7.com/paulwong/archive/2019/07/18/434230.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434230.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434230.html

Spring JMS Artemis Example 6 minute read

A detailed step-by-step tutorial on how to connect to Apache ActiveMQ Artemis using Spring JMS and Spring Boot.

Spring JMS Topic Example 5 minute read

A detailed step-by-step tutorial on how to publish/subscribe to a JMS topic using Spring JMS and Spring Boot.

Spring JMS Integration Example12 minute read

A detailed step-by-step tutorial on how to connect to an ActiveMQ JMS broker using Spring Integration and Spring Boot.

Spring JMS Listener Example 7 minute read

A detailed step-by-step tutorial on how a Spring JMS listener works in combination with Spring Boot.

Spring JMS JmsTemplate Example 7 minute read

A detailed step-by-step tutorial on how to use JmsTemplate in combination with Spring JMS and Spring Boot.

Spring JMS Message Converter Example5 minute read

A detailed step-by-step tutorial on how to implement a message converter using Spring JMS and Spring Boot.

Spring Batch Admin Example 11 minute read

A detailed step-by-step tutorial on how to use a Spring Boot admin UI to manage Spring Batch jobs.

Spring Batch Example 11 minute read

A detailed step-by-step tutorial on how to implement a Hello World Spring Batch job using Spring Boot.



paulwong 2019-07-18 13:21 鍙戣〃璇勮
]]>
Spring Integration Java DSLhttp://m.tkk7.com/paulwong/archive/2019/07/18/434229.htmlpaulwongpaulwongThu, 18 Jul 2019 05:16:00 GMThttp://m.tkk7.com/paulwong/archive/2019/07/18/434229.htmlhttp://m.tkk7.com/paulwong/comments/434229.htmlhttp://m.tkk7.com/paulwong/archive/2019/07/18/434229.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/434229.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/434229.htmlThis time I decided to play a little bit with Spring Integration Java DSL. Which has been merged directly into Spring Integration Core 5.0, which is smart and obvious move because:

  • Everyone starting the new Spring projects based on Java Config uses that
  • SI Java DSL enables you to use new powerfull Java 8 features like Lambdas
  • You can build your flow using the Builder pattern based on IntegrationFlowBuilder

Let's take a look on the samples howto use that based on ActiveMQ JMS.


https://bitbucket.org/tomask79/spring-integration-java-dsl/src/master/



paulwong 2019-07-18 13:16 鍙戣〃璇勮
]]>
Message Processing With Spring Integrationhttp://m.tkk7.com/paulwong/archive/2019/06/05/433840.htmlpaulwongpaulwongWed, 05 Jun 2019 03:08:00 GMThttp://m.tkk7.com/paulwong/archive/2019/06/05/433840.htmlhttp://m.tkk7.com/paulwong/comments/433840.htmlhttp://m.tkk7.com/paulwong/archive/2019/06/05/433840.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/433840.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/433840.html
https://dzone.com/articles/message-processing-spring



paulwong 2019-06-05 11:08 鍙戣〃璇勮
]]>
Spring integration 鍩烘湰姒傚康http://m.tkk7.com/paulwong/archive/2019/06/05/433839.htmlpaulwongpaulwongWed, 05 Jun 2019 02:36:00 GMThttp://m.tkk7.com/paulwong/archive/2019/06/05/433839.htmlhttp://m.tkk7.com/paulwong/comments/433839.htmlhttp://m.tkk7.com/paulwong/archive/2019/06/05/433839.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/433839.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/433839.html

1.spring integration 's architecture

涓昏鎻愪緵涓や釜鍔熻兘錛?/p>

鍦ㄧ郴緇熷唴鎻愪緵瀹炵幇杞婚噺綰с佷簨浠墮┍鍔ㄤ氦浜掕涓虹殑妗嗘灦

鍦ㄧ郴緇熼棿鎻愪緵涓縐嶅熀浜庨傞厤鍣ㄧ殑騫沖彴錛屼互鏀寔鐏墊椿鐨勭郴緇熼棿浜や簰

2.spring integration瀵逛簬浼佷笟闆嗘垚妯″紡鐨勬敮鎸?/p>

2.1Message錛氫竴涓俊鎭殑鍗曞厓錛岄氬父鏈夋秷鎭ご錛坔eader錛夊拰娑堟伅鍐呭錛坧ayload錛夌粍鎴?/p>

2.2Message channel錛氭秷鎭鐞嗚妭鐐逛箣闂寸殑榪炴帴錛岃礋璐e皢Message浠庣敓浜ц呬紶杈撳埌娑堣垂鑰呫?/p>

    鏍規嵁娑堣垂鑰呯殑澶氬皯錛屽彲鍒嗕負point to point鍜宲ublish-subscribe涓ょ


    鏍規嵁娑堟伅浼犺緭鏂瑰紡鐨勪笉鍚岋紝鍒嗕負鍚屾鍜屽紓姝ヤ袱縐?/p>

2.3Message Endpoint錛氭秷鎭鐞嗚妭鐐癸紝娑堟伅浠庤妭鐐硅繘鍏ラ氶亾錛屼篃鏄粠鑺傜偣紱誨紑閫氶亾

鍑犱釜甯歌鐨凪essage EndPoint錛?/p>

CHANNEL ADAPTER錛岀敤浜庤繛鎺ヨ閫傞厤鍣ㄧ殑鐗圭偣鏄崟鍚戞秷鎭祦鐨勶紝瑕佷箞鏄秷鎭氳繃璇ラ傞厤鍣ㄨ繘鍏ラ氶亾錛岃涔堟槸娑堟伅閫氳繃璇ラ傞厤鍣ㄧ寮閫氶亾


MESSAGING GATEWAY錛屽鐞嗙殑娑堟伅嫻佸拰Channel Adapter涓嶅悓錛屼笉鏄崟鍚戠殑錛屽嵆鏈夎繘鍏ヨ鑺傜偣鐨勬秷鎭紝涔熶細浠庤鑺傜偣鍙戝嚭娑堟伅銆?br />



SERVICE ACTIVATOR錛岃鑺傜偣璋冪敤鏈嶅姟鏉ュ鐞嗚緭鍏ョ殑娑堟伅錛屽茍灝嗘湇鍔¤繑鍥炵殑鏁版嵁鍙戦佸埌杈撳嚭閫氶亾銆傚湪spring integration涓紝璋冪敤鐨勬柟娉曡闄愬畾涓烘湰鍦版柟娉曡皟鐢ㄣ?br />


ROUTER錛岃礬鐢卞櫒錛屽皢杈撳叆鐨勬秷鎭礬鐢卞埌鏌愪釜杈撳嚭閫氶亾涓?/p>


SPLITTER錛屽皢杈撳叆鐨勬秷鎭媶鍒嗘垚瀛愭秷鎭?br />


AGGREGATOR錛屽皢杈撳叆鐨勫涓秷鎭悎騫朵負涓涓秷鎭?br />


3.瑙傜湅涔︿腑渚嬪瓙hello-world鎬濊?/p>

嫻嬭瘯gateway鏃訛紝涓嬮潰浠g爜鍚戦氶亾names鍐呮斁鍏ユ秷鎭痺orld錛?/p>


鐒跺悗service-activator浠巒ames閫氶亾涓幏寰楁秷鎭痺orld錛岃皟鐢ㄦ柟娉晄ayHello榪斿洖鍊煎埌緇檊ateway錛?/p>

瑙i噴錛歡ateway鏈変竴涓猻ervice錛峣nterface鐨勫睘鎬э紝榪欎釜灞炴ф寚鍚戜竴涓猧nterface銆傚綋鎴戜滑鐢ㄤ竴涓帴鍙e0鏄庝竴涓猤ateway鏃訛紝spring integration浼氳嚜鍔ㄥ府鎴戜滑鐢熸垚璇ユ帴鍙g殑浠g悊綾伙紝榪欐牱褰撴垜浠線gateway鍙戦佹秷鎭椂錛宻pring integration浼氶氳繃浠g悊綾繪妸娑堟伅杞彂鍒癲efault錛峳equest錛峜hannel涓幓



浣滆咃細椹浗鏍?br /> 閾炬帴錛歨ttps://www.jianshu.com/p/bf1643539f99
鏉ユ簮錛氱畝涔?br /> 綆涔﹁憲浣滄潈褰掍綔鑰呮墍鏈夛紝浠諱綍褰㈠紡鐨勮漿杞介兘璇瘋仈緋諱綔鑰呰幏寰楁巿鏉冨茍娉ㄦ槑鍑哄銆?/div>

paulwong 2019-06-05 10:36 鍙戣〃璇勮
]]>
濡備綍鍦⊿PRING INTEGRATION涓嬌鐢ㄤ簨鍔?/title><link>http://m.tkk7.com/paulwong/archive/2019/06/04/433836.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 04 Jun 2019 06:19:00 GMT</pubDate><guid>http://m.tkk7.com/paulwong/archive/2019/06/04/433836.html</guid><wfw:comment>http://m.tkk7.com/paulwong/comments/433836.html</wfw:comment><comments>http://m.tkk7.com/paulwong/archive/2019/06/04/433836.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/paulwong/comments/commentRss/433836.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/paulwong/services/trackbacks/433836.html</trackback:ping><description><![CDATA[<div>File Polling using the Spring Integration DSL</div> <a target="_blank">http://porterhead.blogspot.com/2016/07/file-polling-using-spring-integration.html</a> <br /><a target="_blank"><br />https://github.com/iainporter/spring-file-poller</a><br /><br /><br />Transaction Support in Spring Integration<br /><a target="_blank">https://www.baeldung.com/spring-integration-transaction</a><img src ="http://m.tkk7.com/paulwong/aggbug/433836.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/paulwong/" target="_blank">paulwong</a> 2019-06-04 14:19 <a href="http://m.tkk7.com/paulwong/archive/2019/06/04/433836.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鐢↗AMES瀹炵幇鑷繁鐨勯偖浠舵湇鍔″櫒http://m.tkk7.com/paulwong/archive/2012/12/16/393057.htmlpaulwongpaulwongSun, 16 Dec 2012 05:14:00 GMThttp://m.tkk7.com/paulwong/archive/2012/12/16/393057.htmlhttp://m.tkk7.com/paulwong/comments/393057.htmlhttp://m.tkk7.com/paulwong/archive/2012/12/16/393057.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/393057.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/393057.html 綆浠?br /> James 鏄竴涓紒涓氱駭鐨勯偖浠舵湇鍔″櫒錛屽畠瀹屽叏瀹炵幇浜唖mtp 鍜?pops 浠ュ強nntp 鍗忚銆傚悓鏃訛紝james鏈嶅姟鍣ㄥ張鏄竴涓偖浠跺簲鐢ㄧ▼搴忓鉤鍙般侸ames鐨勬牳蹇冩槸Mailet API,鑰宩ames 鏈嶅姟榻愭槸涓涓猰ailet鐨勫鍣ㄣ傚畠鍙互璁╀綘闈炲父瀹規槗鐨勫疄鐜板嚭寰堝己澶х殑閭歡搴旂敤紼嬪簭銆侸ames寮婧愰」鐩騫挎硾鐨勫簲鐢ㄤ簬涓庨偖浠舵湁鍏崇殑欏圭洰涓備綘鍙互閫氳繃瀹冩潵鎼緩鑷繁鐨勯偖浠舵湇鍔″櫒銆傛垜浠彲浠ュ埄鐢∕ailet API,緙栫▼鎺ュ彛鏉ュ疄鐜拌嚜宸辨墍闇鐨勪笟鍔°侸ames闆嗘垚浜咥valon 搴旂敤紼嬪簭妗嗘灦浠ュ強Phoenix Avalon 妗嗘灦瀹瑰櫒銆侾hoenix涓簀ames 鏈嶅姟鍣ㄦ彁渚涗簡寮哄ぇ鐨勬敮鎸併傞渶瑕佽鏄庣殑鏄疉valon寮婧愰」鐩洰鍓嶅凡緇忓叧闂?br /> 蹇熶笂鎵?br /> 瀹夎james
鎴戣繖嬈′嬌鐢ㄧ殑瀹夎鍖呮槸james 2.3.1銆傚ぇ瀹跺彲浠ヤ粠榪欓噷涓嬭澆鍒癶ttp://james.apache.org/download.cgi
鐜板湪璁╂垜浠紑濮嬫垜浠縺鍔ㄤ漢蹇冪殑james涔嬫梾銆傞鍏堟垜浠皢james-binary-2.3.1.zip瑙e帇緙╀笅杞藉埌浣犵殑瀹夎鐩綍銆傛垜浠彲浠ユ妸榪欎釜榪囩▼鐞嗚В涓哄畨瑁呯殑榪囩▼銆傛垜鍦ㄨ繖閲屽皢瀹冭В鍘嬪埌c:\.騫朵笖鎶婂畠鏀瑰悕涓簀ames.榪欐牱鎴戜滑鐨刯ames灝卞畨瑁呭ソ浜嗐傜洰褰曚負C:\james銆傚緢綆鍗曞惂錛?br />
鍑嗗鐭ヨ瘑 錛?瀛︿範涓浜涘繀瑕佺殑鐭ヨ瘑
鍦ㄦ垜浣跨敤james鐨勬椂鍊欒鎴戞劅瑙夐鍏堢悊瑙ames鐨勫簲鐢ㄧ▼搴忕粨鏋勬槸寰堥噸瑕佺殑銆傚惁鍒欎綘浼氬湪浣跨敤涓劅鍒板緢鍥版儜銆?br /> 瀹冪殑搴旂敤紼嬪簭緇撴瀯鏄繖鏍風殑錛?br /> James
|_ _apps
|_ _bin
|_ _conf
|_ _ext
|_ _lib
|_ _logs
|_ _tools
鎴戜滑閲嶇偣浠嬬粛涓涓嬩袱涓枃浠跺すbin 鍜?apps.
bin鐩綍涓殑run.bat鍜宺un.sh鏄疛ames鐨勫惎鍔ㄧ▼搴忋傚彧瑕佽浣忚繖涓噸瑕佹枃浠跺氨鍙互銆?br /> 鍚姩涔嬪悗鎺у埗鍙版樉紺哄涓嬶細
Using PHOENIX_HOME: C:\james
Using PHOENIX_TMPDIR: C:\james\temp
Using JAVA_HOME: C:\j2sdk1.4.2_02
Phoenix 4.2
James Mail Server 2.3.1
Remote Manager Service started plain:4555
POP3 Service started plain:110
SMTP Service started plain:25
NNTP Service started plain:119
FetchMail Disabled
Apps 鐩綍涓嬫湁涓猨ames鐨勫瓙鐩綍榪欎釜鐩綍鏄畠鐨勬牳蹇冦?br /> james
|_ _SAR-INF
|_ _conf
|_ _logs
|_ _var
|_mail
|_address-error
|_error
|_indexes
|_outgoing
|_relay-denied
|_spam
|_spool
|_nntp
|_....

|_users
SAR-INF 涓嬫湁涓涓猚onfig.xml鏄痡ames涓殑鏍稿績閰嶇疆鏂囦歡銆?br /> Logs 鍖呭惈浜嗕笌james鏈夊叧鐨凩og銆傝皟璇曞叏闈犲畠浜嗐?br /> Var 鍖呭惈浜嗕竴浜涙枃浠跺す閫氳繃瀹冧滑鐨勫悕瀛楁垜浠ぇ姒備篃鑳界寽嫻嬪嚭瀹冧滑鐨勭敤閫斻侻ail涓昏鐢ㄤ簬瀛樺偍閭歡銆俷ntp涓昏鐢ㄤ簬鏂伴椈鏈嶅姟鍣ㄣ俇sers鐢ㄤ簬瀛樺偍鎵鏈夐偖浠舵湇鍔″櫒鐨勭敤鎴楓備篃灝辨槸閭歡鍦板潃鍓嶉潰鐨勪笢涓溿傚錛歱ig@sina.com鐨刾ig灝辨槸鎵璋撶敤鐢ㄦ埛銆?br />
鍒涘緩鐢ㄦ埛錛?br /> 鎴戜滑鍦↗ames涓婂緩鑻ュ共鐢ㄦ埛錛岀敤鏉ユ祴璇曟敹鍙戦偖浠躲傚綋鐒跺鏋滀綘涓嶇敤james鏈韓鐨勭敤鎴蜂篃鍙互銆侸ames浠elnet 鐨勬柟寮忔彁渚涗簡鎺ュ彛鐢ㄦ潵娣誨姞鐢ㄦ埛銆備笅闈㈡垜鏉ユ紨紺轟竴涓嬨?br /> 棣栧厛浣跨敤telnet鏉ヨ繛鎺ames鐨剅emote manager .
1.telnet localhost 4555 鍥炶濺
2.鐒跺悗杈撳叆綆$悊鍛樼敤鎴峰悕鍜屽瘑鐮侊紙user/pwd 錛?root/root 鏄粯璁よ緗繖涓彲浠ュ湪config.xml涓慨鏀癸級
JAMES Remote Administration Tool 2.3.1
Please enter your login and password
Login id:
root
Password:
root
Welcome root. HELP for a list of commands

3.娣誨姞鐢ㄦ埛
adduser kakaxi kakaxi
User kakaxi added

Adduser mingren mingren
User mingren added

4.鏌ョ湅娣誨姞鎯呭喌
listusers
Existing accounts 2
user: mingren
user: kakaxi
寰楀埌涓婇潰鐨勪俊鎭鏄庢垜浠凡緇忔坊鍔犳垚鍔熴?br />

鍙戦佸櫒
榪欎釜綾諱富瑕佺敤鏉ユ祴璇曟垜浠殑閭歡鏈嶅姟鍣紝鍙互涓嶇敤灝嗗叾鎵撳叆鍖呬腑銆?br /> java 浠g爜 
package com.paul.jamesstudy;   
  
import java.util.Date;   
import java.util.Properties;   
  
import javax.mail.Authenticator;   
import javax.mail.Message;   
import javax.mail.PasswordAuthentication;   
import javax.mail.Session;   
import javax.mail.Transport;   
import javax.mail.internet.InternetAddress;   
import javax.mail.internet.MimeMessage;   
  
public class Mail {   
    private String mailServer, From, To, mailSubject, MailContent;   
  
    private String username, password;   
  
    private Session mailSession;   
  
    private Properties prop;   
  
    private Message message;   
  
    // Authenticator auth;//璁よ瘉   
    public Mail() {   
        // 璁劇疆閭歡鐩稿叧   
        username = "kakaxi";   
        password = "kakaxi";   
        mailServer = "localhost";   
        From = "kakaxi@localhost";   
        To = "mingren@localhost";   
        mailSubject = "Hello Scientist";   
        MailContent = "How are you today!";   
    }   
    public void send(){   
        EmailAuthenticator mailauth =    
new EmailAuthenticator(username, password);   
        // 璁劇疆閭歡鏈嶅姟鍣?nbsp;  
        prop = System.getProperties();   
        prop.put("mail.smtp.auth", "true");   
        prop.put("mail.smtp.host", mailServer);   
        // 浜х敓鏂扮殑Session鏈嶅姟   
        mailSession = mailSession.getDefaultInstance(prop,   
                (Authenticator) mailauth);   
        message = new MimeMessage(mailSession);   
  
        try {   
        message.setFrom(new InternetAddress(From)); // 璁劇疆鍙戜歡浜?nbsp;  
        message.setRecipient(Message.RecipientType.TO,    
new InternetAddress(To));// 璁劇疆鏀朵歡浜?nbsp;  
        message.setSubject(mailSubject);// 璁劇疆涓婚   
        message.setContent(MailContent, "text/plain");// 璁劇疆鍐呭   
        message.setSentDate(new Date());// 璁劇疆鏃ユ湡   
        Transport tran = mailSession.getTransport("smtp");   
        tran.connect(mailServer, username, password);   
        tran.send(message, message.getAllRecipients());   
        tran.close();   
        } catch (Exception e) {   
            e.printStackTrace();   
        }   
    }   
    public static void main(String[] args) {   
        Mail mail;   
        mail = new Mail();   
        System.out.println("sending");   
        mail.send();   
        System.out.println("finished!");   
    }   
  
}   
  
class EmailAuthenticator extends Authenticator {   
    private String m_username = null;   
  
    private String m_userpass = null;   
  
    void setUsername(String username) {   
        m_username = username;   
    }   
  
    void setUserpass(String userpass) {   
        m_userpass = userpass;   
    }   
  
    public EmailAuthenticator(String username, String userpass) {   
        super();   
        setUsername(username);   
        setUserpass(userpass);   
    }   
  
    public PasswordAuthentication getPasswordAuthentication() {   
        return new PasswordAuthentication(m_username, m_userpass);   
    }   
}   




paulwong 2012-12-16 13:14 鍙戣〃璇勮
]]>
SRING INTEGRATION + BATCHhttp://m.tkk7.com/paulwong/archive/2012/10/21/389968.htmlpaulwongpaulwongSun, 21 Oct 2012 09:23:00 GMThttp://m.tkk7.com/paulwong/archive/2012/10/21/389968.htmlhttp://m.tkk7.com/paulwong/comments/389968.htmlhttp://m.tkk7.com/paulwong/archive/2012/10/21/389968.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/389968.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/389968.html闃呰鍏ㄦ枃

paulwong 2012-10-21 17:23 鍙戣〃璇勮
]]>
spring integration鍚屾鏁版嵁搴撴暟鎹?/title><link>http://m.tkk7.com/paulwong/archive/2012/10/17/389716.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Wed, 17 Oct 2012 03:50:00 GMT</pubDate><guid>http://m.tkk7.com/paulwong/archive/2012/10/17/389716.html</guid><wfw:comment>http://m.tkk7.com/paulwong/comments/389716.html</wfw:comment><comments>http://m.tkk7.com/paulwong/archive/2012/10/17/389716.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/paulwong/comments/commentRss/389716.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/paulwong/services/trackbacks/389716.html</trackback:ping><description><![CDATA[     鎽樿: 闇姹備負錛氬綋瀹㈡埛宸叉湁緋葷粺鐨勬暟鎹鍚屾鍒版垜鏂規暟鎹簱鍚庯紝鑻ュ啀鏈夋柊鏁版嵁錛屽彧鍚屾鏂版暟鎹埌鎴戞柟鏁版嵁搴撱傝В鍐籌細鍥犱負瀹㈡埛鐨勪笟鍔¤〃鏄笉鑳藉彉鍔ㄧ殑錛屾垜鏂瑰湪瀹㈡埛鏁版嵁搴撲腑鏂板緩涓鐘舵佽〃錛岃褰曞摢浜涙暟鎹鏇存柊榪囥傚綋瀹㈡埛涓氬姟琛ㄦ湁鏂版暟鎹彃鍏ユ椂錛岀敤瑙﹀彂鍣ㄥ皢鏂版暟鎹甶d鎻掑叆鍒扮姸鎬佽〃銆備負鏂逛究瀹炰緥錛氫笟鍔¤〃pp錛岀姸鎬佽〃status緇撴瀯涓猴細pp錛? Code highlighting produced by Actipro CodeHighli...  <a href='http://m.tkk7.com/paulwong/archive/2012/10/17/389716.html'>闃呰鍏ㄦ枃</a><img src ="http://m.tkk7.com/paulwong/aggbug/389716.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/paulwong/" target="_blank">paulwong</a> 2012-10-17 11:50 <a href="http://m.tkk7.com/paulwong/archive/2012/10/17/389716.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>SPRING INTEGRATION + SPRING BATCHhttp://m.tkk7.com/paulwong/archive/2012/10/16/389625.htmlpaulwongpaulwongMon, 15 Oct 2012 16:11:00 GMThttp://m.tkk7.com/paulwong/archive/2012/10/16/389625.htmlhttp://m.tkk7.com/paulwong/comments/389625.htmlhttp://m.tkk7.com/paulwong/archive/2012/10/16/389625.html#Feedback7http://m.tkk7.com/paulwong/comments/commentRss/389625.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/389625.html闃呰鍏ㄦ枃

paulwong 2012-10-16 00:11 鍙戣〃璇勮
]]>
SPRING INTERGRATION璧勬簮http://m.tkk7.com/paulwong/archive/2012/06/11/380483.htmlpaulwongpaulwongMon, 11 Jun 2012 02:07:00 GMThttp://m.tkk7.com/paulwong/archive/2012/06/11/380483.htmlhttp://m.tkk7.com/paulwong/comments/380483.htmlhttp://m.tkk7.com/paulwong/archive/2012/06/11/380483.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/380483.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/380483.html http://wangleifire.iteye.com/blog/351749



paulwong 2012-06-11 10:07 鍙戣〃璇勮
]]>
SPRING INTERGRATIONhttp://m.tkk7.com/paulwong/archive/2012/06/11/380482.htmlpaulwongpaulwongMon, 11 Jun 2012 02:04:00 GMThttp://m.tkk7.com/paulwong/archive/2012/06/11/380482.htmlhttp://m.tkk7.com/paulwong/comments/380482.htmlhttp://m.tkk7.com/paulwong/archive/2012/06/11/380482.html#Feedback0http://m.tkk7.com/paulwong/comments/commentRss/380482.htmlhttp://m.tkk7.com/paulwong/services/trackbacks/380482.html灝嗗鐞嗕笟鍔$殑嫻佺▼鎷嗗垎鎴愪竴涓竴涓摼錛屽墠闈㈠鐞嗗畬錛屽啀媧劇粰涓嬩竴涓紝綾諱技HTTP涓殑FILTER
涓嶇敤瀹夎鏈嶅姟鍣紝鍐呭祵鍦⊿PRING瀹瑰櫒涓紝瀵瑰鏀寔澶氱鏍煎紡鐨勬暟鎹紝澶栭儴緋葷粺濡傝鍜孲PRING INTERGRATION鏁村悎錛屼笉闇瑕佸啀榪涜寮鍙?br />澶勭悊嫻佺▼涓鑸氨鏄紝ADAPTER鍘昏鍙栧閮ㄦ暟鎹紝杞崲鍚庢斁鍒癈HANNEL涓紝ENDPOINT澶勭悊CHANNEL涓殑鏁版嵁錛屽媧劇粰涓嬩竴涓狢HANNEL錛屼笅涓涓狤NDPOINT澶勭悊錛岄氳繃ADAPTER鍐欏埌澶栭儴鎺ュ彛涓?br />
  1. ADAPTER
    澶栭儴緋葷粺涓嶤HANNEL涔嬮棿鐨勬ˉ姊侊紝鑾峰彇澶栭儴鏁版嵁灝嗗叾鏀懼埌CHANNEL鍘伙紝鏈塅TP錛孞MS錛屾枃浠剁郴緇熺殑

  2. CHANNEL
    閲岄潰鏀綧ESSAGE瀵硅薄錛孧ESSAGE閲岄潰鍙互鏀捐嚜瀹氫箟瀵硅薄錛屼互鎻愪緵娑堣垂鑰呬嬌鐢?br />
  3. ENDPOINT
    CHANNEL鐨勬秷璐硅咃紝CHANNEL涓嶦NDPOINT鏄竴瀵逛竴鐨勫叧緋伙紝鎵浠ュ鏋滄兂鍦ㄤ竴涓狢HANNE涓嬪搴斿涓狤NDPOINT錛屾槸鍋氫笉鍒扮殑錛屽彧鑳藉鍔燙HANNEL

    Service Activators錛氫粠INPUT CHANNEL涓彇鍑轟竴涓璞′綔涓哄弬鏁幫紝璋冪敤璁劇疆鐨凱OJO鐨勬柟娉曪紝灝嗙粨鏋滄斁鍒癘UTPUT CHANNEL涓?br />Transformers錛氬CHANNEL涓殑瀵硅薄榪涜綾誨瀷杞崲
    鍐沖畾嫻佸悜鐨凟NDPOINT錛歊outers錛孲PLITER

  4. 渚嬪瓙
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans
="http://www.springframework.org/schema/beans"
    xmlns:stream
="http://www.springframework.org/schema/integration/stream"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/integration
            http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/integration/stream
            http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd"
>

    
<gateway id="cafe" service-interface="org.springframework.integration.samples.cafe.Cafe"/>

    
<channel id="orders"/>
    
<!-- 姝ゅorders閲岄潰鐨勫璞℃槸涓涓竴涓狹essage錛岃皟鐢╬ayload鍒欏彇鍒癘rder
         璋冪敤items鍒欏緱鍒癘rderItem List錛屾媶鍒嗘垚OrderItem浠ヤ竴涓負鍗曚綅鏀懼埌
         drinks涓?br />     
-->
    
<splitter input-channel="orders" expression="payload.items" output-channel="drinks"/>

    
<channel id="drinks"/>
    
<!-- 姝ゅdrinks閲岄潰鐨勫璞℃槸涓涓竴涓狾rderItem錛岃皟鐢╥ced鍒欏彇鍒板竷灝斿?br />         濡傛灉鏄痶rue鍒欐斁鍒癱oldDrinks涓紝濡傛槸false鍒欐斁鍒癶otDrinks涓?br />     -->
    
<router input-channel="drinks"  expression="payload.iced ? 'coldDrinks' : 'hotDrinks'"/>

    
<channel id="coldDrinks">
        
<queue capacity="10"/>
    
</channel>
    
<service-activator input-channel="coldDrinks" ref="barista" method="prepareColdDrink" output-channel="preparedDrinks"/>

    
<channel id="hotDrinks">
        
<queue capacity="10"/>
    
</channel>
    
<!-- 灝嗚緭鍏ラ氶亾涓殑OrderItem杞垚Drink -->
    
<service-activator input-channel="hotDrinks" ref="barista" method="prepareHotDrink" output-channel="preparedDrinks"/>

    
<channel id="preparedDrinks"/>
    
<!-- 灝嗛氶亾涓殑Drink鎸変竴涓狾rder榪涜鍚堝茍鎴愪竴涓狶ist<Order>-->
    
<aggregator input-channel="preparedDrinks"  method="prepareDelivery" output-channel="deliveries">
        
<beans:bean class="org.springframework.integration.samples.cafe.xml.Waiter"/>
    
</aggregator>

    
<stream:stdout-channel-adapter id="deliveries"/>

    
<beans:bean id="barista" class="org.springframework.integration.samples.cafe.xml.Barista"/>

    
<poller id="poller" default="true" fixed-delay="1000"/>

</beans:beans>


paulwong 2012-06-11 10:04 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 狠狠色香婷婷久久亚洲精品| 国产精品自在自线免费观看| 亚洲视频一区二区| 亚洲国产精品无码第一区二区三区| 久久久久久AV无码免费网站下载 | 免费的黄色的网站| 99精品全国免费观看视频| 亚洲国产成人精品无码区在线秒播 | 野花香高清在线观看视频播放免费| 国产在线播放免费| 亚洲国产精品无码久久98| 三年片在线观看免费观看大全一| 久久亚洲国产午夜精品理论片| 4hu四虎免费影院www| 亚洲精品乱码久久久久久蜜桃不卡| 日韩精品无码免费专区午夜 | 免费大片在线观看网站| 久久无码av亚洲精品色午夜 | 亚洲国产人成在线观看69网站| 久久久久久国产精品免费免费男同 | 毛片免费在线观看网站| 亚洲一区二区三区免费观看| 日韩精品福利片午夜免费观着 | xxxxx做受大片视频免费| 亚洲色欲色欲www在线丝| 久久成人免费大片| 亚洲综合伊人制服丝袜美腿| 日韩在线免费看网站| 日韩在线观看视频免费| 在线a亚洲v天堂网2019无码| 日韩在线永久免费播放| 亚洲一区二区三区播放在线| 国产zzjjzzjj视频全免费| 三年在线观看免费观看完整版中文| 亚洲网站在线观看| 日韩免费a级在线观看| 成人毛片100免费观看| 亚洲一级黄色大片| 亚洲无码日韩精品第一页| 亚欧色视频在线观看免费| 色www免费视频|