批量扣收java_cb4j: csv batch for java 是一个java批量处理csv的类库.旨在简化csv文件的批量处理. cb4j解决常见的如读取,解析和验证csv所记录的繁琐工作,让你...

Easy Batch

The simple, stupid batch framework for Java™

license-MIT-brightgreen.svg?style=flat

badge.svg

badge.svg?style=flat

easy-batch-core.svg

Project%20status-Maintenance-orange.svg

Project status

As of November 18, 2020, Easy Batch is in maintenance mode. This means only bug fixes will be addressed from now on.

Version 7.0.x is the only supported version.

Latest news

18/12/2020: Version 7.0.1 is out with a minor bug fix and some dependency updates. Check the release notes here.

24/09/2020: Version 7.0.0 is out with several enhancements towards type safe APIs. See the change log here.

What is Easy Batch?

Easy Batch is a framework that aims to simplify batch processing with Java. It was specifically designed for simple ETL jobs.

Writing batch applications requires a lot of boilerplate code: reading, writing, filtering, parsing and validating data, logging, reporting to name a few..

The idea is to free you from these tedious tasks and let you focus on your batch application's logic.

How does it work?

Easy Batch jobs are simple processing pipelines. Records are read in sequence from a data source, processed in pipeline and written in batches to a data sink:

91ecd60fa9e9ce1fab7a5dfb1e186aa7.png

The framework provides the Record and Batch APIs to abstract data format and process records in a consistent way regardless of the data source type.

Let's see a quick example. Suppose you have the following tweets.csv file:

id,user,message

1,foo,hello

2,bar,@foo hi!

and you want to transform these tweets to XML format. Here is how you can do that with Easy Batch:

Path inputFile = Paths.get("tweets.csv");

Path outputFile = Paths.get("tweets.xml");

Job job = new JobBuilder()

.reader(new FlatFileRecordReader(inputFile))

.filter(new HeaderRecordFilter<>())

.mapper(new DelimitedRecordMapper<>(Tweet.class, "id", "user", "message"))

.marshaller(new XmlRecordMarshaller<>(Tweet.class))

.writer(new FileRecordWriter(outputFile))

.batchSize(10)

.build();

JobExecutor jobExecutor = new JobExecutor();

JobReport report = jobExecutor.execute(job);

jobExecutor.shutdown();

This example creates a job that:

reads records one by one from the input file tweets.csv

filters the header record

maps each record to an instance of the Tweet bean

marshals the tweet to XML format

and finally writes XML records in batches of 10 to the output file tweets.xml

At the end of execution, you get a report with statistics and metrics about the job run (Execution time, number of errors, etc).

All the boilerplate code of resources I/O, iterating through the data source, filtering and parsing records, mapping data to the domain object Tweet, writing output and reporting

is handled by Easy Batch. Your code becomes declarative, intuitive, easy to read, understand, test and maintain.

Quick start

Add the following dependency to your project and you are ready to go:

org.jeasy

easy-batch-core

7.0.1

You can also generate a quick start project with the following command:

$>mvn archetype:generate \

-DarchetypeGroupId=org.jeasy \

-DarchetypeArtifactId=easy-batch-archetype \

-DarchetypeVersion=7.0.1

For more details, please check the Getting started guide.

Presentations, articles & blog posts

Current versions

Stable:

Development:

The current development version is 7.0.2-SNAPSHOT: badge.svg

If you want to import a snapshot version, please check the Getting started guide.

Contribution

You are welcome to contribute to the project with pull requests on GitHub.

Please note that Easy Batch is in maintenance mode,

which means only pull requests for bug fixes will be considered.

If you believe you found a bug or have any question, please use the issue tracker.

Awesome contributors

Thank you all for your contributions!

Who is using Easy Batch?

Easy Batch has been successfully used in production in a number of companies which I (@benas) am not allowed to mention.

That said, there are some companies which publicly mention that they use Easy Batch:

You can also find some feedback from the community about the project in the Testimonials section.

Credits

a2ccd6fb5dcc4abcf6c6e7cdab372ae9.png

Many thanks to YourKit, LLC for providing a free license of YourKit Java Profiler to support the development of Easy Batch.

License

Easy Batch is released under the terms of the license-MIT-brightgreen.svg?style=flat.

The MIT License (MIT)

Copyright (c) 2021 Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in

all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

THE SOFTWARE.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值