RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About
  •  

    An Even Briefer Look at Distributed Transactions in GigaSpaces

    A couple of weeks ago I posted a quick example and explanation of a GigaSpaces local transaction.  You can find the post here and get the code here.

    In today’s short post I will extend that example to use a distributed transaction.  We’ll do this in two steps: first we’ll break the example; then we’ll fix it.

    As a reminder, a GigaSpaces distributed transaction is any transaction that operates on more than one primary space.  In the example code, our client program executed a local transaction when it wrote two instances of TestClass to a single instance remote space.

    In that example routing was not a concern because we created the space as unpartitioned, and we did not declare a space routing field. Behind the scenes, however, GigaSpaces selected one (the id field) for us.  You can check this on the Space Browser tab by expanding the GSSimpleTranExample space node, clicking on “Classes”, then clicking on “TestClass”.  The name of Routing Filed will appear on the Classes Info tab just above the table showing the fields (only one in our case) in the class.

    Now drop the space using Undeploy Application on the Cluster Runtime tab.  Then recreate it as a partitioned space with two partitions and no backups.  Rerun the client application, and it will fail with this error message:

    Exception in thread “main” org.openspaces.core.TransactionDataAccessException: Invalid operation – local transaction spans over multiple spaces – [GSSimpleTranExample_container2:GSSimpleTranExample, GSSimpleTranExample_container1:GSSimpleTranExample] !
    You might be using hash based load balancing (partitioned schema) while writing data into multiple spaces and not into a single node.
    Please Use Jini Transaction manager with your operations.
    ; nested exception is net.jini.core.transaction.TransactionException: Invalid operation – local transaction spans over multiple spaces – [GSSimpleTranExample_container2:GSSimpleTranExample, GSSimpleTranExample_container1:GSSimpleTranExample] !
    You might be using hash based load balancing (partitioned schema) while writing data into multiple spaces and not into a single node.
    Please Use Jini Transaction manager with your operations.

    The reason is that GigaSpaces attempted to route each of the two writes to  different partitions, which turned our local transaction into a distributed transaction.  Because we configured the application with a local transaction manager, the transaction fails.

    To fix the application we need to specify a distributed transaction manager instead of a local one.  Here’s how:

    Find the line in the Spring application context file, GSSimpleTranExample.xml, in which we specify a transaction manager:

    <!– @page { margin: 2cm } P { margin-bottom: 0.21cm } –><os-core:local-tx-manager id=transactionManager” space=gSSimpleTranExample”/>

    and replace it with a line that looks like this:

    <!– @page { margin: 2cm } P { margin-bottom: 0.21cm } –>

    <os-core:distributed-tx-manager id=“transactionManager” />

    Note that the distributed transaction manager, unlike a local transaction manager, is not associated with a particular space.

    Now run the client application.  This time it should work.  You can confirm the transactional behaviour using the techniques described in the earlier post.

    6 Responses to “An Even Briefer Look at Distributed Transactions in GigaSpaces”

    1. Guy Pardon says:

      Hi,

      Cool article, but the JINI transaction manager only works if you don’t use JDBC or JMS resources underneath.

      AFAIK in those cases you should be configuring the JTA transaction manager, of which http://www.atomikos.com is an example.

      Best

    2. subuta says:

      Hi Guy,

      Thanks for the visit and for the very valuable comment. I think you are exactly right, although I confess to not yet having used GigaSpaces with JDBC/JMS data sources.

      -Dan

    3. Guy Pardon says:

      Dan,

      Thanks, no problem. BTW: some people have asked us to support JINI transactions too, but so far we did not have time to implement this. Who knows, maybe some day;-)

      Personally, I like JINI as an SOA platform, but it’s a shame that there seems to be a lack of support lately. Even though it became an apache project, there is little of a community AFAIK.

      Guy

    4. Brian Aniya says:

      Hi,
      I am wondering what’s happening to the Jini standard–especially with Oracle acquiring Sun.

      My contacts at Oracle are saying that Jini and Javaspace will be axed. What will happen to Gigaspace?

    5. subuta says:

      Hi Brian,

      Thanks for the visit and the compelling question. It would be good to hear what the folks at GigaSpaces have to say about this. I will ping Uri Cohen and ask him to comment.

      -Dan

    6. Nati Shalom says:

      Sun had stopped supporting Jini and JavaSpaces for a long while before the Oracle acquisition so i don’t expect any change on that regard:)

      At GigaSpaces we implemented our own space implementation. We also continue to maintain the discovery aspect of Jini ourselfs so i don’t expect that any of this will have an impact on us and our customers.

      As of our 6.0 release that introduced our new Spring based development framework named OpenSpaces which comes with full source under Apache 2.0. The developer is not even expose to any of that details as we we provide complete abstraction on the way discovery and lookup is done.

      The space as a core concept and Space Based Architecture is going to continue to be core to our product and approach. I actually see an increasing awarness behind space based architecture and different people and organizations such as Twitter and even Google – See some recent blog on that regard:

      JavaSpaces and the Next Big Thing

    Leave a Reply