Building Transactional Classes


EJB programming & troubleshooting: Building Transactional Classes

  1. Building Transactional Classes (2 messages)


    I just wanted to know if anyone new how to make an object transactional. For example if I wanted to write a sequence of three strings to a file and if any of them failed the whole lot would be rolled back.

     UserTransaction tx = getUserTransaction();
       MyTransFileWriter mtf = new MyTransFileWriter();

    }catch(Exception e){

    Any resources on this would be appreciated.

  2. Building Transactional Classes[ Go to top ]

    To put Three String in a file, if your Strings are smaller than the Stream's BufferSize, then changes will affect after calling the close method of the Stream. Otherwise you can read the file after writing your Strings and if you found some of them has failed, then you can remove others from the file.
  3. Building Transactional Classes[ Go to top ]


    Have you considered using a Distributed Caching product in your architecture? Products such as GemFire give you:

    1. Transactional Semantics accross multiple updates into the cache. These could easily be the String objects in your example below.

    2. Fast file persistence or redundant memory-copies (or both), including the handling of rollbacks if some component of the transaction fails.

    Finally, if you ever want to switch the persistence method from a file to a database, you would simply implement a CacheWriter callback with the necessary logic and without the need for any changes the business logic code.


    GemFire-The Enterprise Data Fabric