简体   繁体   中英

Oracle Coherence: How to set the timeout on an invoke call in a replicated cache?

I have a replicated cache running on a number of weblogic nodes which are also running OSB. The cache is started with the server as a startup class. It has a very simple cache of objects that simply track whether they are in use or not with a boolean attribute "available".

From OSB I am making java callouts to the same class, which call "invoke" on the cache with a processor that marks the object as unavailable and then runs Thread.sleep(31000). This is a placeholder for some lengthy processing I want to add later.

What I want to happen, is if the invoke() call takes too long, the process should time out and return or throw an exception. So I have been trying to configure a request timeout of 30000 milliseconds to test this. Unfortunately I cannot figure out how to make this timeout happen.

I have tried:

  • Wrapping the processor in a PriorityProcessor and calling setRequestTimeout(30000) before invoke()

  • Adding <request-timeout >30000 </request-timeout > to the <replicated-scheme/ > element in the cache config

  • Adding <tasktimeout >30000 </tasktimeout > to the <replicated-scheme/ > element in the cache config

  • Adding <guardian-timeout >30000 </guardian-timeout > to the <replicated-scheme/ > element in the cache config

  • Creating a tangosol-coherence-override.xml and adding a guardian-timeout <init-param > to a <service > element who's "type" matches the service "name" in the cache config

  • Changing the sleep() call to Thread.sleep(310000) just to see if any out-of-box default will kick in after 5 minutes.

None of these result in any kind of timeout, the processor simply sleeps for however long I told it to and then returns with no error.

Has anyone done something similar before and can give me some advice? It would be very much appreciated.

Thanks

James

OK, so I have the answer, with some help from Tim Middleton .

Basically the replicated cache doesn't support timeouts, and it turns out that it wasn't an appropriate choice for my system anyway!

The solution is:

  1. Switch to a <distributed-cache > scheme in the cache config.
  2. Add a <thread-count > element to the scheme with a number > 1 (I chose 10 but it's just however many concurrent instances you want to support).
  3. Use a PriorityProcessor to wrap the EntryProcessor and set the timeout with setRequestTimeoutMillis() before calling invoke(). (Note this is the first thing I tried, but with the wrong kind of cache as it turns out)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM