在应用服务器上动态生成内容以供下载
我使用应用程序服务器(例如 geronimo)来运行一些 EAR/WAR 应用程序。 现在我需要某种数据传输服务,但数据太大,可能不适合通过我的应用程序所基于的JMS/Queue 进行传输。
一种想法是服务生成内容并将其存储在应用服务器的文件系统上。然后客户端可以通过 HTTP 下载来检索内容。
问题是如何将 Java EE MDB Bean 中的内容存储到可通过 HTTP 链接访问的文件系统上。或者有什么替代解决方案?
提前致谢!
I use application server, e.g. geronimo, to run some EAR/WAR applications.
And now I need some kind of data transfer service, but the data is so large that it may not be suitable to be transferred via JMS/Queue which my application bases on.
One idea is that the service generates the content and stores it on the file system of application server. Then the client can retrieve the content with HTTP download.
The question is how can I store something from a Java EE MDB Bean onto file system which is accessible with HTTP link. Or any alternative solution?
thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将数据存储在本地磁盘文件系统上,则基本上有 2 种通过 HTTP 提供数据的方法:
创建一个指向根本地磁盘文件系统位置的额外 webapp 上下文。我不知道如何在 Gernimo 中执行此操作,但例如在 Tomcat 中,只需将以下条目添加到
/conf/server.xml
这样就可以通过 http://example.com/files/whatever.ext 获得它
创建一个获取
FileInputStream 从磁盘并写入它到响应的
OutputStream
以及一组正确的响应标头。然后通过 URL 调用该 servlet,并将文件名作为请求路径或参数。If you store the data on the local disk file system, then there are basically 2 ways to provide it by HTTP:
Create an extra webapp context pointing to the root local disk file system location. I have no idea how to do it in Gernimo, but in Tomcat for example it's a matter of adding the following entry to
/conf/server.xml
This way it's available by http://example.com/files/whatever.ext
Create a servlet which gets a
FileInputStream
from the disk and writes it toOutputStream
of the response, along with a set of proper response headers. Then invoke the servlet by its URL with the filename as request path or parameter.