开发者

Can JBoss instances communicate?

I've got a Java servlet that handles file uploads, but resides in the "intranet" instance of JBoss. It needs to write files to a directory in the "internet" instance of JBoss (on the same machine). The Java servlet can't be moved to the other instance. This is with JBoss 4.2 on a Solar开发者_开发技巧is box.

Is there a way for this to happen? Can there be a shared folder that both instances can see? Thank you.


If the purpose is to upload files, you can put the files in any common shared directory that both can see (referenced by relative file name, or to a defined location).

If you have potential contention on the files, the way that is usually handled is to write the files to a temporary file name, and rename the file when done. Rename is an atomic operation, unlike writing a file.

I don't see in your question a need for actual communication. For that, EJBs or JMS are the obvious choices in JBoss, but if all you are doing is sharing files, that seems overkill.

EDIT: I'm assuming here that you are writing files using FileOutputStream/FileWriter and the like. In that case, it is a simple case of making a directory or file share that both processes running the respective JBoss instances have rights. If you aren't familiar with Unix file administration and rights, then serverfault.com is the right place to ask about those details.


Thus you want to transfer the file between two machines connected by network. The keyword here is FTP or network drive.

You can use FTP (File Transfer Protocol) for this, its name says it all. You could use Java for this and if you like to, then I recommend Apache Commons Net FTPClient. The target machine has to run a FTP server however. You could use under each FileZilla for this.

Alternatively you can at operating system level map a network drive from the target machine in the source machine and just write the file to it as if it is local.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜