New to JEE; architecture suggestions for a service/daemon?
- by Kate
I am brand new to the JEE world. As an exercise to try and familiarize myself with JEE, I'm trying to create a tiered web-app, but I'm getting a little stuck on what the best way is to spin up a service in the background that does work.
Parameters of the service:
It must open and hold a socket connection and receive information from the connected server.
There is a 1-to-1 correlation between a user and a new socket connection.
So the idea is the user presses a button on the web-page, and somewhere on the server a socket connection is opened. For the remainder of the users session (or until the user presses some sort of disconnect button) the socket remains open and pushes received information to some sort of centralized store that servlets can query and return to the user via AJAX.
Is there a JEE type way to handle this situation? Naturally what I would think to do is to just write a Java application that listens on a port that the servlets can connect to and spawns new threads that open these sockets, but that seems very ad-hoc to me.
(PS: I am also new to Stack Overflow, so forgive me if it takes me some time to figure the site out!)