1

If I push a Runnable to a redisson distributed executor service, what rules am I required to oblige by?

Surely , I can not have free reign, I do not see how that is possible, yet, it is not mention in the docs at all, nor are any rules apparently enforced by the API, like R extends Serializable or similar.

If I pass this runnable:

new Runnable(()-> {
    // What can I access here, and have it be recreated in whatever server instance picks it up later for execution? 


    // newlyCreatedInstanceCreatedJustBeforeThisRunnableWasCreated.isAccissible(); // ?

    // newlyComplexInstanceSuchAsADatabaseDriverThatisAccessedHere.isAccissible(); // ?

    // transactionalHibernateEntityContainingStaticReferencesToComplexObjects....
   
    // I think you get the point. 

    // Does Redisson serialize everything within this scope? 

    // When it is recreated later, surely, I can not have access to those exact objects, unless they run on the same server, right? 

    // If the server goes does and up, or another server executes this runnable, then what happens? 

    // What rules do we have to abide by here?

})

Also, what rules do we have to abide by when pushing something to a RQueue, RBlockingDequeu, or Redisson live objects?

It is not clear from the docs.

Also, would be great if a link to a single site documentation site could be provided. The one here requires a lot of clickin and navigation:

https://github.com/redisson/redisson/wiki/Table-of-Content

mjs
  • 21,431
  • 31
  • 118
  • 200

2 Answers2

2

https://github.com/redisson/redisson/wiki/9.-distributed-services#933-distributed-executor-service-tasks

You can have an access to RedisClient and taskId. Full state of task object will be serialized.

TaskRetry setting applied to each task. If task isn't executed after 5 minutes since the moment of start then it will requeued.

Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71
  • Yes, thanks. A bit risky though since there are no easy ways to discover potential errors. I think i prefer to push a message and consume it and know my lambda / execution is as is. I will continue on your RStream answer on the other. – mjs Aug 25 '20 at 12:09
  • The documentation still feels quite incomplete. What happens when two of my services try and schedule the same exact task? What happens when my two services go down and come back up? How do you cancel tasks if you are no the one that started them? What happens when the executing node does not have the references required in the task? – Sovietaced Oct 23 '20 at 18:40
  • @Sovietaced Behaviour is the same as for java ExecutorService. To cancel task use RExecutorService.cancelTask() method. ClassNotFoundException arise if some reference classes are not found. – Nikita Koksharov Oct 24 '20 at 05:29
0

I agree that the documentation is lacking some "under the hood" explanations.

I was able to execute db reads and inserts through the Callable/runnable that was submitted to the remote ExecutorService.

I configured a single Redis on a remote VM, the database and the app running locally on my laptop. The tasks were executed without any errors.

Anouar
  • 42
  • 1
  • 13