Announcement Announcement Module
No announcement yet.
2 datasource in one JdbcCursorItemReader? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2 datasource in one JdbcCursorItemReader?


    I must to pull data from 2 datasource (2 Mysql DB) and then perform some business modification on this...

    For now, I just configured one datasource and all works fine...

    Here is my configuration :

    	<job id="job1" >
    		<step id="step1">
    				<chunk reader="itemReader" processor="bewebProcessor" writer="itemWriter" commit-interval="1"> </chunk>	
    			<listener class="com.beweb.batch.quartz.SampleListener"/>
    	<beans:bean id="itemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
    		<beans:property name="dataSource" ref="dataSource_beweb" />
    		<beans:property name="rowMapper">
    			<beans:bean class="com.beweb.batch.quartz.domain.internal.PersonneMapper" />
    		<beans:property name="sql">
    				SELECT personne.personne_id, personne.last_name, personne.first_name,
    				personne.pos, personne.year_of_birth, personne.year_drafted
    				from personne
    	<beans:bean id="itemWriter" class="example.ExampleItemWriter" />
    	<beans:bean id="bewebProcessor" class="com.beweb.batch.quartz.BewebProcessor" />
    What must I do to add another datasrouce?
    Must I define another step or can I work with the same step?

    Thank you very much for your help...


  • #2
    There has to be a single transaction manager shared between your application code and Spring Batch, so that's the main constraint. Once you have sorted that out, you can start to think about how to provide your custom business logic. See this article for some deeper discussion of transaction semantics and multiple data sources: