I had a hard time framing that question. I hope it gets the gist of my idea across.
So just to state a few points before you decide to answer. this is a project I am doing for school and it is my own idea and proposal.I am NOT looking for code. I want to hear ideas to architect a system. This thread is more of a discussion than a simple answer. So any and all input is welcome. I will be developing this application over three months and I am using the internet to brainstorm.
So the system consists of several mobile devices and a controller device. the controller sends questions that each mobile device receives. they answer it; the controller gets to see statistics in real-time on their phone or desktop. the mobile devices can join the controller’s session to be able to interact.
In Java EE, I can store the controller device data in the ServletContext and the mobile device sessions can add themselves to the controller device’s data_space in the ServletContext. This way the controller knows who is logged in and it can retrieve the responses of the other mobiled devices. The problem here is the issue with multi-threading as the ServletContext is not threadsafe and Sessions are all multiple threads. There is also the issue where I think this is a not a good design choice. In fact, I feel this is the most straightforward but wrong design choice to make. I would like to hear possible ideas to architect a system to deal with this kind of communication.
Also, would this problem be best solved by using the database? Would such a database centered approach affect the speed of the application? also, am I right in thinking that the database will have no problem dealing with multiple threads since it is a serial pipeline. Database in question MySQL. I am thinking of creating a unique VIEW that will be alive for the lifetime of the controller’s session. the mobile devices can get the controller’s unique VIEW by checking with the ServletContext and then adding themselves to the View and manipulating data in there. Is this a decent approach to the problem?
thanks for looking. 🙂
Good discussion.
I think that the best solution is to use a database. You should use the MVC Model View Controller pattern. In this case mobile devices will be clients which comunicates with a controller (Java EE servlet) through an http connection.
The servlet will handle the database. If a database is hosted in the same server that a Java EE application is deployed, your speed will be very good.
I don’t really understand what you are you thinking on doing with the VIEW, if you explain me better we could continue the discussion with that point.