I have a chain that uses a splitter that splits a request into 10 separate threads using a dispatcher/task-executor.
We use Spring Data repositories to retrieve data. While I am able to retrieve data before the splitter splits the request, when querying for data post the split, I get CannotCreateTransactionException.
My pipeline configuration is as follows:Code:Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:382) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
The documentation of executor channel does mention that:"this does break the "single-threaded" execution context between sender and receiver so that any active transaction context will not be shared by the invocation of the handler". So since a new transaction would be needed post the 'requestSplitterChannel' above, we did add @Transactional to processorA and processorB, assuming that would tell Spring to create a new transaction within those threads. But that does not work and gives us the exception mentioned above.Code:<si:chain input-channel="emsValuationServiceIn" output-channel="requestSplitterChannel"> <si:filter ref="requestFilter" method="accept" /> <si:transformer ref="valuationProcessor" /> <si:splitter ref="positionContextSplitter" method="splitRequest" /> </si:chain> <si:channel id="requestSplitterChannel" > <si:dispatcher task-executor="positionRequestTaskExecutor" /> </si:channel> <bean id="positionRequestTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" > <property name="corePoolSize" value="10" /> <property name="daemon" value="false" /> </bean> <si:chain input-channel="requestSplitterChannel" output-channel="aggregatorRequestChannel" > <si:transformer ref="processorA" /> <si:transformer ref="processorB" /> </si:chain>
Is there a way of introducing a new transaction here? Any help would be appreciated.
P.S: I am using Spring Integration 2.0.3.RELEASE.


Reply With Quote
)
