GAE messaging service

偶尔善良 提交于 2019-12-11 07:27:25

问题


Let's say I want my corporate server to communicate with Google App Engine and vice versa. I know that GAE does not support JMS,RMI etc. What is the best alternative for this kind of communication? Use task queue? (I think HTTP get() is not suitable for this kind of communication).

Both my corporate server and GAE application use Spring framework.


回答1:


XMPP is a powerful and flexible messaging protocol, and this article shows how to do the GAE side of it in both Java and Python. For XMPP implementations (in Java and others) outside of GAE, see this SO question.

For accessing from GAE a lot of bulky secure data that lives behind your corporate firewall, Google recommends implementing the Secure Data Connector (I'm pointing specifically to the URL of the Java tutorial for SDC with GAE).




回答2:


Use any of a number of HTTP based RPC protocols: REST, JSONRPC, SOAP, etc.

You say "I think http get() is not suitable for this kind of communication" - why not?




回答3:


Yes, task queue. It does the same that JMS does.

You can also use Google Cloud Pub/Sub or any other similar service.

What you going to do is basically configure a WebServlet and implement the HttpServlet doPost method. In specific for Google Cloud Pub/Subm you should use the url pattern /_ah/push-handlers

Here the example from the docs of AppEngine for the receiver:

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


来源:https://stackoverflow.com/questions/2533415/gae-messaging-service

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