Announcement Announcement Module
Collapse
No announcement yet.
Problem with overriding transaction settings Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with overriding transaction settings

    Hi all,

    I've got a problem with setting my transaction settings in SpringBatch
    For special components, I want to specify a different transaction (actually, no transaction at all).

    I've writen this :
    Code:
    <aop:config>
       <aop:pointcut id="transactional" expression="execution(* mypackage.batch.*.*(..))" />
       <aop:advisor pointcut-ref="transactional" advice-ref="txAdvice" order="0"/>
    </aop:config>
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
       <tx:attributes>
          <tx:method name="*" propagation="NEVER"/>
       </tx:attributes>
    </tx:advice>
    And what I see in my log is
    Code:
    Adding transactional method[*] with attribute [PROPAGATION_NEVER,ISOLATION_DEFAULT]
    So I guess it take in account my configuration

    But, I still see this
    Code:
    Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT

    I'm new in Spring Batch and in transaction too. So, maybe I'm doing something wrong.
    Could you help please ? Thanks.

  • #2
    I'm using WebLogicJtaTransactionManager as a transactionManger, maybe this has something to do with it ?

    Comment


    • #3
      You can specify the transaction manager and the transaction attributes on the <tasklet/> element of a <step/>.
      Code:
        <step id="step1">
            <tasklet transaction-manager="myTxMgr">
                <chunk reader="itemReader" writer="itemWriter" commit-interval="2"/>
                <transaction-attributes isolation="DEFAULT" propagation="REQUIRED" timeout="30"/>
            </tasklet>
        </step>

      Comment


      • #4
        Yes, I agree. But, actually I'd like to specify different kind of transaction for itemReader, itemProcessor and itemWriter.
        For example, "PROPAGATION_REQUIRED" for code in read() and write()
        and "PROPAGATION_NEVER" for code in readError(), afterRead(). For logging in databe for instance.
        I guess there is a way to do this ?

        Comment


        • #5
          Actually, I'm trying to do what is explained in section 11.1 of the Spring Batch Documentation.
          But it does not work. My aopconfig is not taken in account.

          Please, help !

          Comment


          • #6
            I think by default listeners are in requires new propagation, but I'd have to double check. (It might only be the skip listeners) You should be able to use @Transactional though. Your AOP issues may be pointcut related, its tough to say without seeing the actual config.

            Comment


            • #7
              Hi, I've tried to add the @Transactionnal tag to my method and....it seems to work ! Great !
              I don't understand why it works better than the aop config I've tried but, anyway, it works. That's all I want.
              Thanks a lot for your help !

              Comment


              • #8
                Usually when that happens it's because the pointcut expression is slightly off. It's kind of like a regular expression in that way. (AJDT can help make sure it's actually applying it where you think it is)

                Comment

                Working...
                X