【问题标题】:GAE messaging serviceGAE 消息服务
【发布时间】:2011-02-01 18:27:04
【问题描述】:

假设我希望我的公司服务器与 Google App Engine 进行通信,反之亦然。我知道 GAE 不支持 JMS、RMI 等。这种通信的最佳选择是什么?使用任务队列? (我认为HTTPget()不适合这种通信方式)。

我的公司服务器和 GAE 应用程序都使用 Spring 框架。

【问题讨论】:

    标签: java spring google-app-engine jms rmi


    【解决方案1】:

    XMPP 是一个强大而灵活的消息传递协议,this article 展示了如何在 Java 和 Python 中实现它的 GAE 方面。对于 GAE 之外的 XMPP 实现(Java 和其他),请参阅this SO question

    为了从 GAE 访问位于公司防火墙后面的大量安全数据,Google 建议实施 Secure Data Connector(我特意指的是使用 GAE 进行 SDC 的 Java 教程的 URL)。

    【讨论】:

    • 而且...它已全部删除,链接已损坏。
    【解决方案2】:

    使用多种基于 HTTP 的 RPC 协议中的任何一种:REST、JSONRPC、SOAP 等。

    你说“我认为 http get() 不适合这种通信方式”——为什么不呢?

    【讨论】:

    • @Nick,慢。假设我需要在 1 秒内非常频繁地调用,与 http get 相比,使用 jms 会更好吗?
    • 没有。 RPC over HTTP 没有什么慢的。事实上,它们经过了极大的优化,因为用户对时间非常敏感,并且一直通过 HTTP 获取页面。
    【解决方案3】:

    是的,task queue。它的作用与 JMS 相同。

    您也可以使用Google Cloud Pub/Sub 或任何其他类似服务。

    你要做的基本上是配置一个 WebServlet 并实现 HttpServlet doPost 方法。特别是对于 Google Cloud Pub/Subm,您应该使用 url 模式 /_ah/push-handlers

    这里是接收者 AppEngine 文档中的示例:

    // The Enqueue servlet should be mapped to the "/enqueue" URL.
    // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
    @WebServlet(
        name = "TaskEnque",
        description = "taskqueue: Enqueue a job with a key",
        urlPatterns = "/taskqueues/enqueue"
    )
    public class Enqueue extends HttpServlet {
    
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        String key = request.getParameter("key");
    
        // Add the task to the default queue.
        Queue queue = QueueFactory.getDefaultQueue();
        queue.add(TaskOptions.Builder.withUrl("/worker").param("key", key));
    
        response.sendRedirect("/");
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-11
      • 2019-09-20
      相关资源
      最近更新 更多