Announcement Announcement Module
Collapse
No announcement yet.
Multiple writers and processors in Spring Batch 2.1.8 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple writers and processors in Spring Batch 2.1.8

    Hi,

    Need to implement the processor after reader the file in Spring Batch 2.1.8.

    But not able to add Chunk tag inside the tasklet tag of Springjob.xml.

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schem...spring-aop.xsd
    http://www.springframework.org/schema/batch http://www.springframework.org/schem...-batch-2.1.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <import resource="applicationContext.xml"/>

    <!-- Set up our reader and its properties -->
    <bean id="itemReader" class="org.springframework.batch.item.file.FlatFil eItemReader">
    <property name="resource" value="file:C:\data\input\player1.txt" />
    <property name="recordSeparatorPolicy" ref="recordSeparatorPolicy" />
    <property name="lineMapper" ref="lineMapper" />
    </bean>

    <bean id="recordSeparatorPolicy" class="org.springframework.batch.item.file.separat or.SimpleRecordSeparatorPolicy"/>

    <bean id="lineMapper" class="org.springframework.batch.item.file.mapping .DefaultLineMapper">

    <property name="fieldSetMapper" ref="fieldSetMapper1" />
    <property name="lineTokenizer" ref="lineTokenizer1" />
    </bean>

    <bean id="fieldSetMapper1" class="com.vignesh.batch21.PlayerFieldSetMapper"/>

    <bean id="lineTokenizer1" class="org.springframework.batch.item.file.transfo rm.FixedLengthTokenizer">
    <property name="names" value="accountNumber,businessName,addr1,addr2,city ,state,zip,phone,countryCode,phoneCode,bizID,duns, dummy" />
    <property name="columns" value="1-30,31-120,121-190,191-260,261-310,311-360,361-370,371-380,381-382,371-380,400-419,385-393,420-451" />

    </bean>

    <!-- Set up our writer, and it's properties -->
    <bean id="itemWriter" class="org.springframework.batch.item.file.FlatFil eItemWriter">
    <property name="resource" value="file:c:/data/output/hello2.txt" />
    <property name="lineAggregator" ref="lineAggregator1"/>
    </bean>




    <bean id="lineAggregator1" class="org.springframework.batch.item.file.transfo rm.DelimitedLineAggregator">
    <property name="delimiter" value="*"/>
    <property name="fieldExtractor" ref="fieldExtractor1"/>
    </bean>

    <bean id="fieldExtractor1" class="org.springframework.batch.item.file.transfo rm.BeanWrapperFieldExtractor">
    <property name="names" value="accountNumber,businessName"/>
    </bean>




    <!-- Set up our transformation step with these beans in -->
    <bean id="step" class="org.springframework.batch.core.step.item.Si mpleStepFactoryBean">
    <property name="transactionManager" ref="transactionManager" />
    <property name="jobRepository" ref="jobRepository"/>
    <property name="itemReader" ref="itemReader"/>
    <property name="itemWriter" ref="itemWriter"/>
    </bean>




    <bean id="careerProcessor" class="com.vignesh.batch21.CareerProcessor" />

    <!-- Set up our job to run said step -->
    <bean id="readwriteJob" class="org.springframework.batch.core.job.SimpleJo b">
    <property name="name" value="readwriteJob" />
    <property name="steps">
    <list>
    <ref local="step"/>
    </list>
    </property>
    <property name="jobRepository" ref="jobRepository"/>
    </bean>

    <!-- New -->

    <bean id="customEditorConfigurer"
    class="org.springframework.beans.factory.config.Cu stomEditorConfigurer">
    <property name="customEditors">
    <map>
    <entry key="org.springframework.batch.item.file.transform .Range[]">
    <bean class="org.springframework.batch.item.file.transfo rm.RangeArrayPropertyEditor" />
    </entry>
    </map>
    </property>
    </bean>
    <!-- New -->

    </beans>

    After adding Chunk tag inside the tasklet it throwing following error.

    cvc-complex-type.2.4.a: Invalid content was found starting with element 'tasklet'. One of '{"http://www.springframework.org/schema/beans":meta, "http://www.springframework.org/schema/beans":constructor-arg, "http://www.springframework.org/schema/beans"roperty, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.

  • #2
    Can you put your configuration in
    Code:
    Code Tags
    please? It'll make your question easier to read. Also, I can't see the definition of the chunk and tasklet here (maybe I'll spot them when the code tags are included), did you post them?

    Comment

    Working...
    X