I am writing simple webapp in Java (for educational purpuses only) which allows admin to manually execute some background maintenance jobs (e.g. execute some process on system via Runtime.exec - its actually irrelevant). Background job ofc runs in its own thread and outputs some info. I am wondering, whats the correct way to pass that output to user via web interface? For example, admin returns after few minutes, and wants to look at output of job he ran. More importantly, how to solve this in a clustered environment, where job runs on single instance, but output viewing happens on another? Is there any known well practices?
I guess, in non-clustered env output buffer in memory would be enough. But in clustered env i can only think of db/file store for that output, but thats cumbersome (temporary resources must be removed later etc).
Thanks in advance.
I suggest a database ( although I take your point about it being only a temporary resource ).
Whatever storage medium you use, it'll need to be shared across your application server cluster, and will therefore need to be tidied at some point. A database is no more difficult to perform housekeeping on that anything else.
Also, these "temporary" resources have a habit of becoming permanent over time as the results of the back ground process take on greater significance ( in the eyes of auditors etc ), although that's not likely in your case