I need some advice from someone experienced in networking.
I have already created a system designed to monitor some tasks (5-30) that are written in java started by a auomatic scheduler or by operator. These tasks are engaged in systems in the context of banking or insurance.
The system consists of a client class, from a multithread server and from the web application. The tasks will use the client to communicate with the server and the web application does the same to monitor the performance of the tasks registered on the server and the webapp may send to the tasks some commands too, like "stop" or "pause".
task[1-n] <---> Server <---> webapp
Since the web application must be able to send commands to the batch, here lies the problem. I have found 2 solutions:
1) Connectionless; are not kept open connections between the parties, the client periodically sends the status to the server and asks to the server if there are commands for him, the period should be a few seconds, each request opens and then closes a socket connection in a similar way to http protocol.
2) Connectionfull; active connections are maintained between the parties. At this point, the tasks can communicate with the server and the server with the tasks without polling. For example, every time the web application requests the status of a task to the server, he will ask the client who will provide it.
For a moment I adopted the solution 1 and in a simulated test environment, it works fine.
The question is, in terms of employment of resources and flexibility exists a solution between the two definitely better, if so, which one?
If you have some link with specific discussion of the topic this is wellcome.
Thanks, Bye.