Hi Evaristo,

We had a discussion with the devs, and they came up with a couple of 
suggestions like using Functions or CacheListeners/CacheWriters

  *   You can create a CacheListener/CacheWriter to a region, so that when the 
region is created the initialize method is called in the Listener
Eg: In the cache.xml

<initializer>
  <class-name>TestInitializer</class-name>
</initializer>

Create an empty CacheListener/CacheWriter to the region that implements a 
Declarable with an initialize method (TestInitializer )

public class TestInitializer implements Declarable {

  public void init(Properties properties) {
    System.out.println("TestInitializer.init invoked");
  }
}

This CacheListener can be removed at a later point in time with the region's 
AttributedMutator removeCacheListener method call.

Please do let us know if you want any more details, or can share with us what 
you want that scheduled code to do, perhaps more resources can be saved using 
event listeners.


Regards
Nabarun Nag
________________________________
From: evaristo.camar...@yahoo.es <evaristo.camar...@yahoo.es>
Sent: Wednesday, March 9, 2022 11:39 PM
To: user@geode.apache.org <user@geode.apache.org>
Subject: SCHEDULE CODE EXECUTION IN GEODE SERVERS

Hi there,

Is it possible to run in Geode periodically scheduled code (e.g. server 
function) without the need to perform a remote call from a Geode client.

I am looking for something like scheduledFunction.

Currently I only the change to start a thread (or executor that periodically 
executes my code), BUT I see things that are not convenient:
- How to stop that thread? It can be a daemon thread, BUT for instance when 
running testing then that thread keeps going...
- It is a resource waste because ideally this scheduled execution could be 
using regular thread pools

Thanks in advance,

/Evaristo

Reply via email to