So i have this xml file.
So i have several question.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> <batch:job-repository id="repository" data-source="dataSource" transaction-manager="transactionManager" isolation-level-for-create="DEFAULT" /> <batch:job id="enableUserJob" job-repository="repository" restartable="true"> <batch:step id="activateUser"> <batch:tasklet allow-start-if-complete="false" transaction-manager="transactionManager"> <batch:chunk writer="userItemWriter" reader="userItemReader" commit-interval="${hibernate.jdbc.batch_size}"/> <batch:transaction-attributes propagation="REQUIRED"/> </batch:tasklet> </batch:step> </batch:job> <bean id="userStatusMapper" class="com.advertising.mapper.UserStatusMapper"/> <bean id="userItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader"> <property name="sql"> <value> <![CDATA[ SELECT user_id, user_status FROM user WHERE user_status=:lockStatus AND create_time < :current_time ]]> </value> </property> <property name="queryTimeout" value="30"/> <property name="fetchSize" value="${hibernate.jdbc.batch_size}"/> <property name="rowMapper" ref="userStatusMapper"/> <property name="dataSource" ref="dataSource"/> </bean> <bean id="userItemWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter"> <property name="dataSource" ref="dataSource"/> <property name="sql"> <value> <![CDATA[ UPDATE user SET user_status=:enableStatus WHERE user_id=:userId ]]> </value> <property name="itemSqlParameterSourceProvider" ref="sourceProvider"/> </bean> <bean id="sourceProvider" class="com.advertising.provider.UserStatusSourceProvider"/> </beans>
1.) How do i pass in parameter as run time parameter (i.e. current time from shell script). [Note: i can write the script], but getting spring batch to accept run time parameter.
2.) Is this correct way to read from db and than write to db.
-- I want to be able to read from db all the user that are lock and have been created within last 5 minute (I can pass in via shell script), write to another db.


Reply With Quote