Remote API, Objectify and the DevServer don't like transactions?

454 views Asked by At

I am using objectify 4 to write to the HRD datastore. Everything works fine in unit tests and running the application in devserver or production.

But when I try connect using the REMOTE API to the devserver datastore, an error is thrown when the code starts a XG transaction. While connecting with the Remote API, it seems to think that HRD is not enabled. This is how I connect ...

public static void main(String[] args) {
    RemoteApiOptions options = new RemoteApiOptions().server("localhost", 8888).credentials("foo", "bar");
    //options = options.
    RemoteApiInstaller installer = new RemoteApiInstaller();
    StoredUser storedUser = null;
    try {
        installer.install(options);
        ObjectifyInitializer.register();
        storedUser = new StoredUserDao().loadStoredUser(<KEY>);
        log.info("found user : " + storedUser.getEmail());

        // !!! ERROR !!!
        new SomeOtherDao().doSomeDataManipulationInTransaction();

    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        ObjectifyFilter.complete();
        installer.uninstall();
    }
}

When new SomeOtherDao().doSomeDataManipulationInTransaction() starts a transactions on multiple entity groups I get the error thrown :

transactions on multiple entity groups only allowed in High Replication applications

How can I tell the remote api that this is a HRD environment ?

2

There are 2 answers

1
koma On BEST ANSWER

I had 'unapplied job percentage' set to 0 and transactions using the remote api failed as if the devserver was running with Master/Slave and not HRD. Raising the 'unapplied job percentage' above zero fixed the problem.

enter image description here

1
Deviling Master On

If your application is using the High Replication Datastore, add an explicit s~ prefix (or e~ prefix if your application is located in the European Union) to the app id

For Java version, add this prefix in the application tag in the appengine-web.xml and then deploy the version where you have activated the remote_api servlet

Example

<application>myappid</application>

become

<application>s~myappid</application>

Source: https://developers.google.com/appengine/docs/python/tools/uploadingdata#Python_Setting_up_remote_api