Skip to content

Instantly share code, notes, and snippets.

View tkstone's full-sized avatar

Pete TK tkstone

View GitHub Profile
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.RecordMetadata;
import java.util.Properties;
import java.util.concurrent.Future;
public class TestProducer {
private Producer<String, String> producer;
import java.util.List;
import java.util.Map;
import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;
import org.apache.kafka.common.PartitionInfo;
public class TestPartitioner implements Partitioner{
@Override
public void configure(Map<String, ?> arg0) {
<bean id="ParameterSetter" class="test.reader.TestPartitionParameterSetter" scope="step">
<property name="startParam" value="#{stepExecutionContext['StartDay']}"/>
<property name="endParam" value="#{stepExecutionContext['EndDay']}"/>
</bean>
<bean id="TestReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader"
scope="step">
<property name="dataSource" ref="testDataSource"/>
<property name="sql"
import java.util.HashMap;
import java.util.Map;
import org.springframework.batch.core.partition.support.Partitioner;
import org.springframework.batch.item.ExecutionContext;
public class DayOfWeekPartitioner implements Partitioner {
@Override
public Map<String, ExecutionContext> partition(int gridSize) {
<batch:job id="TestPartitionJob" job-repository="jobRepository">
<batch:step id="TestPartitionStep">
<batch:partition step="SingleStep" partitioner="DayOfWeekPartitioner">
<batch:handler grid-size="7" task-executor="TaskExecutor" />
</batch:partition>
</batch:step>
</batch:job>
<bean id="DayOfWeekPartitioner"
class="test.reader.DayOfWeekPartitioner"
<batch:job id="TestCompositeJob" job-repository="jobRepository">
<batch:step id="SimpleStep">
<batch:tasklet transaction-manager="testTransactionManager" allow-start-if-complete="true">
<batch:chunk
reader="TestReader"
processor="TestProcessor"
writer="TestCompositeWriter"
commit-interval="1"
reader-transactional-queue="false"
/>
<bean id="TestCompositeWriter"
class="org.springframework.batch.item.support.CompositeItemWriter"
scope="step">
<property name="delegates">
<list>
<ref bean="TestWriter1"/>
<ref bean="TestWriter2"/>
</list>
</property>
</bean>
public class TargetVO {
public String new_col1;
public String new_col2;
public String new_col3;
public String getNewCol1() {
return this.new_col1;
}
public String getNewCol2() {
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
public class TestRun2_2 {
public static void main(String[] args) throws Exception{
<bean id="SourceMapper"
class="test.rowmapper.TbSourceMapper"/>
<bean id="ParameterSetter" class="test.reader.TestParameterSetter" scope="step">
<property name="param" value="#{jobParameters['param1']}"/>
</bean>
<bean id="TestReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader"
scope="step">