Results 1 to 6 of 6

Thread: <batch:step>: no "transaction-attribute"?

  1. #1
    Join Date
    Feb 2009
    Posts
    11

    Default <batch:step>: no "transaction-attribute"?

    I'm trying to setup a non-transactional tasklet using MethodInvokingTaskletAdapter in a simple definition like this:

    Code:
        <batch:job id="indexUpdater">
            <batch:step id="updateIndexes" tasklet="indexUpdaterTasklet"/>
        </batch:job>
    
      <bean id="indexUpdaterTasklet" class="org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter">
            <property name="targetObject" ref="indexUpdaterService"/>
    
    [...]
    Unfortunately, I cannot directly set the required "transaction-attribute" on a <batch:step>-element. Using <batch:tasklet> is not an option, since I don't have any readers/writers.

    Would the addition of this attribute make sense or is there an other preferred way of achieving this?

    Thanks,
    Yann

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    I've created the following issue to track this: http://jira.springframework.org/browse/BATCH-1131

  3. #3
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    What do you mean by a non-transactional tasklet? I guess you could provide your own implementation of AbstractStep.

  4. #4
    Join Date
    Feb 2009
    Posts
    11

    Default

    Indeed, I figured a solution using plain <bean>-style configuration with TaskletStep and setting transactionAttribute directly.

  5. #5
    Join Date
    Jan 2011
    Posts
    2

    Default

    Quote Originally Posted by yannc76 View Post
    Indeed, I figured a solution using plain <bean>-style configuration with TaskletStep and setting transactionAttribute directly.
    I have the same problem and I solved it injecting a "ResourcelessTransactionManager" to my non-transactional tasklet:

    Code:
    <bean id="resourcelessTransactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
    
    <batch:tasklet ref="myTasklet" start-limit="1" transaction-manager="resourcelessTransactionManager" />
    Last edited by vesperaba; Jul 12th, 2012 at 04:40 AM. Reason: I found a soluction

  6. #6
    Join Date
    Jan 2011
    Posts
    2

    Wink Another way to do it

    I found another way to do it:

    Code:
    <batch:tasklet ref="myTasklet">
        <batch:transaction-attributes propagation="NOT_SUPPORTED" /> 
    </batch:tasklet>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •