2 Replies Latest reply on Feb 20, 2012 12:58 PM by affandar

    Forcing savepoints during workflow execution

    affandar

      From the documentation it is clear that the process instance state is persisted whenever a wait state is hit which is great but it means that any progress made before a wait state is encountered would be lost. E.g if in a sync service task I inserted some data into a DB (non-transactional maybe) and the engine crashes between this point and the next wait state then on resume this data will get inserted in the DB again. Is there a way to force a savepoint after performing some work within a service activity?

       

      Maybe for every such non-idempotent action I can make the service task async to force a savepoint? Actually I'm not even sure if it would force a savepoint since a parallel branch might start executing when this branch blocks.

       

      Just looking for best practices or recommendations for these crash/recovery scenarios.. any help would be appreciated!

       

      Thanks

        • 1. Re: Forcing savepoints during workflow execution
          melc

          Hello,

          .... if in a sync service task I inserted some data into a DB (non-transactional maybe) and the engine crashes between this point and the next wait state then on resume this data will get inserted in the DB again.

          One way of handling this is to place some logic before saving your data in order to check whether it actually needs to be saved or not.

          For example from your business logic i.e. do i have an entry for this entity with this id already? etc if it is not possible to have it from your logic then use the process instance id i.e. save the pid in a table associated to the specific entry.

           

          However the same problem you mention may happen at any point of your code as long as it does not belong to the same transaction, so having a way to force saving the state is the same as saving it from the process.

           

          Please take a look at the following discussion, it is a little long but i think this issue is discussed quite thorougly,

          https://community.jboss.org/message/649767#649767

           

          thanks

          • 2. Re: Forcing savepoints during workflow execution
            affandar

            Thanks Chris. This info is was what I was looking for.