[jboss-user] [JBoss Cache Users] - Re: What is an invocation, and the related option override?

alllle do-not-reply at jboss.com
Wed Sep 30 14:20:13 EDT 2009


Thanks for the reply.

So if I need to read a node, then write to it, such as:

  |                     tm.begin();
  |                     // force write lock even on read operations
  |                     cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
  |                     
  |                     // read node
  |                     Object value = cache.get(myFqn, "key");
  | 
  |                     // write node
  |                     cache.put(myFqn, "key", "newValue");
  | 
  |                     tm.commit();
  | 

Will the "setForceWriteLock(true)" applied to both cache.get() and cache.put() operations?

It looks like the InvocationContext is a ThreadLocal variable (looking at the CacheInvocationDelegate class), which means it lasts as long as the thread is still active. In other words, once I set the "setForceWriteLock(true)", all future cache related operations in this thread will see this option set to "true". And if a thread pool is used in my application for processing (such as a pool of JMS consumer threads), I won't know which options are set and which aren't.

Is my observation correct?

Thanks,



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

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



More information about the jboss-user mailing list