I'm starting a team of 2 to develop a chat server (both of us are college students), we made some research and found that netty is the most suitable for this kind of concurrent based app.
we never had any experience in developing server side application in java, this is our first time to tackle this kind of project and I just need the right direction for us to build this server the right way.
Our goal is to build something like, whatsapp, kik messenger, Line or weChat.
The real question is, how to make our netty app scalable? do we need to use redis for data persistent? do we need to use mysql for saving relationship or nosql database like mongodb?
Hope someone could guide us.
You could have a look at the documentation if you don't have done yet:
SecureChat example
Netty User Guide
The scalability is a complex answear. One could think of making your application multi-servers able (horizontal scalability), but then it really depend on how your information/context/session are available/updated...
You could think of course to use some Redis for data persistency.
On database usage, it mainly depends on how your data are and if you need relationship using SQL language or if your application can do it for you (to be clear, do you want the database making for you the join parts in your SQL command, or do you want to use the application doing that?). Also it depends on the amount of data (1 millions, 1 billions, ?) and the amount of connections too.
So all is your choice...
Then you can come back with some issues you've got.
Related
During my studies, I have to make a project connected with programming in Java. I learn Java from a few months and I would like to make something interesting (not an application for bank, library, car renting etc). I'm wondering whether it is possible to create real-time web game/application, where you can type something and your friend on another laptop see this message and can send you response? (using internet/Bluetooth) If yes, what I should look for to find information about this type of applications?
Yes, creating something like this is definitely possible. It really will just depend on exactly how you want to implement this (it sounds like you're still not sure EXACTLY what you want, as your description is vague).
What I mean by that, is what do you want as your medium? Would you like the two users to be on their laptops and communicating through their web browsers? Or would you rather have a standalone application that accomplishes this? If so, what Operating Systems will you support? Will it have a graphical user interface, or will it run on the command line?
Let's assume that you want to develop a standalone Windows application that allows the users to exchange messages. Keep in mind that doing this gracefully would involve users logging into your system with authentication, a fairly sophisticated GUI, and lots of encryption for privacy reasons. That being said, a very basic implementation of this could probably be as follows:
You'd have an app that runs locally on the users machine, and also some sort of database backend that your app communicates with. I'd recommend using a mySQL database hosted by Amazons RDS (Here's a tutorial that got me using Javas JDBC library to work with an Amazon RDS database - https://www.youtube.com/watch?v=2i4t-SL1VsU).
Rather than worry about a GUI, I'd suggest trying to get your prototype working on the command line. Your app could preform the following steps when booting up:
Ask user to input the word send followed by a message to send messages ("SEND %MESSAGE%"), or "RECEIVE" to receive messages.
If "SEND %MESSAGE%" is input, add message to database
if "RECEIVE" is input, query the database for all message entries and output them to the user.
You can see that this would accomplish a very crude version of what you asked for, and the devil is in the details. I'd suggest building something very simple like this, and then adding functionality by tweaking and improving features one at a time.
We've developed a management software specifically to very small businesses. But, unexpectedly, several bigger businesses liked it and started to use it. The problem is that our software works only locally (one store) and the bigger businesses want us to make the software to work online (two or more stores at different places but with the same database).
So, we would like to make our local software to work online, utilizing our already existent JAVA Swing user interface.
We've thought about some solutions but, as it will be a big change, we would like to know what is the best way to proceed.
Important information:
The user interface is JAVA Swing and the database is Postgresql.
We have thousands of customers using our software and they would like to use it online too.
Below are the solutions that we've thought about. Please, let us know if there is a better way.
Solution #1
A single database in internet and all clients connected to it.
Drawbacks:
Every single query would have to access internet.
The source code of the clients would need to have the database password. Then the security would be totally compromised.
Solution #2
All clients would have their own database in internet, with different passwords.
Drawbacks:
Every single query would have to access internet.
Would need thousand of databases.
Difficult to maintain.
Solution #3
A single database in internet, but clients connecting through a web service that validates the customers login data and returns the queries results.
Drawbacks:
Every single query would have to access internet.
The construction of the web service would be a little complex and it would have to return the results in somehow we don't know (maybe simple csv text or xml).
Solution #4
There would exist a single database in the internet for all our customers.
Also, all the clients would have their own database locally, so they could do fast select queries.
Every update query would be firstly sent to a web service that would execute the query at the online database and return if it were successfully done.
Besides that, we would have a mechanism to synchronize the local databases with the online database from time to time.
Drawbacks:
Very complex and difficult to implement.
The synchronize mechanism would require high processing.
Is there a better way? How?
I would go with Solution #3. Build a database-backed service/API, and have the desktop client authenticate itself and use it. I would avoid having a local database as in Solution #4. You cannot rely on your users not to accidentally mess with it somehow and cause synchronization to be lost or corrupted. In addition, having a local database will slow you down when you want to create a different client, for example a mobile app.
If you decide to go with Solution #3, the current de facto standard is JSON-based REST API. Also, you should note that there are many caching techniques that can be used which will reduce the number of queries actually run.
I am working on a web application that uses mongodb as the database. Data is inserted into this db via a Java Application and i want to somehow monitor/understand that the data is inserted from a nodejs application so that i can push some information to the clients via socket.io.
I know this is quite easy when we remove Java part from the equation and carry out the insertion via nodejs. But this is not the case for me; so i need pointers on mongodb - nodejs push kind of a thing..
It would be very nice if the solution remains only with Java, Nodejs and mongodb. But if some other 3rd party framework or technology (like mq) must be included i would be happy to hear that.
I would suggest that you should look for apache kafka connect which provide source connector to keep watch on your mongo db. Confluent
has created mongo connector which provide the above functionality. You can go through the above link for further research. Apache kafka is a messaging queue system.
I'd suggest having the Java App let your front end (node) app know when it has changed something. That leaves the responsibility of knowing what has changed and how with the system making the changes. Watching the DB for changes sounds like a good idea, and will likely work but it's far more likely to cause you issues. Consider:
What data to watch?
What changes do you consider worthy of action?
What happens when you change how your data is updated?
How do you know when a change is atomic?
All these issues are at least mitigated if your front end is simply told what has changed and how, where to get the resource and when it happend.
How you tell your front end is up to you. Simple HTTP calls from Java to your front end is simple, if a little unreliable and unpredictable (load wise). A queue/notification service like Amazon SNS might be a little more robust.
First of all, I'm sorry for a long explanation.
I need to develop a desktop app that will enable users to enter patients lab results for tracking diabetes treatment.
I usually code in php/mysql, but I'm not allowed to use it (my first choice was to use LAMP / XAMPP, but was told not to do so). I was told to use MS Access, as the easiest tool, but since I've never used it before, it gave me a lot of headache. Its wizards are great, but I needed to use data from several tables in my forms, and was simply unable to efficiently do so.
So, here is my question: What sort of db can I use with Java to create such an Application? As I said, I'm most comfortable with PHP/MYSQL combination, but during my studies I also used Java quite a lot. If I could find some sort of 'template' for such an application, I could probably create this easily.
I found this http://netbeans.org/kb/docs/java/gui-db.html using google. How complicated is this?
I need to create this ASAP, since I need to get this App to a team of medical staff, since I need this data to use as datasets for my MSc thesis (related to case based reasoning). I'm really behind schedule here :). And someone will probably break my neck if I don't develop it in a few days and start working on a theoretical part of my thesis.
Thank you in advance.
Okay, this one is near and dear having just been diagnosed as pre-diabetic.
What's not completely clear from your description is if you are keeping a separate database for each instance of the app, or are you sharing the data in one big remote database?
And how much data are you expecting?
If it's just for each instance, then any old database will work; the lightest weight one is actually probably sqlite3, but since you're in a hurry and used to LAMP, mysql will certainly work.
For remote data, go with mysql.
Either way around, there are plenty of ways to connect to the database, most all of them based on JDBC. It seems like you basiucally need two tables: patient, and labs. Patient will be something like <name,dob,ssan,address>, and labs something like <ssan, labtype, value, units>. SSAN would be the key and a record would be something like
123-45-6789|A1C| 6.0|pct glucolated
In that case, I'd just make the tables, have two forms with the data, and don't try for anything too fancy.
Update
Okay, from your comments, yes, either use Derby or just use text files. Do you need any particularly complicated queries? In the Old Days we would just have made something like a CSV file and read it into memory.
Oh, and look into Java Web Start for distributing the app.
You can use Java to connect to a database via JDBC. Check out this tutorial. http://download.oracle.com/javase/tutorial/jdbc/index.html. You can use mySQL as your database. You can also use embedded databases such as derby which don't require an external database application.
Here are 2 tutoriala how to build CRUD application on top of the NetBeans Platform (a Swing-based RCP):
http://platform.netbeans.org/tutorials/nbm-maven-crud.html
http://platform.netbeans.org/tutorials/nbm-crud.html
I've tried searching for similar questions here and I don't think I've found anything that matches what I'm looking for. I would like to know where to start in developing a (most likely) database-driven Java application that could keep track of customers, invoices, and quotes for my dad's auto shop. There will be a couple computers in the shop that will need access to it.
I was thinking of having a server in there to handle the database and let whatever machines need to access it use a client app.
Almost all of my experience is in a LAMP environment but I have been trying to learn as much as I can about Java and feel pretty comfortable playing with it in Netbeans or Eclipse.
I'm not asking anyone to tell me how to make it or anything. I would just like to know where to start learning. Is MySQL a good match with Java or should I use something else? I've been wanting to learn Java and I figured this would be a good project to learn on but everything I read seems to give only bits and pieces of what I want to know.
Java and MySQL work well together. Here are some things I would recommend to get started:
JDBC (Java Database Connector) - use it to connect to MySQL
Swing programming - used to create the GUI front end that users will interact with. While NetBeans has a drag and drop GUI builder interface, actually understanding what's going on under the hood is very important.
GlazedLists is a great project for showing dynamic content in table format, such that you can easily filter, sort, etc. Given you will probably have table views of customers, etc., I would look into this
If I were you I would definitely set the bar a little bit lower and try some easier projects to start with (ones that do not require database connectivity, for instance). Once you're a little more advanced with Java, then I'd start work integrating a MySQL table with your app.
I think that most of the answers to this question will prove useful as a starting point
You'll never find a complete subject list to learn java or any other tecnology, I suggest that you should start by writing down the requirements for the project and start "trying/failing" at what you want to do. Bits and Pieces are a very good way to learn.
You could try building different test applications, to get the feel of java, and slowly start using all parts needed to build your application. Common concepts used in small database-driven Java applications are:
JDBC, a java database connector
A client/server architecture (needed if multiple clients need to keep their data synchronized)
Synchronization
A swing GUI
A learning path that worked for me was:
Build a command-line driven java application
Build a test application with a graphical user interface (GUI).
Build a test application with a client/server architecture, but with only one client
Build a test application with a client/server architecture, connect multiple clients and keep them synchronized.
Build a java application with a JDBC database connector, set up a MySQL server and connect the server in your client/server architecture to it.
You can search for each of the concepts on the internet. It should be easy to find tutorials that will teach you how to use them.
MySQL should work well with Java.
In any case, if you use JDBC (a generic API to access SQL databases, part of the standard Java library), you should be quite independent of what underlying database you are using (apart from vendor-specific SQL extensions).