如何将数据从常规无状态 servlet 传递到后端实例?
我从未使用过 Google App Engine 后端,并且由于缺乏示例和详细文档而感到非常困惑。
假设我有一个投票应用程序。我想在常规无状态 GAE servlet 中收集投票,然后将数据传递到常驻的后端实例并由它处理我的数据。如何将数据从常规 servlet 传递到后端 servlet?如何指定哪个 servlet 类是普通 servlet,以及哪个 servlet 应该仅在后端实例中处理?我不明白如何在配置 xml 中将 servlet 分配给后端。
或者如果我有两个后端——B1 类和 B2 类怎么办?我如何在无状态 servlet 代码中选择哪些后端现在处于活动状态?我听说我应该使用 URL Fetch 与后端对话,但是如何呢?我没有找到如何迭代后端实例。
请指教 :)
I've never used Google App Engine backends and I'm very confused by lack of samples and detailed documentation.
Let's say I have a voting app. I want to collect votes in regular stateless GAE servlet and then pass the data to backend instance that is resident and it processes my data. How can I pass data from regular servlet to backend servlet ? How do I assign what servlet class is normal servlet and what servlet should be handled only in backend instance? I don't see how I can assign servlet to backend in config xml.
Or what if I have two backends - class B1 and class B2. How can I choose in code of stateless servlet what backends are active right now? I heard that I should use URL Fetch to talk to backends but how ? I didn't find how I can iterate through backend instances.
Please advise :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该首先阅读有关后端的文档
您有几个选择 - 通过将数据粘贴到内存缓存或数据存储中来间接传递它。或者使用 URLFetch 直接向后端发出请求来传递它(请参阅下面的寻址信息)
后端配置文档解释说您不能这样做(但是),尽管您只能将它们标记为管理员,因此它们不可供公众使用:
“寻址后端”部分包含有关如何连接到特定后端的信息:
当您配置后端时,您可以给它们命名,这些名称将进入上述 url 方案中的 [backend] 插槽。如果您想向第一个可用的 B1 实例发送 http 请求,您可以使用类似 http://B1.ruslansapp.appspot.com/dosomething/
You should start by reading the documentation on backends
You have a few options - pass it indirectly by sticking data in memcache or the datastore. Or pass it directly by using URLFetch to make requests to your backends (see addressing info below)
The doc on Backend Configuration explains that you can't do that (yet), though you can mark them as admin only so they are not available to the public:
The "Addressing Backends" section includes info on how to connect to a specific backend:
When you configure your backends , you give them names, which go into the [backend] slot in the url scheme described above. If you wanted to send a http request to the first available B1 instance, you would use something like http://B1.ruslansapp.appspot.com/dosomething/