Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

How to properly work with thransactions on a thread executor?

Hi I have something like this:

@Notify(fifo = true)
@NotifyType(write = true, update = true)    
class MyClass {
   private GigaSpace space;
   private final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
   public void processEvent(final MyEvent event){
       Task task = new Task()
       executor.schedule(task, 100, TimeUnit.SECONDS)

   private final class Task {
       public void run(){

How you properly work with the space inside the run() method in transactional manner? Thanks, Luke

asked 2014-04-30 02:46:29 -0500

lukeh gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Any reason why you start a new thread within the processEvent method? It is triggered via a dedicated thread (notify thread). Is your task is a long running one? That's the only reason why you should place your logic into a different thread as it will release the notify thread.

Any way - you can start a transaction manually: http://docs.gigaspaces.com/xap97/tran...

Get the PlatformTransactionManager once.


answered 2014-04-30 08:07:41 -0500

shay hassidim gravatar image
edit flag offensive delete link more


I need to implement sort of a timers. I want to start actual processing of the event at a timestamp coming as a field of it. That timestamp may need to be hours later, other similar events may come meanwhile, but the job within run() is pretty short. Edit: also the timestamp may change and the task canceled and rescheduled in that case on the update event. I tryed using programmatic transaction having this at the beginning of run():

GigaSpace space = new GigaSpaceConfigurer(ijSpace).gigaSpace();
PlatformTransactionManager ptm = new LocalJiniTransactionManager();
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
TransactionStatus status = ptm.getTransaction(definition);

ijSpace obtained from the GigaSpace instance in MyClass or instead of that first line using directly that instance or another anotated on inside Task class. In all the cases it hanged when reaching read/write methods.

EDIT: just noticed the get ptm once. I tested with only one run trough that method so unless I did something else wrong it is once.

lukeh gravatar imagelukeh ( 2014-04-30 08:30:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-04-30 02:46:29 -0500

Seen: 92 times

Last updated: Apr 30 '14