[jboss-user] [JBoss Cache: Core Edition] - JBosscache dirty read even though isolation is REPEATABLE_RE

vishwasoft do-not-reply at jboss.com
Fri Jun 19 17:09:48 EDT 2009


I'm trying to evaluate the JBossCache for our application
I'm getting dirty read even though I rollback transaction. I tried this with EJB3 Stateless session bean BMT.

Could you please anyone help me on this prolbem, Am I making anything wrong?

Here is the code

public class TestEntity {
    
    private int array[] = new int[100000];
    
    public void update(int value) {
    
        for (int i = 0; i < array.length; i++) {
            array [ i ]=value;
        }
        
    }

    public int[] getArray() {
        return array;
    }
}


Stateless Bean code to update cache

Stateless Bean 1

    public void updateArray(int value) {
        TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
        try {
            tm.begin();
                String key = node.getFqn().toString();
                TestEntity t = (TestEntity) node.get(key);
                if(t != null) {
                    t.update(value);
                    node.put(key, t);
                }
            tm.rollback();
        } catch (Exception e) {
            try {
                tm.rollback();
            }catch(Exception ex1) {
                ex1.printStackTrace();
            }
            e.printStackTrace();
        }
    }

Stateless Bean 2 to read and validating array
    
        public boolean validateArray() {
            TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
            try {
                tm.begin();
                cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
                int a[] = readArray();
                int value = a[0];
                for (int i = 0; i < a.length; i++) {
                    if(a != value) {
                        System.out.println(a+":"+value);
                        sctx.getUserTransaction().rollback();
                        return false;
                    }
                }
                tm.commit();
            }catch(Exception ex) {
                try {
                    tm.rollback();
                }catch(Exception ex1) {
                    ex1.printStackTrace();
                }
                ex.printStackTrace();
            }
            return true;
        }
        
Configuration file:
I have used configuration file example for cache configuration

    

    

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4238848#4238848

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4238848



More information about the jboss-user mailing list