Cassandra与SpringBatch批处理

使用SpringBatch框架将海量数据文件中数据批量导入Cassandra数据库中


  • SpringBatch通过springbatch.xml中 batch:job标签具体定义job工作内容
  • step job内步骤项 这里只需要一个就可以
  • tasklet 任务集,可以指定线程池来执行
  • chunk : read-process-write模式 读csv文件,程序处理,然后写入Cassandra
  • commit-interval : 事务隔多少次提交
    <batch:job id="integrationTradingDate">
		<batch:step id="readTradingDateWriteToDatebase">
			<batch:tasklet task-executor="taskExecutor"
                           throttle-limit="20">
				<batch:chunk reader="inputDateReader" writer="ProductItemWriter"
							 processor="itemProcessor" commit-interval="12">
				</batch:chunk>
			</batch:tasklet>
		</batch:step>
	</batch:job>

项目源码下载

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <artifactId>dataIntegration</artifactId>
        <groupId>com.beifa.cn.data.integration</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>tradingDate</artifactId>
    <packaging>jar</packaging>

    <name>A Camel Route</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Camel BOM -->
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-parent</artifactId>
                <version>2.22.0</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
        </dependency>

        <!-- logging -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- testing 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值