??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品乱码久久久久久日本蜜臀 ,亚洲综合第一,av亚洲一区二区三区http://www.aygfsteel.com/paulwong/category/52669.htmlzh-cnTue, 23 Mar 2021 03:20:50 GMTTue, 23 Mar 2021 03:20:50 GMT60csv 文g打开qQ有哪些Ҏ(gu)可以解决Q?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 23 Mar 2021 02:30:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435832.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435832.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435832.html</trackback:ping><description><![CDATA[Excel 在读?csv 的时候是通过d文g头上?bom 来识别编码的Q这D如果我们生成 csv 文g的^台输出无 bom 头编码的 csv 文gQ例?utf-8 Q在标准中默认是可以没有 bom 头的Q,Excel 只能自动按照默认~码dQ不一致就?x)出Cؕ码问题(sh)(jin)?br /><br />掌握?jin)这点相信ؕ码已l无法阻挡我们前q的步伐?jin)?x)只需不?bom 头编码的 csv 文gQ用文本~辑器(工具随意Q推?notepad++ Q打开q{换ؓ(f)?bom 的编码Ş式(具体~码方式随意Q,问题解决?br /><br />当然Q如果你是像我一L(fng)码农哥哥Q在生成 csv 文g的时候写?bom 头更直接点,用户?x)感谢你的?br /><br />附录Q对?utf-8 ~码Qunicode 标准中是没有 bom 定义的,微Y在自q utf-8 格式的文本文件之前加上了(jin)EF BB BF三个字节作ؓ(f)识别此编码的 bom _(d)q也解释?jin)?f)啥大部分q都是 utf-8 ~码D的原?br /><br />SPRING BATCH中生成CSV文g时的解决Ҏ(gu)Q?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; ">new</span> FlatFileItemWriterBuilder<T>()<br />      .name(itemWriterName)<br />      .resource(outputResource)<br />      .lineAggregator(lineAggregator)<br />      .headerCallback(<br />      h -> {<br />               System.out.println(header);<br />               h.write('\uFEFF');<span style="color: #008000; ">//</span><span style="color: #008000; ">只需加这一?/span><span style="color: #008000; "><br /></span>               h.write(header);<br />           }<br />      )<br />      .build();</div><br /><a target="_blank">https://stackoverflow.com/questions/48952319/send-csv-file-encoded-in-utf-8-with-bom-in-java</a><br /><img src ="http://www.aygfsteel.com/paulwong/aggbug/435832.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-03-23 10:30 <a href="http://www.aygfsteel.com/paulwong/archive/2021/03/23/435832.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SPRING BATCH中STEP如果没加TRANSACTION MANAGERhttp://www.aygfsteel.com/paulwong/archive/2020/03/16/435267.htmlpaulwongpaulwongMon, 16 Mar 2020 01:43:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/03/16/435267.htmlhttp://www.aygfsteel.com/paulwong/comments/435267.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/03/16/435267.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435267.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435267.html
+------------+--------------+-------------+-----------------+------------------+--------------------+----------------+-----------+-------------------------
 | READ_COUNT | FILTER_COUNT | WRITE_COUNT | READ_SKIP_COUNT | WRITE_SKIP_COUNT | PROCESS_SKIP_COUNT | ROLLBACK_COUNT | EXIT_CODE | EXIT_MESSAGE
-+------------+--------------+-------------+-----------------+------------------+--------------------+----------------+-----------+-------------------------
 |          1 |            0 |           1 |               0 |                0 |                  0 |              0 | COMPLETED |
 |      30006 |            0 |       29947 |               0 |               59 |                  0 |             61 | COMPLETED | Waited for 101 results.

如上面的L?0006Q但COMMIT的L?9947Q有59个被跌?jin)?br />
因此需在STEP上加TRANSACTION MANAGER.

https://stackoverflow.com/questions/42803941/spring-batch-incorrect-write-skip-count-issue



paulwong 2020-03-16 09:43 发表评论
]]>
使用 Spring Batch 构徏企业U批处理应用-2http://www.aygfsteel.com/paulwong/archive/2020/03/06/435226.htmlpaulwongpaulwongFri, 06 Mar 2020 05:47:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/03/06/435226.htmlhttp://www.aygfsteel.com/paulwong/comments/435226.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/03/06/435226.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435226.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435226.html阅读全文

paulwong 2020-03-06 13:47 发表评论
]]>
使用 Spring Batch 构徏企业U批处理应用-1http://www.aygfsteel.com/paulwong/archive/2020/03/06/435225.htmlpaulwongpaulwongFri, 06 Mar 2020 05:45:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/03/06/435225.htmlhttp://www.aygfsteel.com/paulwong/comments/435225.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/03/06/435225.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435225.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435225.html阅读全文

paulwong 2020-03-06 13:45 发表评论
]]>
配置SPRING BATCH中的JUNIT TESThttp://www.aygfsteel.com/paulwong/archive/2020/02/03/435063.htmlpaulwongpaulwongMon, 03 Feb 2020 08:47:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/02/03/435063.htmlhttp://www.aygfsteel.com/paulwong/comments/435063.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/02/03/435063.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435063.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435063.html
    @Configuration
    public class BatchTestConfiguration {
        
        
        @Bean
        public JobLauncherTestUtils stoppedReportJobLauncherTestUtils(
                JobLauncher stoppedReportJobLauncher
        ) {
            return new JobLauncherTestUtils() {
                
                @Autowired
                public void setJobLauncher(JobLauncher stoppedReportJobLauncher) {
                    super.setJobLauncher(stoppedReportJobLauncher);
                }

                @Autowired
                public void setJob(Job stoppedReportJob) {
                    super.setJob(stoppedReportJob);
                }
                
            };
        }
    }




paulwong 2020-02-03 16:47 发表评论
]]>
Transform RemoteChunk to remote with json format in Spring Batchhttp://www.aygfsteel.com/paulwong/archive/2020/01/21/435048.htmlpaulwongpaulwongTue, 21 Jan 2020 08:44:00 GMThttp://www.aygfsteel.com/paulwong/archive/2020/01/21/435048.htmlhttp://www.aygfsteel.com/paulwong/comments/435048.htmlhttp://www.aygfsteel.com/paulwong/archive/2020/01/21/435048.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435048.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435048.html
注意此处使用的是SPRING JACKSONQ而不是JACKSON。一般是在SPRING INTEGRATIONA框架下{的?br />
需要自定义TransformerQ?br />
JsonToChunkRequestTransformer.java
package com.frandorado.springbatchawsintegrationslave.transformer;

import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.stream.IntStream;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.integration.chunk.ChunkRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.aws.support.AwsHeaders;
import org.springframework.integration.json.JsonToObjectTransformer;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import com.amazonaws.services.sqs.AmazonSQSAsync;
import com.fasterxml.jackson.databind.ObjectMapper;

@Component
public class JsonToChunkRequestTransformer extends JsonToObjectTransformer {
    
    private static final String MESSAGE_GROUP_ID_HEADER = "message-group-id";
    
    @Autowired
    AmazonSQSAsync amazonSQSAsync;
    
    @Override
    protected Object doTransform(Message<?> message) throws Exception {
        // ACK
        ack(message);
        
        return this.getMessageBuilderFactory().withPayload(buildChunkRequest(message)).setHeader(MESSAGE_GROUP_ID_HEADER, "unique").build();
    }
    
    private ChunkRequest buildChunkRequest(Message<?> message) throws IOException {
        Map map = new ObjectMapper().readValue(message.getPayload().toString(), Map.class);
        Map stepContributionMap = (Map) map.get("stepContribution");
        Map exitStatusMap = (Map) stepContributionMap.get("exitStatus");
        
        StepContribution stepContribution = new StepContribution(new StepExecution("null", null));
        ExitStatus exitStatus = new ExitStatus((String) exitStatusMap.get("exitCode"), (String) exitStatusMap.get("exitDescription"));
        
        IntStream.range(0, (Integer) stepContributionMap.get("readCount")).forEach(e -> stepContribution.incrementReadCount());
        stepContribution.incrementWriteCount((Integer) stepContributionMap.get("writeCount"));
        stepContribution.incrementFilterCount((Integer) stepContributionMap.get("filterCount"));
        stepContribution.incrementReadSkipCount((Integer) stepContributionMap.get("readSkipCount"));
        IntStream.range(0, (Integer) stepContributionMap.get("writeSkipCount")).forEach(e -> stepContribution.incrementWriteSkipCount());
        IntStream.range(0, (Integer) stepContributionMap.get("processSkipCount"))
                .forEach(e -> stepContribution.incrementProcessSkipCount());
        stepContribution.setExitStatus(exitStatus);
        
        return new ChunkRequest((Integer) map.get("sequence"), (Collection) map.get("items"), (Integer) map.get("jobId"), stepContribution);
    }
    
    private void ack(Message<?> message) {
        String receiptHandle = message.getHeaders().get(AwsHeaders.RECEIPT_HANDLE, String.class);
        String queue = message.getHeaders().get(AwsHeaders.QUEUE, String.class);
        String queueUrl = amazonSQSAsync.getQueueUrl(queue).getQueueUrl();
        
        amazonSQSAsync.deleteMessage(queueUrl, receiptHandle);
    }
}


JsonToChunkResponseTransformer.java
package com.frandorado.springbatchawsintegrationmaster.transformer;

import java.io.IOException;
import java.util.Map;

import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.integration.chunk.ChunkResponse;
import org.springframework.integration.json.JsonToObjectTransformer;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.ObjectMapper;

@Component
public class JsonToChunkResponseTransformer extends JsonToObjectTransformer {
    
    @Override
    protected Object doTransform(Message<?> message) throws Exception {
        return buildChunkResponse(message);
    }
    
    private ChunkResponse buildChunkResponse(Message<?> message) throws IOException {
        Map map = new ObjectMapper().readValue(message.getPayload().toString(), Map.class);
        
        Integer jobId = (Integer) map.get("jobId");
        Integer sequence = (Integer) map.get("sequence");
        String messageContent = (String) map.get("message");
        Boolean status = (Boolean) map.get("successful");
        
        StepContribution stepContribution = new StepContribution(new StepExecution("-", null));
        
        return new ChunkResponse(status, sequence, Long.valueOf(jobId), stepContribution, messageContent);
    }
}


q有一U方式,是如果W三cM支持转JSONQ即代码里没有JACKSON的注解,可以采用MIXIN的方式:(x)

StepExecutionJacksonMixIn.java
package org.springframework.cloud.dataflow.rest.client.support;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.springframework.batch.core.StepExecution;

/**
 * Jackson MixIn for {
@link StepExecution} de-serialization.
 *
 * 
@author Gunnar Hillert
 * 
@since 1.0
 
*/
@JsonIgnoreProperties({ "jobExecution", "jobParameters", "jobExecutionId", "skipCount", "summary" })
public abstract class StepExecutionJacksonMixIn {

    @JsonCreator
    StepExecutionJacksonMixIn(@JsonProperty("stepName") String stepName) {
    }

}

在配|文件中注册才能使用Q?br />
JacksonConfiguration.java
import java.util.Locale;
import java.util.TimeZone;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.ISO8601DateFormatWithMilliSeconds;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.ExecutionContextJacksonMixIn;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.ExitStatusJacksonMixIn;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.JobExecutionJacksonMixIn;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.JobInstanceJacksonMixIn;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.JobParameterJacksonMixIn;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.JobParametersJacksonMixIn;
import com.novacredit.bmb.batchmonitor.springbatch.common.batch.jackson.mixin.StepExecutionJacksonMixIn;

@Configuration
public class JacksonConfiguration {

    @Bean
    public Jackson2JsonObjectMapper jackson2JsonObjectMapper(ObjectMapper objectMapper) {
        return new Jackson2JsonObjectMapper(objectMapper);
    }
    
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer dataflowObjectMapperBuilderCustomizer() {
        return (builder) -> {
            builder.dateFormat(new ISO8601DateFormatWithMilliSeconds(TimeZone.getDefault(), Locale.getDefault(), true));
            // apply SCDF Batch Mixins to
            
// ignore the JobExecution in StepExecution to prevent infinite loop.
            
// https://github.com/spring-projects/spring-hateoas/issues/333
            builder.mixIn(StepExecution.class, StepExecutionJacksonMixIn.class);
            builder.mixIn(ExecutionContext.class, ExecutionContextJacksonMixIn.class);
            builder.mixIn(JobExecution.class, JobExecutionJacksonMixIn.class);
            builder.mixIn(JobParameters.class, JobParametersJacksonMixIn.class);
            builder.mixIn(JobParameter.class, JobParameterJacksonMixIn.class);
            builder.mixIn(JobInstance.class, JobInstanceJacksonMixIn.class);
//            builder.mixIn(StepExecutionHistory.class, StepExecutionHistoryJacksonMixIn.class);
            builder.mixIn(ExecutionContext.class, ExecutionContextJacksonMixIn.class);
            builder.mixIn(ExitStatus.class, ExitStatusJacksonMixIn.class);
//            objectMapper.setDateFormat(new ISO8601DateFormatWithMilliSeconds());
            builder.modules(new JavaTimeModule(), new Jdk8Module());
        };
    }
}

    @Bean
    public IntegrationFlow flow4Contribution(
            ConnectionFactory connectionFactory, 
            JobProperties jobProperties,
            Jackson2JsonObjectMapper jackson2JsonObjectMapper
    ) {
        return IntegrationFlows
                    .from(request4ContributionMaster())
                    .enrichHeaders(headerEnricherConfigurer())
                    .transform(Transformers.toJson(jackson2JsonObjectMapper))
                    .handle(jmsOutboundGateway4Contribution(connectionFactory, jobProperties))
                    .transform(Transformers.fromJson(StepExecution.class, jackson2JsonObjectMapper))
                    .channel(replies4ContributionMaster(null))
                    .get();
    }


https://github.com/spring-cloud/spring-cloud-dataflow/tree/master/spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client/support

https://frandorado.github.io/spring/2019/07/29/spring-batch-aws-series-introduction.html

https://github.com/frandorado/spring-projects/tree/master/spring-batch-aws-integration/spring-batch-aws-integration-master/src/main/java/com/frandorado/springbatchawsintegrationmaster/transformer


https://github.com/frandorado/spring-projects/tree/master/spring-batch-aws-integration/spring-batch-aws-integration-slave/src/main/java/com/frandorado/springbatchawsintegrationslave/transformer

paulwong 2020-01-21 16:44 发表评论
]]>
Spring Batch JUnit test for multiple jobshttp://www.aygfsteel.com/paulwong/archive/2019/07/31/434326.htmlpaulwongpaulwongWed, 31 Jul 2019 02:48:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/07/31/434326.htmlhttp://www.aygfsteel.com/paulwong/comments/434326.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/07/31/434326.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434326.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434326.htmlhttps://stackoverflow.com/questions/34217101/spring-batch-junit-test-for-multiple-jobs

@Configuration
public class TestBatchConfiguration implements MergedBeanDefinitionPostProcessor {

    @Autowired
    @Qualifier("JobA")
    private Job job;

    @Bean(name="jtestl")
    public JobLauncherTestUtils jobLauncherTestUtils() {
        JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils();
        jobLauncherTestUtils.setJob(job);
        return jobLauncherTestUtils;
    }

    /**
     * 
https://stackoverflow.com/questions/22416140/autowire-setter-override-with-java-config
     * This is needed to inject the correct job into JobLauncherTestUtils
     
*/
    @Override
    public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
        if(beanName.equals("jtestl")) {
            beanDefinition.getPropertyValues().add("job", getMyBeanFirstAImpl());
        }
    }

    private Object getMyBeanFirstAImpl() {
        return job;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}


paulwong 2019-07-31 10:48 发表评论
]]>
SPRING BATCH & SPRING INTEGRATION TUTORIALhttp://www.aygfsteel.com/paulwong/archive/2019/07/18/434230.htmlpaulwongpaulwongThu, 18 Jul 2019 05:21:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/07/18/434230.htmlhttp://www.aygfsteel.com/paulwong/comments/434230.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/07/18/434230.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434230.htmlhttp://www.aygfsteel.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 BATCH remote chunking模式下可同时处理多文?/title><link>http://www.aygfsteel.com/paulwong/archive/2019/07/16/434210.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 16 Jul 2019 06:38:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2019/07/16/434210.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/434210.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2019/07/16/434210.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/434210.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/434210.html</trackback:ping><description><![CDATA[<div>SPRING BATCH remote chunking模式下,如果要同一旉处理多个文gQ按DEMO的默认配|,是会(x)报错的,q是׃多个文g的处理的MASTER方,是用同一个QUEUE名,q样SLAVE中处理多个JOB INSTANCEӞ?x)返回不同的JOB-INSTANCE-IDQ导致报错?br /> <br /> q时需更改SPRING BATCH使用SPRING INTEGRATION的模式中的GATEWAYlg?br /> <br /> GATEWAYlg是工作在REQUEST/RESPONSE模式下,卛_一个MESSAGE到某一QUEUEӞ要从REPLY QUEUE{到CONSUMERq回l果Ӟ才往(xin)下(h)l?br /> <br /> OUTBOUND GATEWAYQ从某一CHANNEL获取MESSAGEQ发往(xin)REQUEST QUEUEQ从REPLY QUEUE{到CONSUMERq回l果Q将此MESSAGE发往(xin)下一CHANNEL?br /> <br /> INBOUND GATEWAYQ从某一QUEUE获取MESSAGEQ发往(xin)某一REQUEST CHANNELQ从REPLY CHANNEL{到q回l果Q将此MESSAGE发往(xin)下一QUEUE?br /> <br /> 详情参见此文Q?a target="_blank">https://blog.csdn.net/alexlau8/article/details/78056064</a>?br /> <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: #008000; "><!--</span><span style="color: #008000; "> Master jms </span><span style="color: #008000; ">--></span><br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">int:channel </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="MasterRequestChannel"</span><span style="color: #0000FF; ">></span><br />         <span style="color: #0000FF; "><</span><span style="color: #800000; ">int:dispatcher </span><span style="color: #FF0000; ">task-executor</span><span style="color: #0000FF; ">="RequestPublishExecutor"</span><span style="color: #0000FF; ">/></span><br />     <span style="color: #0000FF; "></</span><span style="color: #800000; ">int:channel</span><span style="color: #0000FF; ">></span><br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">task:executor </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="RequestPublishExecutor"</span><span style="color: #FF0000; "> pool-size</span><span style="color: #0000FF; ">="5-10"</span><span style="color: #FF0000; "> queue-capacity</span><span style="color: #0000FF; ">="0"</span><span style="color: #0000FF; ">/></span><br /> <span style="color: #008000; "><!--</span><span style="color: #008000; ">    <int-jms:outbound-channel-adapter <br />         connection-factory="connectionFactory" <br />         destination-name="RequestQueue" <br />         channel="MasterRequestChannel"/> </span><span style="color: #008000; ">--></span><br /> <br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">int:channel </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="MasterReplyChannel"</span><span style="color: #0000FF; ">/></span><br /> <span style="color: #008000; "><!--</span><span style="color: #008000; ">    <int-jms:message-driven-channel-adapter <br />         connection-factory="connectionFactory" <br />         destination-name="ReplyQueue"<br />         channel="MasterReplyChannel"/> </span><span style="color: #008000; ">--></span><br /> <br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">int-jms:outbound-gateway<br />         </span><span style="color: #FF0000; ">connection-factory</span><span style="color: #0000FF; ">="connectionFactory"</span><span style="color: #FF0000; "><br />         correlation-key</span><span style="color: #0000FF; ">="JMSCorrelationID"</span><span style="color: #FF0000; "><br />         request-channel</span><span style="color: #0000FF; ">="MasterRequestChannel"</span><span style="color: #FF0000; "><br />         request-destination-name</span><span style="color: #0000FF; ">="RequestQueue"</span><span style="color: #FF0000; "><br />         receive-timeout</span><span style="color: #0000FF; ">="30000"</span><span style="color: #FF0000; "><br />         reply-channel</span><span style="color: #0000FF; ">="MasterReplyChannel"</span><span style="color: #FF0000; "><br />         reply-destination-name</span><span style="color: #0000FF; ">="ReplyQueue"</span><span style="color: #FF0000; "><br />         async</span><span style="color: #0000FF; ">="true"</span><span style="color: #0000FF; ">></span><br />         <span style="color: #0000FF; "><</span><span style="color: #800000; ">int-jms:reply-listener </span><span style="color: #0000FF; ">/></span><br />     <span style="color: #0000FF; "></</span><span style="color: #800000; ">int-jms:outbound-gateway</span><span style="color: #0000FF; ">></span><br /> <br />     <span style="color: #008000; "><!--</span><span style="color: #008000; "> Slave jms </span><span style="color: #008000; ">--></span><br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">int:channel </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="SlaveRequestChannel"</span><span style="color: #0000FF; ">/></span><br /> <span style="color: #008000; "><!--</span><span style="color: #008000; ">    <int-jms:message-driven-channel-adapter<br />         connection-factory="connectionFactory" <br />         destination-name="RequestQueue"<br />         channel="SlaveRequestChannel"/> </span><span style="color: #008000; ">--></span><br /> <br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">int:channel </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="SlaveReplyChannel"</span><span style="color: #0000FF; ">/></span><br /> <span style="color: #008000; "><!--</span><span style="color: #008000; ">    <int-jms:outbound-channel-adapter <br />         connection-factory="connectionFactory" <br />         destination-name="ReplyQueue"<br />         channel="SlaveReplyChannel"/> </span><span style="color: #008000; ">--></span><br /> <br />     <span style="color: #0000FF; "><</span><span style="color: #800000; ">int-jms:inbound-gateway<br />         </span><span style="color: #FF0000; ">connection-factory</span><span style="color: #0000FF; ">="connectionFactory"</span><span style="color: #FF0000; "><br />         correlation-key</span><span style="color: #0000FF; ">="JMSCorrelationID"</span><span style="color: #FF0000; "><br />         request-channel</span><span style="color: #0000FF; ">="SlaveRequestChannel"</span><span style="color: #FF0000; "><br />         request-destination-name</span><span style="color: #0000FF; ">="RequestQueue"</span><span style="color: #FF0000; "><br />         reply-channel</span><span style="color: #0000FF; ">="SlaveReplyChannel"</span><span style="color: #FF0000; "><br />         default-reply-queue-name</span><span style="color: #0000FF; ">="ReplyQueue"</span><span style="color: #0000FF; ">/></span></div> </div><br /> MASTER配置<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; ">package</span> com.paul.testspringbatch.config.master;<br /> <br /> <span style="color: #0000FF; ">import</span> javax.jms.ConnectionFactory;<br /> <br /> <span style="color: #0000FF; ">import</span> org.springframework.beans.factory.config.CustomScopeConfigurer;<br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">import org.springframework.batch.core.configuration.annotation.StepScope;</span><span style="color: #008000; "><br /> </span><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.context.annotation.Profile;<br /> <span style="color: #0000FF; ">import</span> org.springframework.context.annotation.Scope;<br /> <span style="color: #0000FF; ">import</span> org.springframework.context.support.SimpleThreadScope;<br /> <span style="color: #0000FF; ">import</span> org.springframework.integration.channel.DirectChannel;<br /> <span style="color: #0000FF; ">import</span> org.springframework.integration.channel.QueueChannel;<br /> <span style="color: #0000FF; ">import</span> org.springframework.integration.config.EnableIntegration;<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.jms.JmsOutboundGateway;<br /> <br /> <span style="color: #0000FF; ">import</span> com.paul.testspringbatch.common.constant.IntegrationConstant;<br /> <br /> @Configuration<br /> @EnableIntegration<br /> @Profile("batch-master")<br /> <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> IntegrationMasterConfiguration {<br />     <br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">    @Value("${broker.url}")<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    private String brokerUrl;<br /> <br /> <br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    @Bean<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    public ActiveMQConnectionFactory connectionFactory() {<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">        connectionFactory.setBrokerURL(this.brokerUrl);<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">        connectionFactory.setTrustAllPackages(true);<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">        return connectionFactory;<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    }</span><span style="color: #008000; "><br /> </span><br />     <span style="color: #008000; ">/*</span><span style="color: #008000; "><br />      * Configure outbound flow (requests going to workers)<br />      </span><span style="color: #008000; ">*/</span><br />     @Bean<br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)</span><span style="color: #008000; "><br /> </span>    <span style="color: #0000FF; ">public</span> DirectChannel requests() {<br />         <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> DirectChannel();<br />     }<br /> <br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">    @Bean<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    public IntegrationFlow outboundFlow(ConnectionFactory connectionFactory) {<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">        return IntegrationFlows<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .from(requests())<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .handle(Jms.outboundAdapter(connectionFactory).destination(IntegrationConstant.MASTER_REQUEST_DESTINATION))<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .get();<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    }</span><span style="color: #008000; "><br /> </span>    <br />      @Bean<br />      <span style="color: #0000FF; ">public</span> CustomScopeConfigurer customScopeConfigurer() {<br />          CustomScopeConfigurer customScopeConfigurer = <span style="color: #0000FF; ">new</span> CustomScopeConfigurer();<br />          customScopeConfigurer.addScope("thread", <span style="color: #0000FF; ">new</span> SimpleThreadScope());<br />          <span style="color: #0000FF; ">return</span> customScopeConfigurer;<br />      }<br />      <br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">     @Bean<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">     public static BeanFactoryPostProcessor beanFactoryPostProcessor() {<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">         return new BeanFactoryPostProcessor() {<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                <br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">             @Override<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">             public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                    beanFactory.registerScope("thread", new SimpleThreadScope());<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                }<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">              };<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">     }</span><span style="color: #008000; "><br /> </span>    <br />     <span style="color: #008000; ">/*</span><span style="color: #008000; "><br />      * Configure inbound flow (replies coming from workers)<br />      </span><span style="color: #008000; ">*/</span><br />     @Bean<br />     @Scope(value = "thread"<span style="color: #008000; ">/*</span><span style="color: #008000; "> , proxyMode = ScopedProxyMode.NO </span><span style="color: #008000; ">*/</span>)<br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)</span><span style="color: #008000; "><br /> </span>    <span style="color: #0000FF; ">public</span> QueueChannel replies() {<br />         <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> QueueChannel();<br />     }<br /> <br /> <span style="color: #008000; ">//</span><span style="color: #008000; ">    @Bean<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    public IntegrationFlow inboundFlow(ConnectionFactory connectionFactory) {<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">        return IntegrationFlows<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .from(Jms.messageDrivenChannelAdapter(connectionFactory).destination(IntegrationConstant.MASTER_REPLY_DESTINATION))<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .channel(replies())<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .get();<br /> </span><span style="color: #008000; ">//</span><span style="color: #008000; ">    }</span><span style="color: #008000; "><br /> </span><br />     @Bean<br />     <span style="color: #0000FF; ">public</span> JmsOutboundGateway jmsOutboundGateway(ConnectionFactory connectionFactory) {<br />         JmsOutboundGateway jmsOutboundGateway = <span style="color: #0000FF; ">new</span> JmsOutboundGateway();<br />         jmsOutboundGateway.setConnectionFactory(connectionFactory);<br />         jmsOutboundGateway.setRequestDestinationName(IntegrationConstant.MASTER_REQUEST_DESTINATION);<span style="color: #008000; ">//</span><span style="color: #008000; ">2. send the message to this destination</span><span style="color: #008000; "><br /> </span>        jmsOutboundGateway.setRequiresReply(<span style="color: #0000FF; ">true</span>);<br />         jmsOutboundGateway.setCorrelationKey(IntegrationConstant.JMS_CORRELATION_KEY);<span style="color: #008000; ">//</span><span style="color: #008000; ">3. let the broker filter the message</span><span style="color: #008000; "><br /> </span>        jmsOutboundGateway.setAsync(<span style="color: #0000FF; ">true</span>);<span style="color: #008000; ">//</span><span style="color: #008000; ">must be async, so that JMS_CORRELATION_KEY work</span><span style="color: #008000; "><br /> </span>        jmsOutboundGateway.setUseReplyContainer(<span style="color: #0000FF; ">true</span>);<br />         jmsOutboundGateway.setReplyDestinationName(IntegrationConstant.MASTER_REPLY_DESTINATION);<span style="color: #008000; ">//</span><span style="color: #008000; ">4. waiting the response from this destination</span><span style="color: #008000; "><br /> </span>        jmsOutboundGateway.setReceiveTimeout(30_000);<br />         <span style="color: #0000FF; ">return</span> jmsOutboundGateway;<br />     }<br /> <br />     @Bean<br />     <span style="color: #0000FF; ">public</span> IntegrationFlow jmsOutboundGatewayFlow(ConnectionFactory connectionFactory) {<br />         <span style="color: #0000FF; ">return</span> IntegrationFlows<br />                         .from(requests())<span style="color: #008000; ">//</span><span style="color: #008000; ">1. receive message from this channel</span><span style="color: #008000; "><br /> </span>                        .handle(jmsOutboundGateway(connectionFactory))<br />                         .channel(replies())<span style="color: #008000; ">//</span><span style="color: #008000; ">5. send back the response to this channel</span><span style="color: #008000; "><br /> </span>                        .get();<br />     }<br /> <br /> }</div><br /><br />SLAVE配置Q?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; ">package</span> com.paul.testspringbatch.config.slave;<br /><br /><span style="color: #0000FF; ">import</span> javax.jms.ConnectionFactory;<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.context.annotation.Profile;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.channel.DirectChannel;<br /><span style="color: #0000FF; ">import</span> org.springframework.integration.config.EnableIntegration;<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.jms.dsl.Jms;<br /><br /><span style="color: #0000FF; ">import</span> com.paul.testspringbatch.common.constant.IntegrationConstant;<br /><br />@Configuration<br />@EnableIntegration<br />@Profile("batch-slave")<br /><span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> IntegrationSlaveConfiguration {<br />    <br /><br />    <span style="color: #008000; ">/*</span><span style="color: #008000; "><br />     * Configure inbound flow (requests coming from the master)<br />     </span><span style="color: #008000; ">*/</span><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> DirectChannel requests() {<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> DirectChannel();<br />    }<br /><br /><span style="color: #008000; ">//</span><span style="color: #008000; ">    @Bean<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">    public IntegrationFlow inboundFlow(ConnectionFactory connectionFactory) {<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">        return IntegrationFlows<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .from(Jms.messageDrivenChannelAdapter(connectionFactory).destination("requests"))<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .channel(requests())<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .get();<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">    }</span><span style="color: #008000; "><br /></span><br />    <span style="color: #008000; ">/*</span><span style="color: #008000; "><br />     * Configure outbound flow (replies going to the master)<br />     </span><span style="color: #008000; ">*/</span><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> DirectChannel replies() {<br />        <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">new</span> DirectChannel();<br />    }<br /><br /><span style="color: #008000; ">//</span><span style="color: #008000; ">    @Bean<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">    public IntegrationFlow outboundFlow(ConnectionFactory connectionFactory) {<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">        return IntegrationFlows<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .from(replies())<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .handle(Jms.outboundAdapter(connectionFactory).destination("replies"))<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">                .get();<br /></span><span style="color: #008000; ">//</span><span style="color: #008000; ">    }</span><span style="color: #008000; "><br /></span><br />    @Bean<br />    <span style="color: #0000FF; ">public</span> IntegrationFlow inboundGatewayFlow(ConnectionFactory connectionFactory) {<br />        <span style="color: #0000FF; ">return</span> IntegrationFlows<br />                    .from(Jms<br />                            .inboundGateway(connectionFactory)<br />                            .destination(IntegrationConstant.SLAVE_HANDLE_MASTER_REQUEST_DESTINATION)<span style="color: #008000; ">//</span><span style="color: #008000; ">1. receive message from this channel.</span><span style="color: #008000; "><br /></span>                            .correlationKey(IntegrationConstant.JMS_CORRELATION_KEY)<span style="color: #008000; ">//</span><span style="color: #008000; ">2. let the broker filter the message</span><span style="color: #008000; "><br /></span>                            .requestChannel(requests())<span style="color: #008000; ">//</span><span style="color: #008000; ">3. send the message to this channel</span><span style="color: #008000; "><br /></span>                            .replyChannel(replies())<span style="color: #008000; ">//</span><span style="color: #008000; ">4. waitting the result from this channel</span><span style="color: #008000; "><br /></span>                            .defaultReplyQueueName(IntegrationConstant.SLAVE_RETURN_RESULT_DESTINATION)<span style="color: #008000; ">//</span><span style="color: #008000; ">5.send back the result to this destination to the master.</span><span style="color: #008000; "><br /></span>                            )<br />                    .get();<br />    }<br /><br />}</div><img src ="http://www.aygfsteel.com/paulwong/aggbug/434210.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2019-07-16 14:38 <a href="http://www.aygfsteel.com/paulwong/archive/2019/07/16/434210.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STEP范围内的ROUTERhttp://www.aygfsteel.com/paulwong/archive/2019/07/11/434137.htmlpaulwongpaulwongThu, 11 Jul 2019 03:45:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/07/11/434137.htmlhttp://www.aygfsteel.com/paulwong/comments/434137.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/07/11/434137.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434137.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434137.html

https://gist.github.com/benas/bfe2be7386b99ce496425fac9ff35fb8

paulwong 2019-07-11 11:45 发表评论
]]>
动态改变SPRING BATCH ?CHUNKSIZEhttp://www.aygfsteel.com/paulwong/archive/2019/07/02/434011.htmlpaulwongpaulwongTue, 02 Jul 2019 03:13:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/07/02/434011.htmlhttp://www.aygfsteel.com/paulwong/comments/434011.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/07/02/434011.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/434011.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/434011.htmlSPRING BATCH L件时Q是按一行一行来d数据Q再按CHUNKSIZE提交到REMOTE操作Q有时要整合当前行和下几行,再决定CHUNKSIZEQ以便相关的数据能在q程同一个PROCESSOR中按序q行处理Q因为相关的数据被拆成几个CHUNK来处理的话,有可能不按序来处理。这样就需要动态调整CHUNKSIZE?br />
参照如下Q?br /> https://stackoverflow.com/questions/37390602/spring-batch-custom-completion-policy-for-dynamic-chunk-size

q结合SingleItemPeekableItemReaderQ装饰者,允许查看下一条数据,真正的操作委托给代理Q?img src ="http://www.aygfsteel.com/paulwong/aggbug/434011.html" width = "1" height = "1" />

paulwong 2019-07-02 11:13 发表评论
]]>
Spring batch 的高U特?-监听Q异常处理,事务http://www.aygfsteel.com/paulwong/archive/2019/06/12/433855.htmlpaulwongpaulwongWed, 12 Jun 2019 09:03:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/06/12/433855.htmlhttp://www.aygfsteel.com/paulwong/comments/433855.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/06/12/433855.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433855.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433855.htmlhttps://my.oschina.net/u/2600078/blog/909346

paulwong 2019-06-12 17:03 发表评论
]]>
SPRING BOOT BATCH资源http://www.aygfsteel.com/paulwong/archive/2019/05/07/433753.htmlpaulwongpaulwongTue, 07 May 2019 09:07:00 GMThttp://www.aygfsteel.com/paulwong/archive/2019/05/07/433753.htmlhttp://www.aygfsteel.com/paulwong/comments/433753.htmlhttp://www.aygfsteel.com/paulwong/archive/2019/05/07/433753.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/433753.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/433753.html Spring Boot下Spring Batch入门实例 https://www.jianshu.com/p/305192ea4cb1
 

SPRING BATCH + QUARTZ
https://examples.javacodegeeks.com/enterprise-java/spring/batch/quartz-spring-batch-example/
https://blog.kingbbode.com/posts/spring-batch-quartz

Spring Batch Tutorial: Batch Processing Made Easy with Spring
https://www.toptal.com/spring/spring-batch-tutorial

paulwong 2019-05-07 17:07 发表评论
]]>
如何提高~码质量http://www.aygfsteel.com/paulwong/archive/2012/12/14/392982.htmlpaulwongpaulwongFri, 14 Dec 2012 03:57:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/12/14/392982.htmlhttp://www.aygfsteel.com/paulwong/comments/392982.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/12/14/392982.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/392982.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/392982.html一般程序员都会(x)发现q样的问题,需求拿?jin),~码写完?jin),~译也通过?jin),q行也没报错Q就以ؓ(f)E序OK?jin),但到试人员那里Q一q行试用例Q就发现漏了(jin)q个那个的,产生?jin)所谓的质量问题?/div>

原因
q通常是由于程序员?sh)拿到需求,马上想要几个CLASSQ然后就开始编码了(jin)?/div>

解决Ҏ(gu)
  1. 拿到需求后Q先惛_概会(x)用到哪些OBJECTQ即SERVICEQDAO之类?/li>
  2. 设计Z(x)遇到哪些场景
  3. 设计出分别在q些场景中,那些OBJECT合作的流E图
  4. ~码
举例
需求:(x)有一pȝ?x)在每天的某个时间点Q在某个文g夹内Q导Z个一定格式名U的文gQ现在要求程序实现在文g生成后,dq个文gQ抽取某些内容后Q再生成另一文gQ通过SFTP发走?/div>

Ҏ(gu)Q?/div>
  1. ?x)用到排E器Q控制器QSPRING BATCH JOB
  2. 有这几种场景Q没有发现文件时Q发C(jin)文g后正常处理,控制器和SPRING BATCH JOB出现错误时等
  3. 处理程Q控制器没有发现文g后,通知排程器(h)l下一ơ@环;控制器发现文件后Q通知SPRING BATCH JOB处理Q然后通知控制器退出;控制器出现错误或SPRING BATCH JOB出现错误后,控制器通知排程器退出?/li>
  4. Ҏ(gu)q几U场景设计程序结构,~码
  5. ~写单元试用例




paulwong 2012-12-14 11:57 发表评论
]]>SPRING BATCH 错误通知机制http://www.aygfsteel.com/paulwong/archive/2012/11/17/391508.htmlpaulwongpaulwongSat, 17 Nov 2012 13:42:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/11/17/391508.htmlhttp://www.aygfsteel.com/paulwong/comments/391508.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/11/17/391508.html#Feedback1http://www.aygfsteel.com/paulwong/comments/commentRss/391508.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/391508.html阅读全文

paulwong 2012-11-17 21:42 发表评论
]]>
SPRING BATCH 试http://www.aygfsteel.com/paulwong/archive/2012/11/10/391143.htmlpaulwongpaulwongSat, 10 Nov 2012 09:25:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/11/10/391143.htmlhttp://www.aygfsteel.com/paulwong/comments/391143.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/11/10/391143.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/391143.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/391143.htmlJOB, STEP属于功能试Q黑盒)(j)的范_(d)INTEMPROCESSOR, ITEMREADER, ITEMWRITER属于单元试Q白盒)(j)的范畴?/div>

/*
 * Copyright 2006-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      
http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 
*/
package example;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.Date;
import java.util.concurrent.Callable;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.batch.test.MetaDataInstanceFactory;
import org.springframework.batch.test.StepScopeTestExecutionListener;
import org.springframework.batch.test.StepScopeTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;

@ContextConfiguration(locations = { "/test-context.xml",
        "classpath:/META-INF/spring/batch/hello-tasklet-context.xml",
        "classpath:/META-INF/spring/batch/jdbc-job-context.xml",
        "classpath:/META-INF/spring/integration/hello-integration-context.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
//试ITEMREADER/ITEMPROCESSOR/ITEMWRITER时用?/span>
@TestExecutionListeners( { DependencyInjectionTestExecutionListener.class
    StepScopeTestExecutionListener.class })
public class HelloTaskletTests {
    
    @Autowired
    private JobLauncher jobLauncher;
    
    @Autowired
    private Job helloWorldJob;

    @Autowired
    private JobLauncherTestUtils jobLauncherTestUtils;//试JOB/STEP的入?/span>
    
    @Autowired
    private ItemReader xmlReader;
    
    public void testLaunchJobWithJobLauncher() throws Exception {
        JobExecution jobExecution = jobLauncher.run(helloWorldJob, new JobParameters());
        assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    }

    /**
     * Create a unique job instance and check it's execution completes
     * successfully - uses the convenience methods provided by the testing
     * superclass.
     
*/
    @Test
    public void testLaunchJob() throws Exception {

        JobExecution jobExecution = jobLauncherTestUtils.launchJob(jobLauncherTestUtils.getUniqueJobParameters());
        assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    }
    
    public void testIntegration()
    {
        while(true)
        {
            
        }
    }
    
    /**
     * 试某个STEP
     
*/
    @Test
    public void testSomeStep()
    {
        JobExecution jobExecution = jobLauncherTestUtils.
                launchStep("xmlFileReadAndWriterStep",getJobParameters());
        assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    }
    
    /**
     * 试READER的方?Ӟ所需的方?br />     * 
@return
     
*/
    public StepExecution getStepExecution() {
        StepExecution execution = MetaDataInstanceFactory
                .createStepExecution(getJobParameters());
        return execution;
    }
    
    /**
     * 试READER的方?
     * 
@throws Exception
     
*/
    @Test
    @DirtiesContext
    public void testReader() throws Exception {
        int count = StepScopeTestUtils.doInStepScope(getStepExecution(),
                new Callable<Integer>() {
                    @Override
                    public Integer call() throws Exception {
                        int count = 0;
                        try {
                            ((ItemStream) xmlReader)
                                    .open(new ExecutionContext());
                            while (xmlReader.read() != null) {
                                count++;
                            }
                            return count;
                        } finally {
                            ((ItemStream) xmlReader).close();
                        }
                    }
                });
        assertEquals(3, count);
    }
      
    /**
     * 试READER的方?
     * 
@throws UnexpectedInputException
     * 
@throws ParseException
     * 
@throws NonTransientResourceException
     * 
@throws Exception
     
*/
    @Test
    @DirtiesContext
    public void testReader2() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception
    {
        assertNotNull(xmlReader.read());
    }
    
    /**
     * 试READER的方?Ӟ必须加的Ҏ(gu)
     
*/
    @Before
    public void setUp() {
        ((ItemStream) xmlReader).open(new ExecutionContext());
    }
      
    /**
     * 
     * 
@return
     
*/
    private JobParameters getJobParameters() {
        
        String inputFile = "/Users/paul/Documents/PAUL/DOWNLOAD/SOFTWARE/DEVELOP/"
                + "SPRING BATCH/spring-batch-2.1.9.RELEASE/samples/"
                + "spring-batch-simple-cli/file/trades1.xml";
        
        String outputFile = "/Users/paul/Documents/PAUL/DOWNLOAD/SOFTWARE/DEVELOP/"
                + "SPRING BATCH/spring-batch-2.1.9.RELEASE/samples/"
                + "spring-batch-simple-cli/file/output/out.xml";
        
        JobParameters jobParameters = new JobParametersBuilder()
                .addString("input.file.path", inputFile)
                .addString("output.file.path", outputFile)
                .addDate("date", new Date()).toJobParameters();
        
        return jobParameters;
    }


}


参考例子:(x) 

paulwong 2012-11-10 17:25 发表评论
]]>
SRING INTEGRATION + BATCHhttp://www.aygfsteel.com/paulwong/archive/2012/10/21/389968.htmlpaulwongpaulwongSun, 21 Oct 2012 09:23:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/10/21/389968.htmlhttp://www.aygfsteel.com/paulwong/comments/389968.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/10/21/389968.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/389968.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/389968.html阅读全文

paulwong 2012-10-21 17:23 发表评论
]]>
SPRING BATCH q行机制http://www.aygfsteel.com/paulwong/archive/2012/10/20/389910.htmlpaulwongpaulwongSat, 20 Oct 2012 03:57:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/10/20/389910.htmlhttp://www.aygfsteel.com/paulwong/comments/389910.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/10/20/389910.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/389910.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/389910.html
  1. 判断此JOB以前是否有运行过Q判断依据:(x)Ҏ(gu)JOB NAME和JOB PARAMETERS信息去这两张表查找,如找到记录,则是有运行过Q如定有则引擎退出ƈ提示?br />

  2. 判断是否有重复运行的JOBQ如果没Q查找此JOB上次q行的情况,如果有FAIL的情况,则重C上次p|的地方运行(h)l运行,判断Ҏ(gu)Q根据JOB INSTANCE兌的JOB EXECUTION查找是否有状态ؓ(f)FAIL的记录,如有则是Q就新徏一个JOB EXECUTION表示q行W二ơ尝试,同时又生成关于新JOB的JOB EXECUTION。上ơ的JOBq行完后Q再q行此次新JOB。判断上ơ失败的STEP的依据:(x)查找对应的JOB EXECUTON的STEP EXECUTON状态ؓ(f)FAIL的STEP卛_Q会(x)从此步骤开始运行,而不是从W一步开始运行?br />
参考文档:(x)


paulwong 2012-10-20 11:57 发表评论
]]>SPRING INTEGRATION + SPRING BATCHhttp://www.aygfsteel.com/paulwong/archive/2012/10/16/389625.htmlpaulwongpaulwongMon, 15 Oct 2012 16:11:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/10/16/389625.htmlhttp://www.aygfsteel.com/paulwong/comments/389625.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/10/16/389625.html#Feedback7http://www.aygfsteel.com/paulwong/comments/commentRss/389625.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/389625.html阅读全文

paulwong 2012-10-16 00:11 发表评论
]]>
Quartz 中的d开始、暂停和l箋(hu)http://www.aygfsteel.com/paulwong/archive/2012/10/13/389514.htmlpaulwongpaulwongSat, 13 Oct 2012 08:18:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/10/13/389514.htmlhttp://www.aygfsteel.com/paulwong/comments/389514.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/10/13/389514.html#Feedback1http://www.aygfsteel.com/paulwong/comments/commentRss/389514.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/389514.htmlpackage com.paul.springbatchtest.tasklet;import org.quartz.SchedulerException;public class Tas...  阅读全文

paulwong 2012-10-13 16:18 发表评论
]]>
Spring 3.0的Q务调?/title><link>http://www.aygfsteel.com/paulwong/archive/2012/10/12/389451.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 12 Oct 2012 02:51:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2012/10/12/389451.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/389451.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2012/10/12/389451.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/389451.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/389451.html</trackback:ping><description><![CDATA[Spring3.0以后Q自己已l完全支持更加精的旉Q而不需要QuartzQQuartz是一个开放源码项目,专注于Q务调度器Q提供了(jin)极ؓ(f)q泛的特性如持久化Q务,集群和分布式d{。Spring对Quartz的集成与其对JDK Timer的集成在d、触发器和调度计划的声明式配|方面等都非常相伹{?Q的支持Q当然后面我们也?x)用Quartz实现d的调度?br /><br />Spring3.0同样也用cron表达式。与Quartz不同的是QSpring3.0不支持年Q而Quartz支持q。但q点好象q不是非帔R要?<br /><br />cron表达式:(x)Q是用空格分开的时间字D,不用年? <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #000000">*(U?-</span><span style="color: #000000">59</span><span style="color: #000000">)    <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*(分钟0-</span><span style="color: #000000">59</span><span style="color: #000000">)  <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*(时0-</span><span style="color: #000000">23</span><span style="color: #000000">)  <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*(日期1-</span><span style="color: #000000">31</span><span style="color: #000000">)  <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*(月䆾1-12或是JAN-DEC)  <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*(星期1-7或是SUN-SAT)  <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />CZQ?nbsp;<br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*/</span><span style="color: #000000">5</span><span style="color: #000000">  * * * * </span><span style="color: #000000">6</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000">  :: 每个?到周日,每隔5U钟执行一ơ?br /> <br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*/</span><span style="color: #000000">1</span><span style="color: #000000"> * * </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">2</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000"> :: 1月到2月中?号到9P且必要满周一到周日,每隔1U钟执行一ơ?nbsp;<br /><br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*/</span><span style="color: #000000">1</span><span style="color: #000000"> * * </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000">  :: 注意里面?/span><span style="color: #000000">,</span><span style="color: #000000">(逗号)Q只?月和5月的7?P且必要满周一到周日,每一U钟执行一ơ?nbsp;<br /><br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />*/</span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000">17</span><span style="color: #000000">-</span><span style="color: #000000">59</span><span style="color: #000000"> * </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000"> :: 只解?7-</span><span style="color: #000000">59</span><span style="color: #000000">,</span><span style="color: #000000">是指从第17分钟到第59分钟Q在指定的时间内Q每一U种执行一?nbsp;<br /><br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />* </span><span style="color: #000000">17</span><span style="color: #000000">-</span><span style="color: #000000">59</span><span style="color: #000000"> * </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000">  :: 此代码的功能与上面完全相同。如果不写秒即ؓ(f)每一U执行一ơ?nbsp;<br /></span><span style="color: #000000"><br />  59</span><span style="color: #000000"> </span><span style="color: #000000">19</span><span style="color: #000000">-</span><span style="color: #000000">23</span><span style="color: #000000"> * </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000">  :: 19?23分的?9U钟时只执行一ơ?nbsp;<br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="color: #000000">  59</span><span style="color: #000000"> </span><span style="color: #000000">19</span><span style="color: #000000">,</span><span style="color: #000000">26</span><span style="color: #000000"> * </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000">  :: 注意里面?/span><span style="color: #000000">,</span><span style="color: #000000">(逗号)Q是指只?9分或?6分的56U钟时执行一ơ?nbsp;<br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br />  * * </span><span style="color: #000000">16</span><span style="color: #000000">-</span><span style="color: #000000">23</span><span style="color: #000000"> </span><span style="color: #000000">7</span><span style="color: #000000">-</span><span style="color: #000000">9</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">,</span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">7</span><span style="color: #000000">  :: 定义每天?6点到23Ҏ(gu)一U钟执行一ơ?nbsp;<br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="color: #000000">  59</span><span style="color: #000000"> </span><span style="color: #000000">59</span><span style="color: #000000"> </span><span style="color: #000000">23</span><span style="color: #000000"> * * </span><span style="color: #000000">1</span><span style="color: #000000">-</span><span style="color: #000000">5</span><span style="color: #000000">  :: 定义每周1到周5</span><span style="color: #000000">,</span><span style="color: #000000">晚上23:</span><span style="color: #000000">59</span><span style="color: #000000">:59U只执行一ơ?br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />q个相当用有。可以工作时间每天给用户发邮件?nbsp;<br /><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div><br />在Spring3.0中引用了(jin)新的命名I间-taskQ?<br />task:scheduler 用于定义一个ThreadPoolTaskScheduler,q可以指定线E池的大,<br />即pool-size.所有Q务队列都会(x)在指定大的U程池中q行Q?<br /><br />定义如下Q?br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><span style="color: #008000"><!--</span><span style="color: #008000"> 对于同一个Pojo可以声明多次Qƈ讄标记属?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="one"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="cn.itcast.schedule.One"</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="task"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="A"</span><span style="color: #0000ff">></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="two"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="cn.itcast.schedule.One"</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="task"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="B"</span><span style="color: #0000ff">></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="three"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="cn.itcast.schedule.One"</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="task"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="C"</span><span style="color: #0000ff">></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000"><!--</span><span style="color: #008000"> 声明一个具有两个线E的池,每一个对象将获取同样的运行机?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">task:scheduler </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="sch"</span><span style="color: #ff0000"> pool-size</span><span style="color: #0000ff">="2"</span><span style="color: #0000ff">/></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000"><!--</span><span style="color: #008000"> 引用U程?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">task:scheduled-tasks </span><span style="color: #ff0000">scheduler</span><span style="color: #0000ff">="sch"</span><span style="color: #0000ff">></span><span style="color: #000000">  <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" />     </span><span style="color: #008000"><!--</span><span style="color: #008000"> 引用Spring Beanq设|调用的Ҏ(gu)的时间间?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" />     </span><span style="color: #0000ff"><</span><span style="color: #800000">task:scheduled </span><span style="color: #ff0000">ref</span><span style="color: #0000ff">="one"</span><span style="color: #ff0000"> method</span><span style="color: #0000ff">="doSomeThing"</span><span style="color: #ff0000">  fixed-delay</span><span style="color: #0000ff">="#{1000*3}"</span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /></span><span style="color: #0000ff">       <</span><span style="color: #800000">task:scheduled </span><span style="color: #ff0000">ref</span><span style="color: #0000ff">="two"</span><span style="color: #ff0000"> method</span><span style="color: #0000ff">="doSomeThing"</span><span style="color: #ff0000">  fixed-delay</span><span style="color: #0000ff">="#{1000*3}"</span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /></span><span style="color: #0000ff">       <</span><span style="color: #800000">task:scheduled </span><span style="color: #ff0000">ref</span><span style="color: #0000ff">="three"</span><span style="color: #ff0000"> method</span><span style="color: #0000ff">="doSomeThing"</span><span style="color: #ff0000">  fixed-delay</span><span style="color: #0000ff">="#{1000*3}"</span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /></span><span style="color: #0000ff">  </</span><span style="color: #800000">task:scheduled-tasks</span><span style="color: #0000ff">></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000"><!--</span><span style="color: #008000"> 配置一个定时执行的d </span><span style="color: #008000">--></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="work"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="cn.itcast.schedule.Two"</span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">task:scheduler </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="sendMail"</span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /><br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">task:scheduled-tasks </span><span style="color: #ff0000">scheduler</span><span style="color: #0000ff">="sendMail"</span><span style="color: #0000ff">></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" />     </span><span style="color: #008000"><!--</span><span style="color: #008000"> 定义???9:37:1U执行一ơ,无论是周?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" />     </span><span style="color: #0000ff"><</span><span style="color: #800000">task:scheduled </span><span style="color: #ff0000">ref</span><span style="color: #0000ff">="work"</span><span style="color: #ff0000"> method</span><span style="color: #0000ff">="work"</span><span style="color: #ff0000"> cron</span><span style="color: #0000ff">="1 37 19 8 1 *"</span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /><img alt="" src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">task:scheduled-tasks</span><span style="color: #0000ff">></span><span style="color: #000000"> </span></div><br /><br />定义好之后,正常启动容器卛_Q只有条件符合,即会(x)按要求执行Q务?<img src ="http://www.aygfsteel.com/paulwong/aggbug/389451.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2012-10-12 10:51 <a href="http://www.aygfsteel.com/paulwong/archive/2012/10/12/389451.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SPRING BATCH SCRENhttp://www.aygfsteel.com/paulwong/archive/2012/10/11/389425.htmlpaulwongpaulwongThu, 11 Oct 2012 10:10:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/10/11/389425.htmlhttp://www.aygfsteel.com/paulwong/comments/389425.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/10/11/389425.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/389425.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/389425.htmlA job runs at a specific period in the day at a specific interval (e.g. between 1am - 3am at 15 minute intervals) . When it completes with a specific status, it stops (and does not run after 15 minutes) and does not get triggered again until the next day again at 1am, and at the same time, it triggers all dependent jobs.

SCENARIO 2:
A job is scheduled to run at a specific time of day. It continues to run at regular intervals until a condition is met, after which it stops running. It will then start running the next day at the scheduled time and process repeats.

Reference:

spring+quartz 动态Q务方?/div>

Quartz+Spring 自定义作业调度(作业在DB中配|)(j)

Quartz在Spring中动态设|cronExpressionQspring讄动态定时Q务)(j)

Quartz实现Java调度操作

Sping 中配|QuartzQSchedulerFactoryBean不能自动启动



paulwong 2012-10-11 18:10 发表评论
]]>SPRING BATCH ADMIN安装实录http://www.aygfsteel.com/paulwong/archive/2012/09/23/388382.htmlpaulwongpaulwongSun, 23 Sep 2012 11:36:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/09/23/388382.htmlhttp://www.aygfsteel.com/paulwong/comments/388382.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/09/23/388382.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/388382.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/388382.html
  • 下蝲
    从云端下载文Ӟ(x)http://s3.amazonaws.com/dist.springframework.org/release/BATCHADM/spring-batch-admin-1.2.1.RELEASE.zip

  • 更改JOBREPOSITRY的数据库
    支持从启动JVM时传参数Q即如果启动JVM时传?DENVIRONMENT=mysql|则读取batch-mysql.properties文gQ如未传|则默认读batch-hsql.properties文gQ如找不到此文gQ才dbatch-default.properties文gQ因此将batch-mysql.properties{删除,只保留default文gQ里面放数据库驱动程序等信息是开发环境时的首选做法。相关的properties文g可去http://www.springsource.org/download/community中下载。顺便将JDKҎ(gu)1.6QSPRING-BATCH的版本改成最新的2.1.8?br />
  • 生成WAR?nbsp;
    先用MAVEN安装PARENT包,再安装ADMIN包?br />
  • 部v
    打开TOMCATQ将WAR包丢q去卛_Q如果要在ECLIPSE中调试,此两个PROJECT 导入到ECLIPSE中,安装RUN-JETTY-RUN插gQ即可在ECLIPSE中启动JETTYQ而MAVEN目不用Ҏ(gu)ECLIPSE的WEB目Q推荐!
    讉K|址Qhttp://localhost:8080/spring-batch-admin-sample?br />
  • 部vJOB
    job的spring配置文g和相关class如itemreader{打成jar包,攑ֈMETA-INF/spring/batch/jobs/下,则会(x)自动昄到UI中?br />
    <点击下蝲修改后的控制?/a>> <点击下蝲例子>


  • paulwong 2012-09-23 19:36 发表评论
    ]]>
    SPRING BATCH 资源http://www.aygfsteel.com/paulwong/archive/2012/09/20/388179.htmlpaulwongpaulwongThu, 20 Sep 2012 05:25:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/09/20/388179.htmlhttp://www.aygfsteel.com/paulwong/comments/388179.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/09/20/388179.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/388179.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/388179.htmlhttp://www.cnblogs.com/gulvzhe/archive/2011/11/06/2238125.html 

    http://www.ibm.com/developerworks/cn/java/j-lo-springbatch1/

    单元试例子
    http://code.google.com/p/springbatchhanson/

    单元试STEP

    Spring Batch In Action例子


    paulwong 2012-09-20 13:25 发表评论
    ]]>
    spring batch基本概念http://www.aygfsteel.com/paulwong/archive/2012/09/19/388027.htmlpaulwongpaulwongTue, 18 Sep 2012 16:19:00 GMThttp://www.aygfsteel.com/paulwong/archive/2012/09/19/388027.htmlhttp://www.aygfsteel.com/paulwong/comments/388027.htmlhttp://www.aygfsteel.com/paulwong/archive/2012/09/19/388027.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/388027.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/388027.html
    LE:(x)
    由JobRunner启动JobQJob启动StepQStep启动TaskLetQTaskLet启动ChunkQChunk启动ItemRader/ItemProcessor/ItemWriter?br />
    Step之间可以讑֮程Q即在Step间放一个DecisionQ在上一步放一个ListenerQ根据条件把某变量值放到Context中,DecisionҎ(gu)此值决定下一步是哪个?br />
    DefaultLineMapperQ将STRING转成MAP

    DelimitedLineTokenizerQ将行以豆号分割出来攑ֈLIST

    BeanWrapperFieldSetMapperQ将MAP转成VO

    FlatFileItemWriterQ输出到文g

    DelimitedLineAggregatorQ对象{字符?br />
    自定义TaskLetQ如果Q务不是读或写那种,新增自定义cd成所需工作





    http://www.cnblogs.com/gulvzhe/archive/2011/11/06/2238125.html 

    http://www.ibm.com/developerworks/cn/java/j-lo-springbatch1/

    http://www.visa4uk.fco.gov.uk/Welcome.htm

    paulwong 2012-09-19 00:19 发表评论
    ]]>
    վ֩ģ壺 | | | ²| | ɫ| żҿ| | ϼ| | ̫| | ׶| | »| ʳ| | | | γ| | | | | ޳| | | н| Ͻ| | ¡| | | | ͼ| ˹| ǿ| | | | ͺ|