Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在spring批处理中拆分和联接流,以配置作业中的设置和拆卸步骤_Java_Spring_Multithreading_Spring Batch - Fatal编程技术网

Java 如何在spring批处理中拆分和联接流,以配置作业中的设置和拆卸步骤

Java 如何在spring批处理中拆分和联接流,以配置作业中的设置和拆卸步骤,java,spring,multithreading,spring-batch,Java,Spring,Multithreading,Spring Batch,我已经检查过了,发现(a)标记的解决方案没有解析,因为拆分是不可访问的,(b)我的用例不同,所以答案的意图不同 我也回顾过,但解决方案是增加并行化,而不是拆分和连接线程 这似乎是一个足够常见的用例,应该是一个常见问题,但我还没有看到解决方案 我有一个并行化的spring批处理作业,我想在其中添加设置和拆卸步骤。安装和拆卸是单线程的,但主体工作是并行的 随着时间的推移,以不同的方式绘制事件: start setup | split -----

我已经检查过了,发现(a)标记的解决方案没有解析,因为拆分是不可访问的,(b)我的用例不同,所以答案的意图不同

我也回顾过,但解决方案是增加并行化,而不是拆分和连接线程

这似乎是一个足够常见的用例,应该是一个常见问题,但我还没有看到解决方案

我有一个并行化的spring批处理作业,我想在其中添加设置和拆卸步骤。安装和拆卸是单线程的,但主体工作是并行的

随着时间的推移,以不同的方式绘制事件:

start        setup
               |
split       -------
            |     |
         some    other
         stuff   stuff
            |     |
join        -------
               |
finish      teardown
我开始使用的spring批处理作业XML是:

<batch:job id="myJob">

    <batch:step id="step0001-setup">
        <batch:tasklet transaction-manager="jtaTransactionManager"
            start-limit="100" allow-start-if-complete="true">
            <batch:chunk reader="beforeJobScriptExecutor" writer="dummySinkWriter"
                commit-interval="1" />
        </batch:tasklet>
    </batch:step>


    <batch:split id="split1" task-executor="taskExecutor" next="step9999">

        <batch:flow>
            <batch:step id="step0003-one-thread"
                allow-start-if-complete="true">
                <batch:tasklet transaction-manager="jtaTransactionManager"
                    start-limit="100">
                    <batch:chunk reader="myReader1" writer="myWriter1"
                        commit-interval="1" />
                </batch:tasklet>
            </batch:step>
        </batch:flow>

        <batch:flow>
            <batch:step id="step0002-another-thread">
                <batch:tasklet transaction-manager="jtaTransactionManager"
                    start-limit="100">
                    <batch:chunk reader="myReader2" writer="myWriter2"
                        commit-interval="1" />
                </batch:tasklet>
            </batch:step>
        </batch:flow>

    </batch:split>


    <batch:step id="step9999">
        <batch:tasklet transaction-manager="jtaTransactionManager"
            start-limit="100" allow-start-if-complete="true">
            <batch:chunk reader="afterJobScriptExecutor" writer="dummySinkWriter"
                commit-interval="1" />
        </batch:tasklet>
    </batch:step>
</batch:job>

本帖主要概述了解决方案:

spring批处理作业的最终文本如下:

<batch:job id="myJob">

    <batch:step id="step0001-setup">
        <batch:tasklet transaction-manager="jtaTransactionManager"
            start-limit="100" allow-start-if-complete="true">
            <batch:chunk reader="beforeJobScriptExecutor" writer="dummySinkWriter"
                commit-interval="1" />
        </batch:tasklet>
        <batch:end on="FAILED" />
        <batch:next on="*" to="split1" />
    </batch:step>


    <batch:split id="split1" task-executor="taskExecutor" next="step9999">

        <batch:flow>
            <batch:step id="step0003-one-thread"
                allow-start-if-complete="true">
                <batch:tasklet transaction-manager="jtaTransactionManager"
                    start-limit="100">
                    <batch:chunk reader="myReader1" writer="myWriter1"
                        commit-interval="1" />
                </batch:tasklet>
            </batch:step>
        </batch:flow>

        <batch:flow>
            <batch:step id="step0002-another-thread">
                <batch:tasklet transaction-manager="jtaTransactionManager"
                    start-limit="100">
                    <batch:chunk reader="myReader2" writer="myWriter2"
                        commit-interval="1" />
                </batch:tasklet>
            </batch:step>
        </batch:flow>

    </batch:split>


    <batch:step id="step9999">
        <batch:tasklet transaction-manager="jtaTransactionManager"
            start-limit="100" allow-start-if-complete="true">
            <batch:chunk reader="afterJobScriptExecutor" writer="dummySinkWriter"
                commit-interval="1" />
        </batch:tasklet>
    </batch:step>
</batch:job>