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

眉间皱痕 提交于 2019-12-11 06:26:07

问题


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 ?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/20692475/remote-api-objectify-and-the-devserver-dont-like-transactions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!