-->

Remote API, Objectify and the DevServer don't

2019-10-19 03:18发布

我使用物化4写入HRD数据存储。 一切正常的单元测试和运行devserver或生产中的应用罚款。

但是,当我尝试使用远程API的数据存储devserver连接时,当代码开始交易XG抛出一个错误。 在与远程API连接,它似乎认为HRD未启用。 这就是我如何连接?

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();
    }
}

当新SomeOtherDao()doSomeDataManipulationInTransaction()开始在多个实体组一个交易我抛出的错误:

在多个实体组交易只允许在高复制的应用

我怎么能告诉远程API,这是人力资源开发的环境?

Answer 1:

如果您的应用程序使用高复制数据存储 ,添加一个明确的S〜前缀(或E〜前缀,如果你的应用程序位于欧盟)的应用程序ID

对于Java版本,在应用程序代码中的AppEngine-web.xml中添加这个前缀,然后部署在那里你已经激活了remote_api的servlet的版本

<application>myappid</application>

成为

<application>s~myappid</application>

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



Answer 2:

我有“未核销工作的百分比”使用远程API失败,因为如果devserver与主/从,而不是人力资源开发运行设置为0和交易。 提高零以上的“未核销工作的百分比”解决了这一问题。



文章来源: Remote API, Objectify and the DevServer don't like transactions?