HoneyMoose
  • 首页
  • Java
  • Jersey
  • Jira
  • Confluence
  • U.S.
    • USRealEstate
    • USVisaTrack
    • H1B
  • 项目和网站
    • CWIKI.US
    • OSSEZ 社区
    • WIKI.OSSEZ.COM
    • BUG.OSSEZ.COM
    • RSS.OSSEZ.COM
Spring
Spring

Spring Data 的 Pivotal GemFire 参考指南前言

Spring Data 针对 Pivotal GemFire 关注整合强大的 Spring 框架的能力,无创编程模型和使用 Pivotal GemFire 数据管理方案的 GemFire 的概念来集成和简化配置,开发 Java 应用程序。 本文档假定你已经对 Spring Framework 和 Pivotal GemFire 的概念有了些基本的了解。 我们将会尽力保证这个文档的完整和正确。但是还会有一些主题和概念可能需要更进一步的解释和说明(例如,使用 HA 分区的数据分布管理平台依然会妨碍数据完整性)。 另外本文档中可能还会有一些排版的错误。如果你发现本文档中的一些错误甚至是一些更加严重的问,请告诉 Spring Data 项目组。你可以通过在 Spring Data JIRA 中来创建问题让项目组了解到。 https://www.cwiki.us/display/SpringDataZH/Spring+Data+for+Pivotal+GemFire+Reference+Guide

2020年03月01日 0Comments 563Browse 0Like Read more
Spring

Spring Batch 配置一个步骤(Step)

如我们在 域语言(Domain Language)章节中讨论的内容一致,一个 步骤(Step)是一个独立封装了执行顺序的批量作业(Job),并且包含有用于定义和控制一个批量作业的所有独立信息。 针对这个 Step 的定义必然是非常模糊的,因为任何一个给定步骤的内容都会被要求开发人员在编写一个作业(job)的时候被描述。 一个步骤(Step)可以根据开发人员的需求被开发为简单或者复杂。 一个简单的步骤可能就仅仅是从文件中载入数据然后写入到数据库中,可能并不需要太多的代码或者甚至都不需要代码(这个取决你需要的实现)。一个步骤(Step)也可能会比较复杂,这是因为你将要在数据处理的过程中实现一些复杂的业务规则,如下图所示: 图片 1. 步骤(Step)   https://www.cwiki.us/display/SpringBatchZH/Configuring+a+Step

2020年02月23日 0Comments 481Browse 0Like Read more
Spring

Spring Batch 在默认情况下的任务执行

在默认情况,如果你对 Spring Batch 不进行配置的话。 Spring Batch 将会对所有存在的作业(Job)进行执行。 考察项目:https://github.com/cwiki-us-spring/cwiki-us-spring-batch-examples 你可以 Check out 到本地后运行: gradlew :service:bootJar 将会对项目进行编译,程序将会输出: C:\WorkDir\Repository\Spring\cwiki-us-spring-guides\cwiki-us-spring-batch-examples>gradlew :service:bootJar > Configure project : You are using one or more deprecated Asciidoctor Gradle plugin features. To help with migration run with --warning-mode=all. Repository https://jcenter.bintray.com/ replaced by https://maven.ossez.com/repository/internal. BUILD SUCCESSFUL in 10s 6 actionable tasks: 2 executed, 4 up-to-date C:\WorkDir\Repository\Spring\cwiki-us-spring-guides\cwiki-us-spring-batch-examples> 然后你可以运行 java -jar service/build/libs/service.jar 你会发现没有作业被执行 程序输出如下: C:\WorkDir\Repository\Spring\cwiki-us-spring-guides\cwiki-us-spring-batch-examples>java -jar service/build/libs/service.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.4.RELEASE) 2020-02-18 15:32:38.016 INFO 28560 --- [ main] com.ossez.batch.service.Application : Starting Application on USWTWNB47141 with PID 28560 (C:\WorkDir\Repository\Spring\cwiki-us-spring-guides\cwiki-us-spring-batch-exam ples\service\build\libs\service.jar started by yhu in C:\WorkDir\Repository\Spring\cwiki-us-spring-guides\cwiki-us-spring-batch-examples) 2020-02-18 15:32:38.023 INFO 28560 --- [ main] com.ossez.batch.service.Application : No active profile set, falling back to default profiles: default 2020-02-18 15:32:40.344 INFO 28560 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2020-02-18 15:32:40.353 WARN 28560 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.hsqldb.jdbcDriver was not found, trying direct instantiation. 2020-02-18 15:32:40.854 INFO 28560 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported) 2020-02-18 15:32:40.866 INFO 28560 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2020-02-18 15:32:42.711 INFO 28560 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: HSQL 2020-02-18 15:32:43.137 INFO…

2020年02月18日 0Comments 1119Browse 0Like Read more
Spring

Spring Batch 小任务(Tasklet)步骤

Chunk-Oriented Processing不是处理 step 的唯一方法。 考虑下面的一个场景,如果你仅仅需要调用一个存储过程,你可以在 ItemReader 中实现这个调用,然后在存储过程完成调用后返回 null。这种设计看起来不是那么自然也不是非常优美,因为你的批量设计中甚至都不需要实现 ItemWriter。针对这种情况,Spring Batch 为你提供了 TaskletStep 选项。 TaskletStep 是一个简单的接口,这个接口只需要实现一个方法execute,这个方法将会被TaskletStep多次重复的调用,直到这个方法返回 RepeatStatus.FINISHED 或者抛出异常来表示调用失败。 Tasklet 的每一次调用都会包含在事务中(Transaction)。Tasklet 的实现(implementors)可以调用一个存储过程,一个脚本或者一个简单的 SQL 更新脚本。 针对我们的实践中,我们可以使用 Tasklet 来执行一个 FTP 的任务。 将我们产生的中间文件上传到不同的 FTP 服务器上,你可以在实现中指定不同的服务器配置参数,这样更加有利于代码的重用。 为了能够创建一个 TaskletStep,Bean 需要传递一个 tasklet 方法到构造器(builder),这个 tasklet 方法需要实现 Tasklet 接口。 当你构建 TaskletStep 的时候不要调用 chunk。 下面的示例代码显示了一个在 Step build 中构建一个简单的 tasklet。 @Bean public Step step1() {     return this.stepBuilderFactory.get("step1")                 .tasklet(myTasklet())                 .build(); } 如果你的 tasklet 实现了 StepListener  接口的话,TaskletStep 将会自动将 tasklet 注册成为一个 StepListener。 TaskletAdapter 与 ItemReader 和 ItemWriter 接口的 adapters一样。Tasklet  接口包含的实现也允许能够通过已经存在的类使用 TaskletAdapter 来将自己进行注册。 例如,你希望使用一个已经存在的 DAO 来更新记录集上的标记的时候,你可以使用 TaskletAdapter 来进行实现。 使用 TaskletAdapter  能够让你的 DAO 可以被 Spring Batch 的 TaskletStep 调用而不需要让你的 DAO 都实现 Tasklet 的接口。 如下面的示例代码: @Bean public MethodInvokingTaskletAdapter myTasklet() {     MethodInvokingTaskletAdapter adapter = new MethodInvokingTaskletAdapter();     adapter.setTargetObject(fooDao());     adapter.setTargetMethod("updateFoo");     return adapter; } Tasklet 实现(Implementation)示例 在主批量作业开始之前,可能需要很多其他的批量作业必须完成,这样以便于主批量作业能够获得必要的资源和在完成后释放资源或者进行清理。 例如我们遇到下面的使用场景,一个批量作业需要大量的对文件进行交互和使用,通常来说需要在文件被上传到其他服务器上后删除本地产生的临时文件。 下面的示例就是一个 Tasklet 的实现,这个Tasklet 的实现能够完成上面的交互要求(文件来自 Spring Batch samples project 示例程序)。 public class FileDeletingTasklet implements Tasklet, InitializingBean {     private Resource directory;     public RepeatStatus execute(StepContribution contribution,                                 ChunkContext chunkContext) throws Exception {         File dir = directory.getFile();         Assert.state(dir.isDirectory());         File[] files = dir.listFiles();         for (int i = 0; i < files.length; i++) {             boolean deleted = files[i].delete();             if (!deleted) {                 throw new UnexpectedJobExecutionException("Could not delete file " +                                                           files[i].getPath());             }         }         return RepeatStatus.FINISHED;     }     public void setDirectoryResource(Resource directory) {         this.directory = directory;     }     public void afterPropertiesSet() throws Exception {         Assert.notNull(directory, "directory must be set");     } }   Tasklet 处理程序实现了将给定目录中的所有文件进行删除。我们应该通知 execute  方法,这个 Tasklet 应该只被执行一次。 所有相关执行的操作需要在 Step 中进行设置,请参考下面有关这个 Tasklet 的设置: Java 配置 @Bean public Job taskletJob() {     return this.jobBuilderFactory.get("taskletJob")                 .start(deleteFilesInDir())                 .build(); } @Bean public Step deleteFilesInDir() {     return this.stepBuilderFactory.get("deleteFilesInDir")                 .tasklet(fileDeletingTasklet())                 .build(); } @Bean public FileDeletingTasklet fileDeletingTasklet() {     FileDeletingTasklet tasklet = new FileDeletingTasklet();     tasklet.setDirectoryResource(new FileSystemResource("target/test-outputs/test-dir"));     return tasklet; }   https://www.cwiki.us/display/SpringBatchZH/TaskletStep

2020年02月17日 0Comments 552Browse 0Like Read more
Spring

Spring Batch 4.2 新特性

Spring Batch 4.2 的发行版主要增强了下面的改进: 使用 Micrometer 来支持批量指标(batch metrics) 支持从 Apache Kafka topics 读取/写入(reading/writing) 数据 支持从 Apache Avro 资源中读取/写入(reading/writing) 数据 改进支持文档 使用 Micrometer 的批量指标 本发行版本介绍了可以让你通过使用 Micrometer 来监控你的批量作业。在默认的情况下,Spring Batch 将会收集相关批量指标(包括,作业时间,步骤的时间,读取和写入的项目,以及其他的相关信息),和将这些指标通过 spring.batch 前缀(prefix)注册到 Micrometer 的全局指标中。 这些指标可以发布到任何能够支持 Micrometer 的  监控系统(monitoring system)中。 有关这个新特性的更多细节,请参考 Monitoring and metrics 章节中的内容。 Apache Kafka item 读取/写入 本发行版本添加了一个新的 KafkaItemReader 和 KafkaItemWriter ,用来从 Kafka 的 topics 中读取和写入。 有关更多这个新组建的信息,请参考:Javadoc。 Apache Avro item 读取/写入 本发行版本添加了一个新的 AvroItemReader 和 AvroItemWriter,用来从 Avro 资源中读取和写入。 有关更多这个新组建的信息,请参考: Javadoc。 文档更新 对参考的文档进行更新,以便于与其他 Spring 项目的文档风格保持一致。 4.1 版本的文档更新 下面的内容是 4.1 文档版本中的更新,我们没有将这部分内容从我们的 WIKI 中删除已保持历史信息的一致。 请参考下面链接获得 4.1 文档版本中的更新,在官方的文档中,下面的内容已经不在 4.2 的文档中了。 @SpringBatchTest Annotation @EnableBatchIntegration Annotation JSON support Bean Validation API support JSR-305 Support FlatFileItemWriterBuilder Enhancements https://www.cwiki.us/pages/viewpage.action?pageId=41685600

2019年09月10日 0Comments 748Browse 0Like Read more
Spring Batch

Spring Batch - 参考文档(Reference Documentation)

欢迎来到 Spring 批量(Spring Batch)文档!本文档的内容同时还提供单一 html 和 pdf 文档。 本参考文档被分列为下面的部分: 文档内容链接 文档介绍 Spring Batch Introduction 背景,使用场景和一些常用使用指引。 What’s New in Spring Batch 4.2 4.2 版本中的新特性。 The Domain Language of Batch 核心概念和有关批处理域语言(Batch Domain Language)的抽象 Configuring and Running a Job 作业(Job)配置,执行和管理 Configuring a Step 步骤(Step)配置,不同类型的步骤,控制步骤流 ItemReaders and ItemWriters 条目(Item)读和写接口以及如何使用它们 Scaling and Parallel Processing 多线程步骤(Steps),并行步骤,远程分块(Chunking)和分区(Partitioning) Repeat 重复行为(Repetitive Actions)的完成策略和异常处理 Retry 可重试操作的重做和退出策略 Unit Testing 作业和步骤的测试策略和 APIs Common Batch Patterns 通用批量处理模式和使用指引 JSR-352 Support JSR-352 支持,与 Spring Batch 相似和不同之处 Spring Batch Integration Spring Batch 与 Spring 其他项目的整合 Monitoring and metrics 批量作业的监控和指标 有下列有关的可用附录: 附录名称和链接 文档介绍 List of ItemReaders and ItemWriters 提供的开箱即用(out-of-the box)项目读和写的完整列表 Meta-Data Schema 批量域模式使用的核心表 Batch Processing and Transactions Spring Batch 中使用的事务边界(Transaction Boundaries),事务传播(Transaction propagation)和事务隔离级别(Transaction Isolation Levels) Glossary 批量域中使用的常用术语,概念和词汇。 文档的中文版本由 CWIKI.US 进行翻译和整理。请访问 Spring Batch 文档和手册(中文)   https://www.cwiki.us/display/SpringBatchZH/Reference+Documentation

2019年08月28日 0Comments 1439Browse 1Like Read more
Spring

Flyway Validate failed: Migration checksum mismatch for migration version 1.0.0.01 错误

在运行系统的时候出现错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed: Migration checksum mismatch for migration version 1.0.0.01 -> Applied to database : 1062144176 -> Resolved locally : 1432425380   尝试使用命令: > mvn flyway:migrate 来对校验进行合并  

2019年06月06日 0Comments 1455Browse 0Like Read more
Spring

Spring Batch JSR-305 支持

本发布版本中为 JSR-305 支持添加了一个注解。这个为了与 Spring 框架中的  Null-safety 注解取得平衡,然后为 Spring Batch 添加为 public APIs。 这个注解不仅仅在使用 Spring Batch APIs 来强制空安全(null-safety),同时还可以通过使用 IDEs 来提供有用的相关 nullability 信息。例如,如果用户希望实现 ItemReader  接口,任何能够支持 JSR-305 注解的 IDE 将会生成类似下面的代码:   public class MyItemReader implements ItemReader<String> {         @Nullable         public String read() throws Exception {                 return null;         } }   @Nullable 注解将会出现在 read 方法中,用来表示这个方法的内容可能将会返回一个 null。 这个将会强制在 Javadoc 中强制表示当在数据资源耗尽的时候,方法 read 将会返回一个 null。 https://www.cwiki.us/display/SpringBatchZH/JSR-305+Support

2019年01月21日 0Comments 1192Browse 0Like Read more
Spring

Spring Batch Bean 校验 API 支持

这个发布版本带来了一个新的  ValidatingItemProcessor 实现,这个实现被称为 BeanValidatingItemProcessor。能够让你使用 Bean Validation API (JSR-303) 来校验 Item 的注解。例如给定下面的类型 Person: class Person {     @NotEmpty     private String name;     public Person(String name) {         this.name = name;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     } } 你可以通过在你的应用上下文中声明一个 BeanValidatingItemProcessor  并在你的原始块步骤中注册来校验 items: @Bean public BeanValidatingItemProcessor<Person> beanValidatingItemProcessor() throws Exception {         BeanValidatingItemProcessor<Person> beanValidatingItemProcessor = new BeanValidatingItemProcessor<>();         beanValidatingItemProcessor.setFilter(true);         return beanValidatingItemProcessor; }   https://www.cwiki.us/display/SpringBatchZH/Bean+Validation+API+support

2019年01月21日 0Comments 1180Browse 0Like Read more
Spring

Spring Batch JSON 支持

Spring Batch 4.1 开始能够支持 JSON 格式了。这个发布介绍了一个新的数据读(item reader)能够读取一个 JSON 资源,这个资源按照下面的格式: [   {     "isin": "123",     "quantity": 1,     "price": 1.2,     "customer": "foo"   },   {     "isin": "456",     "quantity": 2,     "price": 1.4,     "customer": "bar"   } ]   与针对 XML 的 StaxEventItemReader 类似,新的 JsonItemReader 使用流 API(streaming APIs)来读取 JSON 对象到块中。Spring Batch 能够支持下面 2 个库: Jackson Gson 如果你还希望添加其他的库的话,你可以实现 JsonObjectReader  接口。 JSON 数据的写是通过 JsonFileItemWriter 来支持的。 有关更多 JSON 数据的支持,请参考 ItemReaders and ItemWriters 章节中的内容。 https://www.cwiki.us/display/SpringBatchZH/JSON+support

2019年01月18日 0Comments 998Browse 0Like Read more
12345
Newest Hotspots Random
Newest Hotspots Random
来看一个 ChatGPT 有关程序员的笑话 IntelliJ IDEA 的 Code Coverage 测试 Okhttp 如何构建一个 Get 的 URL SpringBoot 使用 @ConfigurationProperties 异常 Not registered via @EnableConfigurationProperties Jackson 的 DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES 1月14号的 UA857
说说这 48 小时核酸检测的时间FAA 真的应该换换系统了Java 8 使用 Stream 把 List 转换为 mapPowerShell 中运行 maven 参数无法识别1月14号的 UA857Jackson 的 DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
Maven 中依赖使用的版本号 VUE 如何格式化数字 Docker 文档编译 - 创建标签(Tab)页 CentOS 8 如何安装 htop Confluence 6 创建你的个人空间 Spring Batch 在默认情况下的任务执行
Categories
  • Algorithm(算法)
  • AMQP
  • Angular
  • CI
  • Compile And CI
  • Computer Science
  • Confluence
  • DataBase
  • Gradle
  • H1B
  • Hibernate
  • IDE
  • Java
  • Jersey
  • Jira
  • MariaDB
  • PrestaShop
  • Spring
  • Spring Batch
  • U.S.
  • USRealEstate
  • USVisaTrack
  • 我的小厨

COPYRIGHT © 2020 HoneyMoose. ALL RIGHTS RESERVED.

THEME CWIKIUS.CN MADE BY VTROIS