We have a web application that allows users to upload photos which will then be displayed in a specified page after upload. The upload module places the images inside the exploded war directory, e.g.
webapp-root/uploads/ such that once the image is uploaded, it can be viewed instantly, as in
This was working with one application server, but as it turns out, we were to deploy this app to 2 load-balanced servers. So I coded a quick file-sync module that syncs files between servers using FTP, whenever users upload images. Basically when a user uploads an image on
server1/uploads/, I immediately copy it via FTP to
Edit (added upload process): The upload goes something like this:
At this point, I'm running into problems.
http://mydomain.com uses a hardware load balancer to point to either server1 or server2. If a user uploads an image
test-image.png to server1 (which is then synced to server2), I assume that I can access the image through
http://mydomain.com/uploads/test-image.png regardless of whether the load balancer directs me to server1 or server2.
This isn't the case however. Continuing with the example, an image uploaded when the domain is pointed to server1 can only be viewed when
http://mydomain.com/uploads/test-image.png is redirected to server1, and it appears as a broken link if a second user accesses the same url but the load balancer directs him to server2.
So it seems like JBoss isn't refreshing the second server whenever I FTP-copy an image inside its war directory. Which is kind of weird since if I upload an image to server1, the JBoss instance on that server serves up the image file without any problems.
Any way to manually tell JBoss that "hey, we have a new image file here"?