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

Ask Your Question

How to perform take/takeMultiple operations transactionally from application outside of gigaspace?

We have two parts in our product one which runs as pu on gigaspaces and the other which runs as servlet application. The pu on gigaspace processes large amount of data and at the end of the processing it creates POJO type objects and puts them in on the space. The servlet application have thread/s which perform take/takeMultiple operation on gigaspace at certain interval of time. My question is how do we perform such operations transactionally from an application that is running outside of gigaspace. Untill now our code was using IJSpace interface was performing the operation as below;

import net.jini.core.transaction.Transaction;
import net.jini.core.transaction.TransactionFactory;
import net.jini.core.transaction.server.TransactionManager;
import org.openspaces.core.transaction.manager.DistributedJiniTransactionManager;
import org.openspaces.core.transaction.manager.DistributedJiniTxManagerConfigurer;
public void init(){
    IJSpace ijSpace = (IJSpace) new UrlSpaceConfigurer(spaceurl + "&FIFO&timeout=10000").space();
    TransactionManager _spaceTransactionManager = ((DistributedJiniTransactionManager) new DistributedJiniTxManagerConfigurer().transactionManager()).getTransactionManager();
    Transaction tx = TransactionFactory.create(_spaceTransactionManager, _transactionTimeoutSecs * 1000).transaction;

private void receiveMessage() throws Exception {
    try {
        while(msgsThisTxn < maxMsgPerTxn) {
            PojoObject pojo = null;
            try {
                pojo = (PojoObject) ijSpace.take(new PojoObject(),tx,10000);
            } catch (Exception e) {
                log.error("error occured aborting transaction");
            msgsThisTxn ++;
    } catch (Exception e) {
        log.error("error occured while handling the message. will try to abort transaction again");

This worked as expected i.e. takingmaxMsgPerTxn objects from space in each transaction and committing or rolling back depending upon result of handleMessage() method. But now we are upgrading our code to use gigaspace interface but I do not understand how can I manage transactions in that situation as the take method of gigaspace interface do not take transaction as parameter. Our application already uses PlatformTransactionManager to do other processing in transaction so we are looking to update our code so that the take/takeMultiple operations are handled by spring's platformTransactionManager as-well. Can someone point me in the right direction as to how that can be achieved?

asked 2015-06-23 10:18:03 -0500

Setu Desai gravatar image

updated 2015-06-23 10:22:33 -0500

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted


It's no so different; it's documented here:


You might want to review the whole page, but that section covers how to do it programmatically.

Hope this helps


answered 2015-06-23 11:43:14 -0500

jb gravatar image
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2015-06-23 10:18:03 -0500

Seen: 470 times

Last updated: Jun 23 '15