Announcement Announcement Module
Collapse
No announcement yet.
Chunk handling from JdbcCursorItemReader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Chunk handling from JdbcCursorItemReader

    Bonjour,

    I am trying to adapt the sample in RemoteChunkStepIntegrationTests-context.xml by changing the following:

    1) Use JdbcCursorItemReader
    2) Write directly to the "requests" channel from the ItemWriter
    3) Use a custom ChunkMessageChannelItemWriter in order to remove the sending of messages from the write() method

    But I keep seeing the following error:

    13:59:31,450 ERROR jobLauncherTaskExecutor-1 step.AbstractStep:212 - Encountered an error executing the step
    org.springframework.integration.MessageHandlingExc eption: org.springframework.expression.spel.SpelEvaluation Exception: EL1004Epos 8): Method call: Method handleChunk(java.util.Collections$UnmodifiableRand omAccessList) cannot be found on org.springframework.batch.integration.chunk.ChunkP rocessorChunkHandler type
    at org.springframework.integration.handler.MethodInvo kingMessageProcessor.processMessage(MethodInvoking MessageProcessor.java:76)

    Here is my context:

    Code:
    <bean id="incrementer" class="org.springframework.batch.admin.sample.TrivialJobParametersIncrementer" />
    	
    	<bean id="taskExecutor" parent="throttledTaskExecutor">
    		<property name="throttleLimit" value="100" />
    	</bean>
    	 
        <job id="remoteProductOrderJob" xmlns="http://www.springframework.org/schema/batch" incrementer="incrementer">
    		<step id="readOrders" parent="readOrdersStep" />
    	</job>
    	
    	<step id="readOrdersStep" xmlns="http://www.springframework.org/schema/batch">
    		<tasklet start-limit="100">
    			<chunk commit-interval="100" reader="productOrderSource"  writer="gatewayWriter" />
    		</tasklet>
    	</step>
    	
    	<bean id="productOrderSource" class="org.springframework.batch.item.database.JdbcCursorItemReader">
    		<property name="dataSource" ref="dataSource" />
    		<property name="rowMapper" ref="productOrderRowMapper" />	
    		<property name="sql" value="SELECT * from Customerorder Co where Co.id = 635757"/>
    	</bean>
    	
    	<bean id="productOrderRowMapper" class="com.imagitas.productOrder.ProductOrderRecordRowMapper"/>	
    
    	<integration:channel id="requests" />
    
    	<integration:gateway id="gatewayWriter" service-interface="org.springframework.batch.item.ItemWriter"
    		 default-request-channel="requests"/>
    
    	<bean id="messagingGateway" class="org.springframework.integration.core.MessagingTemplate">
    		<property name="defaultChannel" ref="requests" />
    		<property name="receiveTimeout" value="1000" />
    	</bean>
    	
    	<bean id="chunkWriter" class="com.imagitas.productOrder.OrderForwardingResponseChannelItemWriter" scope="step">
    		<property name="messagingOperations" ref="messagingGateway" />
    		<property name="replyChannel" ref="replies" />
    	</bean>
    	
    	<integration:channel id="replies">
    		<integration:queue />
    	</integration:channel>
    	<integration:service-activator input-channel="requests" output-channel="replies" ref="chunkHandler" />
    
    	<bean id="chunkHandler" class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean">
    		<property name="chunkWriter" ref="chunkWriter" />
    		<property name="step" ref="readOrdersStep" />
    	</bean>
    	
    	
    	<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
    Is it that I have to explicitly transform the List of mapped objects returned from the reader into a ChunkRequest? I've tried doing that but encountered other errors which may warrant a second post. I first wanted to see if there is a recommended approach for the case of using JdbcCursorItemReader and sending the result directly to a channel for Chunk handling.

    Thanks

  • #2
    fixed

    This problem has been fixed. I had convoluted the sample context. The only change needed from the sample was simply to use JdbcCursorItemReader. The TestItemWriter is fine. I was confused about the ChunkMessageChannelItemWriter's retrieving the items from localState. Here is the fixed context:

    Code:
    <bean id="taskExecutor" parent="throttledTaskExecutor">
    		<property name="throttleLimit" value="100" />
    	</bean>
    	
        
        <job id="remoteProductOrderJob" xmlns="http://www.springframework.org/schema/batch" incrementer="incrementer">
    		<step id="step">
    			<tasklet>
    				<chunk reader="productOrderReader" writer="writer" commit-interval="2" />
    			</tasklet>
    		</step>
    	</job>
    	
    	<bean id="productOrderReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
    		<property name="dataSource" ref="dataSource" />
    		<property name="rowMapper" ref="productOrderRowMapper" />	
    		<property name="sql" value="SELECT * from Customerorder Co where Co.id = 635757"/>
    	</bean>
    	
    	<bean id="writer" class="org.springframework.batch.integration.chunk.TestItemWriter" />
    	
    	<bean id="productOrderRowMapper" class="com.imagitas.productOrder.ProductOrderRecordRowMapper"/>
    	
    	
    	<bean id="messagingGateway" class="org.springframework.integration.core.MessagingTemplate">
    		<property name="defaultChannel" ref="requests" />
    		<property name="receiveTimeout" value="1000" />
    	</bean>
    	
    	<bean id="chunkWriter" class="org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter" scope="step">
    		<property name="messagingOperations" ref="messagingGateway" />
    		<property name="replyChannel" ref="replies" />
    	</bean>
    	
    	
    	<task:executor id="poolExecutor" pool-size="5-10" queue-capacity="0" />
    	
    	<integration:publish-subscribe-channel id="requests" task-executor="poolExecutor" />
    	
    	<integration:channel id="replies">
    		<integration:queue />
    	</integration:channel>
    	<integration:service-activator input-channel="requests" output-channel="replies" ref="chunkHandler" />
    
    	<bean id="chunkHandler" class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean">
    		<property name="chunkWriter" ref="chunkWriter" />
    		<property name="step" ref="step" />
    	</bean>
    	
    	
    	<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />

    Comment

    Working...
    X