Multithreading with Stax input files exception ?
Hi,
I'm defining a batch solution for our product used in insurance and banking.
I'm currently investigating Spring-batch, which seems a near-perfect solution to our needs.. ;)
Using trunk or 1.0m2, when I try to setup a multithreading processing of an XML input file using StaxEventReaderInputSource and TaskExecutorRepeatTemplate with SimpleAsyncTaskExecutor, I get the following error:
Code:
10:09:56,863 DEBUG SimpleAsyncTaskExecutor-1 TransactionTemplate:151 - Initiating transaction rollback on application exception
org.springframework.dao.DataAccessResourceFailureException: Error while reading from event reader; nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at org.springframework.batch.io.file.support.StaxEventReaderInputSource.moveCursorToNextFragment(StaxEventReaderInputSource.java:261)
at org.springframework.batch.io.file.support.StaxEventReaderInputSource.read(StaxEventReaderInputSource.java:88)
at org.springframework.batch.io.file.support.StaxEventReaderInputSource$$FastClassByCGLIB$$db438604.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
at org.springframework.batch.io.file.support.StaxEventReaderInputSource$$EnhancerByCGLIB$$94aa0c51.read(<generated>)
at org.springframework.batch.item.provider.InputSourceItemProvider.next(InputSourceItemProvider.java:48)
at org.springframework.batch.execution.tasklet.ItemProviderProcessTasklet.execute(ItemProviderProcessTasklet.java:141)
at org.springframework.batch.execution.step.simple.SimpleStepExecutor.doTaskletProcessing(SimpleStepExecutor.java:372)
at org.springframework.batch.execution.step.simple.DefaultStepExecutor.doTaskletProcessing(DefaultStepExecutor.java:61)
at org.springframework.batch.execution.step.simple.SimpleStepExecutor$2.doInIteration(SimpleStepExecutor.java:347)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:324)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:201)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:131)
at org.springframework.batch.execution.step.simple.SimpleStepExecutor.processChunk(SimpleStepExecutor.java:334)
at org.springframework.batch.execution.step.simple.SimpleStepExecutor$1$2.doInTransaction(SimpleStepExecutor.java:220)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
at org.springframework.batch.execution.step.simple.SimpleStepExecutor$1.doInIteration(SimpleStepExecutor.java:208)
at org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:227)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:588)
at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:271)
at org.springframework.batch.io.file.support.stax.DefaultTransactionalEventReader.peek(DefaultTransactionalEventReader.java:86)
at org.springframework.batch.io.file.support.stax.DefaultFragmentEventReader.peek(DefaultFragmentEventReader.java:152)
at org.springframework.batch.io.file.support.StaxEventReaderInputSource.moveCursorToNextFragment(StaxEventReaderInputSource.java:246)
... 24 more
Maybe I did something wrong or does anybody know if it should be working ?
G.C.
How to parallelise processing ?
Hi,
Thanks for your reply.
You are right, I would like to parallelise processing. But the only sample with parallel stuff is adhoc.xml and I more or less copied the config of it.
How can I find an example of parallelisation processing ?
Should I wait for m4 for that ?
G. C.
Example for Parallel Processing
Hi Gerard,
did you get the parallel processing working? Can you give an example here with xml snippets?
regards,
Ramkumar