<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    #

    Java 9 Flow API 學習

    https://mrbird.cc/Java-9-Flow-API-Learn.html

    posted @ 2021-09-02 15:39 paulwong 閱讀(203) | 評論 (0)編輯 收藏

    httpClient連接自制SSL證書的rest服務

    通常如果rest服務支持https,需申請收費的ssl證書,但也可自制這種證書。
    httpClient進行鏈接時要進行相應的設置, 主要是設置SSLContext中的TrustSelfSignedStrategy

    import java.security.KeyManagementException;
    import java.security.KeyStoreException;
    import java.security.NoSuchAlgorithmException;
    import java.util.concurrent.TimeUnit;

    import javax.net.ssl.SSLContext;

    import org.apache.http.client.config.RequestConfig;
    import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
    import org.apache.http.impl.client.CloseableHttpClient;
    import org.apache.http.impl.client.HttpClients;
    import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
    import org.apache.http.ssl.SSLContexts;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;


    @Configuration
    public class HttpClientConfiguration {
        
        
        @Bean
        public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager(AbstractProperties kycProperties) {
            PoolingHttpClientConnectionManager result = 
                    new PoolingHttpClientConnectionManager(
                            kycProperties.getHttpConnectionTimeToLiveMinu(), 
                            TimeUnit.MINUTES
                        );
            result.setMaxTotal(200);
            result.setDefaultMaxPerRoute(20);
            return result;
        }

        @Bean
        public RequestConfig requestConfig(AbstractProperties kycProperties) {
            return RequestConfig
                        .custom()
                      .setConnectionRequestTimeout(kycProperties.getHttpConnectionTimeout())
                      .setConnectTimeout(kycProperties.getHttpConnectionTimeout())
                      .setSocketTimeout(kycProperties.getHttpConnectionTimeout())
                      .build();
        }
        
        @Bean
        public SSLContext sslContext() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {

            return SSLContexts
                        .custom()
                        .loadTrustMaterial(nullnew TrustSelfSignedStrategy())
                        .build()
                        ;
        }

        @Bean
        public CloseableHttpClient httpClient(AbstractProperties kycProperties) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
            return HttpClients
                      .custom()
    //                  .setConnectionManager(poolingHttpClientConnectionManager(null))
                      .setDefaultRequestConfig(requestConfig(null))
                      .setKeepAliveStrategy(
                              new MyConnectionKeepAliveStrategy(
                                      kycProperties.getHttpConnectionTimeToLiveMinu(), 
                                      TimeUnit.MINUTES
                                  )
                       )
                      .setMaxConnTotal(200)
                      .setMaxConnPerRoute(20)
    //                  .setConnectionTimeToLive(
    //                          kycProperties.getHttpConnectionTimeToLiveMinu(), 
    //                          TimeUnit.MINUTES
    //                   )
                      .setSSLContext(sslContext())
                      .build();
        }

    }

    相應設置
    http-connection-timeout: 30000
    http-connection-time-to-live-minu: 5

    posted @ 2021-09-01 14:24 paulwong 閱讀(378) | 評論 (0)編輯 收藏

    nginx 之 proxy_pass詳解

    https://www.jianshu.com/p/b010c9302cd0

    posted @ 2021-08-30 15:16 paulwong 閱讀(168) | 評論 (0)編輯 收藏

    LINUX下循環讀取文件參數并CURL遠程API

    一系列參數存于文本文件,需在LINUX下循環讀取,之后以此參數進行CURL遠程API調用,同時需記錄每次CURL的總時間

    參數文件,test1.json
    {"ADDRESS_FREE":"XXX","NAME":{"SURNAME":"XXX","FIRST_NAME":"XXX"}}
    {"ADDRESS_FREE":"XXX","NAME":{"SURNAME":"XXX","FIRST_NAME":"XXX"}}
    {"ADDRESS_FREE":"XXX","NAME":{"SURNAME":"XXX","FIRST_NAME":"XXX"}}

    test1.sh
    #! /bin/bash

    RESULT_FILE="result.csv"
    echo "" > $RESULT_FILE
    i=1
    while read line || [[ "$line" ]] #In case the file has an incomplete (missing newline) last line, you could use this alternative:
    do 
        echo "$i"
        printf "$i;$line;" >> $RESULT_FILE
        curl -w %{time_total} -o /dev/null -X POST -H "Content-Type:application/json" -d "$line" http://ip:port  >> $RESULT_FILE
        #printf "\n\r" >> $RESULT_FILE
        echo "" >> $RESULT_FILE
        #i=$(( $i + 1 ))
        (( i++ ))
    done < test1.json

    Reference:
    https://stackoverflow.com/questions/30988586/creating-an-array-from-a-text-file-in-bash









    posted @ 2021-08-26 15:40 paulwong 閱讀(525) | 評論 (0)編輯 收藏

    免注冊JDK下載

    https://repo.huaweicloud.com/java/jdk/

    posted @ 2021-08-25 16:17 paulwong 閱讀(284) | 評論 (0)編輯 收藏

    SPRING INTEGRATION RETRY

    當使用httpOutBoundGateway時,有時會碰到網絡抖動問題而出現連接異常,這時應該有個重試機制,如隔多少秒重試,重試多少次后放棄等。
    默認是重試3次,每次重試間隔是20秒。

    @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


    posted @ 2021-08-23 13:01 paulwong 閱讀(251) | 評論 (0)編輯 收藏

    Gitee代碼托管實踐:讓代碼變得更加有序可靠

    https://my.oschina.net/gitosc/blog/5187695

    posted @ 2021-08-20 14:49 paulwong 閱讀(175) | 評論 (0)編輯 收藏

    Git/EGit | reset 和 revert 的區別

    git的世界里有后悔藥嗎?

    有的。不僅有,還不止一種:Reset 和 Revert。它們有什么區別呢?先說結論吧。

    ResetRevert
    作用 將某個commit之后的push全部回滾 將某個指定的commit回滾
    歷史記錄(軌跡)
    是否可作用于單個文件 否(都是作用于commit,與文件無關)

    下面來說說具體例子。

    Revert

    試驗步驟如下:

    1. 新建兩個空白文件 Revert.txt 和 Common.txt,然后commit&push。
    2. 修改 Revert.txt 文件,內容為“commit 1”,然后commit&push,提交的備注為“commit 1 of Revert”
    3. 修改 Common.txt 文件,內容為“update for Revert(by commit 2)”
    4. 修改 Revert.txt 文件,新增一行,內容為“commit 2”
    5. 3 和 4的修改一起commit&push,提交備注為“commit 2 of Revert(Revert.txt + Common.txt)”

    效果如下:

    git-revert-01

    圖1-revert之前

    目的

    保留3的修改,回滾4的修改。

    操作

    選中“ Revert.txt ”文件,然后在 History 里選中 “commit 2 of Revert…”,右鍵,找到“Revert Commit”菜單,如圖:

    git-revert-02

    圖2-revert操作

    點擊后,效果如圖:

    git-revert-03

    圖3-revert之后

    最后,push即可。

    結果

    未能達到預期效果,Revert.txt 和 Common.txt的修改都被撤銷了。Revert的作用范圍是一個commit(原子),跟文件的個數無關。

    注:對最后一個commit做revert比較簡單,兩步:一,revert;二,push就可以了。對于較早的commit,因為中間間隔了其他的commit,文件會有沖突,需要處理完沖突才可以commit&push。

    Reset

    試驗步驟如下:

    1. 新建空白文件 Reset.txt,然后commit&push。
    2. 修改 Reset.txt 文件,內容為“commit 1”
    3. 修改 Common.txt 文件,內容為“update for Reset(commit 1)”
    4. 2和3的修改一起commit&push,提交的備注為“commit 1 of Reset”
    5. 修改 Reset.txt 文件,新增一行,內容為“commit 2”,然后commit&push,提交的備注為“commit 2 of Reset”
    6. 修改 Reset.txt 文件,內容為“commit 3”
    7. 修改 Common.txt 文件,內容為“update for Reset(commit 3)”
    8. 6和7的修改一起commit&push,提交的備注為“commit 3 of Reset”

    效果如下:

    git-reset-04

    圖4-reset之前

    目的

    將commit 1 之后的(即commit 2 和 3)改動全部回滾。

    操作

    在 History 里找到“commit 1”,選中后,右鍵,找到 Reset 菜單,選擇 Hard 模式。

    git-reset-05

    圖5-reset

    執行后,如下圖所示,HEAD 已經指向里 commit 1,Common.txt 和 Reset.txt 的內容也已改變。注意左側的項目欄,它已落后了服務器(GitHub)2個commit。怎么提交到服務器上呢?直接push,它會提示不是最新的,操作失敗。這里要用到 push 的 force 屬性。

    git-reset-06

    圖6-reset之后

    選中 項目,右鍵 – Team – Remote – Configure Push to Upstream,在打開的小窗口中找到 Advanced,如下圖所示,這里的 Force Update 要勾上,表示強制覆蓋。

    重新push,就可以跟服務器保持同步了。

    git-reset-07

    圖7-push-force

    要特別注意的是,Reset慎用,跟Linux的“rm -rf /”有異曲同工之妙。

    http://www.youngzy.com/blog/2019/08/git-difference-between-reset-and-revert-using-eclipse/

    posted @ 2021-08-17 10:37 paulwong 閱讀(219) | 評論 (0)編輯 收藏

    Jenkins environment variables

    https://medium.com/@mukeshsingal/access-jenkins-global-environment-variables-using-groovy-or-java-b5c1e6b53685

    posted @ 2021-08-16 15:46 paulwong 閱讀(201) | 評論 (0)編輯 收藏

    怎么提高自己的系統架構水平

    https://my.oschina.net/u/4662964/blog/5135740

    posted @ 2021-08-04 11:05 paulwong 閱讀(185) | 評論 (0)編輯 收藏

    僅列出標題
    共115頁: First 上一頁 7 8 9 10 11 12 13 14 15 下一頁 Last 
    主站蜘蛛池模板: 好男人视频在线观看免费看片| 浮力影院第一页小视频国产在线观看免费| 亚洲视频一区在线播放| 青春禁区视频在线观看直播免费| 国产精品亚洲精品日韩动图 | 国产黄色片在线免费观看| www永久免费视频| 亚洲精品国产手机| 亚洲色偷偷狠狠综合网| 99久久国产免费中文无字幕| 亚洲a∨国产av综合av下载| 久久久久亚洲AV成人无码| 成人毛片免费在线观看| 国内永久免费crm系统z在线| 亚洲欧美日韩中文无线码 | 中国好声音第二季免费播放| 亚洲日本乱码一区二区在线二产线 | 亚洲伊人色欲综合网| 久久精品免费一区二区喷潮| h片在线观看免费| 亚洲 日韩经典 中文字幕| 亚洲伊人色欲综合网| 国产免费观看黄AV片| 5555在线播放免费播放| 国产免费久久精品丫丫| 亚洲性色AV日韩在线观看| 亚洲va在线va天堂va888www| 日韩精品亚洲专区在线观看| 国产精品永久免费10000| a国产成人免费视频| 爱爱帝国亚洲一区二区三区| 亚洲人成777在线播放| 亚洲AV综合色区无码一区爱AV| 啊v在线免费观看| 91在线视频免费91| 一级毛片在线观看免费| 国产99久久久久久免费看| 亚洲色www永久网站| 亚洲理论精品午夜电影| 99亚洲精品高清一二区| 91麻豆国产自产在线观看亚洲 |