我需要为 java 客户端提供一种将文件发送到应用程序服务器中运行的另一个应用程序的方法。我不需要处理该文件,但在收到文件时执行一些操作。
有哪些好的方法来实现这种沟通?
我可以考虑 EJB,但我不确定这是否是最好的选择,因为我不需要内存中的图片,对于 WebServices 也是如此...
另一个选择可能是打开 FTP 服务器,但我想知道是否有是使用 Java 执行此操作的一个很好的替代方案。
有什么发生或建议吗?
谢谢!
I need to give to a java client a way to send files to another application running in an Application Server. I don't need to process the file, but do some actions when the file is received.
What good ways to implement this communication are there?
I can think about EJB, but I'm not sure this to be the best option since i don't need the picture in memory, the same for WebServices...
Another option could be to open an FTP server but I wonder if there is a good alternative to do this with Java.
Any ocurrences or suggestions?
Thanks!
发布评论
评论(3)
您可以将文件上传到 Servlet,例如使用 Apache HTTPClient 的 rel="nofollow">MultiPartEntity要求。
You could upload the file to a Servlet, e.g. using the MultiPartEntity of Apache HTTPClient in a POST request.
我强烈推荐 Netty 文档很棒,实现起来很简单,你可以通过自己的自定义发送任何内容您需要的管道。另外,他们还有预先构建的帮助程序类,用于发送文件并在客户端和服务器上执行一些前/后处理工作。
I strongly recommend Netty The documentation is great, it's simple to implement, and you can send anything through your own custom pipe that you need. Plus they have pre-built helper classes to just send files and do some pre/post processing work on both the client and server.
如果您使用 EJB,那么您就在使用 RMI。您可以尝试使用 RMIIO 来传输数据。我从未使用过它,但它声称可以完全满足您的要求。它已经很老了,但是 RMI 很稳定,所以它应该可以正常工作。
If you use EJBs, you're using RMI. You could try using RMIIO to stream the data. I've never used it, but it claims to do exactly what you want. It's pretty old, but then RMI is stable, so it should work fine.