并发会话独立的 Java Web 应用程序?

发布于 2024-10-07 05:23:23 字数 535 浏览 0 评论 0原文

是否可以将应用程序部署到 GlassFish 应用服务器,使其行为更像守护进程而不是 Web 应用程序?我想设置某种守护进程应用程序,将请求转发到一次只允许一个连接的 API。

这样我就可以拥有多个 servlet 实例,这些实例可以简单地通过守护进程提交 API 请求,并避免需要多个与 API 的连接。

我对基于 Java 的 Web 应用程序相当陌生,因此我不完全确定要搜索什么,或者 Java-EE 开发工具包中是否提供这种功能。任何帮助表示赞赏!

更新/想法:

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:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上得阳光 2024-10-14 05:23:23

GlassFish v3 支持 EJB 3.1 Singleton Bean:

Singleton Bean 可用于实现“将请求中继到一次仅允许一个连接的 API”的要求。

默认情况下,所有单例方法都是
实现线程安全和事务性。
这意味着所有多线程
对 bean 的访问是序列化的 (...)

(来自 新功能在 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".

By default, all Singleton methods are
made thread-safe and transactional.
This means that all multithreaded
access to the bean is serialized (...)

(from New Features in EJB 3.1 - theserverside.com)

放血 2024-10-14 05:23:23

听起来您想要一个为消息队列提供数据的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文