并发会话独立的 Java Web 应用程序?
是否可以将应用程序部署到 GlassFish 应用服务器,使其行为更像守护进程而不是 Web 应用程序?我想设置某种守护进程应用程序,将请求转发到一次只允许一个连接的 API。
这样我就可以拥有多个 servlet 实例,这些实例可以简单地通过守护进程提交 API 请求,并避免需要多个与 API 的连接。
我对基于 Java 的 Web 应用程序相当陌生,因此我不完全确定要搜索什么,或者 Java-EE 开发工具包中是否提供这种功能。任何帮助表示赞赏!
更新/想法:
- 生命周期模块:将守护进程构建为生命周期模块怎么样?根据我收集的信息,我可以根据应用程序服务器的状态有效地管理其行为,这对我来说实际上是有益的: http://docs.sun.com/app/docs/doc/819-3672/beamc?l=en&a=view
Is it possible to deploy an application to a GlassFish app server that would behave more like a daemon than a web app? I'd like to set up some sort of daemon app that would relay requests to an API that only allows for one connection at a time.
This way I could have multiple servlet instances that could simply submit API requests through the daemon and avoid ever needing more than one connection to the API.
I'm fairly new to Java-based web apps, so I'm not entirely certain what to search for, or if this kind of functionality is available in, say, the Java-EE development kit. Any help appreciated!
Updates/Ideas:
- Lifecycle Module: What about building the daemon as a lifecycle module? From what I gather, I could effectively manage its behavior based on the app server's status, which could actually be beneficial in my case: http://docs.sun.com/app/docs/doc/819-3672/beamc?l=en&a=view
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GlassFish v3 支持 EJB 3.1 Singleton Bean:
Singleton Bean 可用于实现“将请求中继到一次仅允许一个连接的 API”的要求。
(来自 新功能在 EJB 3.1 - theserverside.com 中)
GlassFish v3 supports EJB 3.1 Singleton Beans:
A Singleton Bean could be used to implement the requirement "relay requests to an API that only allows for one connection at a time".
(from New Features in EJB 3.1 - theserverside.com)
听起来您想要一个为消息队列提供数据的 servlet。然后,您可以使用一些代码从队列中取出条目并处理它们。查找消息驱动 Bean。
Sounds like you want a servlet that feeds a message queue. Then you can have some code that pulls entries off the queue and processes them. Look up Message-Driven Beans.