开发者

GAE messaging service

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. 开发者_如何学CWhat 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.


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).


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?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜