Writing a Java EE User-Interaction Application - java

I want to add the feature to my Java EE 6-Web-Application (JSF 2.0/EJB 3.1/Hibernate with MySQLDB) that registered users can write messages to each other (e.g. like writing a message on Facebook). I googled around but didn't find a good example. So my question is:
How would you design such a feature?
1) Writing Entity Object with the message to the DB?
2) Using JMS? But wouldn't that be transient?
3) Totally different?
Would be pleased with any kind of input (links, suggestions).

i searched about that before...
if you want to make simple messaging between them, build your own one using database relations
but if you want complex one, so this would a lot of work
-- many people suggest JMS if you want a professional work
but i also recommend Apache ActiveMQ
see the link to Apache ActiveMQ

Facebook uses MQTT (https://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920) ... But they cover mobile platforms also ... You can consider using that.
If you are just targeting at taking inputs from browsers and displaying the messages received on refreshing a page, you can go with database approach.
JMS will work for you, but you need a JMS provider for that.

Related

How can I connect an android with a local server?

sorry if my english isn't perfect.
I'm trying to make an app and I need to exchange information between more devices.
I thought that could be a solution connect the devices on a server but I really don't have the idea where start.
What language I need to study to make this? There is a better solution?
This highly depends on what you are trying to achieve in the first place. It would be helpful if you could tell what you are trying to do, but I will still outline some general aspects:
You need to decide, what information is going to be exchanged and how this should happen
What information: Figure out, what exactly needs to be sent and received. Generic text messages? Images? Byte Streams?
How should this be done: Generally spoken, there are two approaches of getting information as a client: Polling and subscribing.
Polling: This approach means to periodically check an endpoint for new data. For example, HTTP uses this way: A web browser or any other client (REST-Client for example) periodically requests information from a HTTP-Server, using a connection just for this single request.
Subscribing / Sync / Notification: In some way or another, the client tells the server that it is interested in the information and wants to get notified when there is something new. The connection is initiated at the beginning and held open for further usage. The benefit of this approach is that changes are received immediately, but on the other hand a permanent connection needs to be maintained.
Things to study
At the beginning, get a good understanding of the TCP/IP Protocol, how Sockets work, how common Protocols do their job (e.g. HTTP, WebSockets)
Take a look at specific Protocols working on top of the basic ones
Tip: REST: Most common WebServices Protocol, providing a common way to exchange stateless data. Uses Polling.
WebSockets: Socket connection using Web Browsers. Commonly used to update information without needing to poll.
There is no specific language to learn for connections. It's more about understanding what the difficulties are and what ways have been invented to address this. Once you get to this point and know what you want to do, it's possible in every language.
Recommendation: As you seem to use Java/Android, I would try to use REST. A really great client-side library for REST on Android is Retrofit. For the server side use what fits for you .. common Java way would be to use Jersey, but you are free to choose from a lot of choices. If using Jersey is too hard for the beginning, maybe take a look at the JS/NodeJS world, those guys invented Express, which allows you to create a REST service out of just a database, wihtout having to code a lot.
First you need to decide if you want to go for an Android or an iOS application. There are other various mobile operating systems as well, but these are widely used . If you want to go for android which is most widely used in my opinion, then you need to learn Java. If you want to go for iOS application, then you need to learn swift or objectiveC. These languages provide the API to connect with various types of services such as Facebook, Firebase and Amazon etc. If you want to connect to some other local server who’s IP is known to you, then you can use socket programming to send messages.
There could be many ways you can implement this. One way will be using Web services. Of course REST might be a better option, if you follow this approach. You can implement Your service(server side code) with any language. I will recommend you use java since you are already using android.
Aside from this You might need to go through the basics of REST, its specifications and
some reference implementations for language of your preference.

(Java) Real time web application

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.

Recommended way to store chat history for a webapp

I'm implementing a web based chat client using Openfire API with Java.
Things are setup and running smoothly, however, I'm a little confused as to where to store chat history.
From what I've observed, Desktop based clients typically store chat history on the client side filesystem using formats such as xml, txt etc.
On the server side, I have the following options:
Using plain text file
Using json (mongodb, hbase etc)
Using database
But I would like to know which is the best of the above options (or any other ones if you can suggest) in terms of speed and performance.
Thanks.
As mentioned in isnot2bad's comment, you can add server-side message archiving through the use of the Openfire Monitoring Plugin. Once you have that setup you can try using the XEP-0126 to fetch archived 1-to-1 chat messages over XMPP.
Openfire Plugins
Unfortunately I have had nothing but trouble when trying to get messages out of the archive using the stanza's defined in XEP-0136. If you look around the OF support forum you will find other people are also running into problems with this plugin. For example, the plugin will not return the list of conversations in correct order, it will not filter the list of conversations or messages by the date specified by the start attribute, etc. To say the least, the plugin could use some work. As a work around, I've left the plugin in place to take care of inserting the messages into the database, but I've written a custom AJAX solution for the retrieval of the archived messages. I just pull them directly out of OF's database and return them in a JSON object to my client side javascript.
XEP-0136 is due for replacement, it's always been overly complicated. XEP-0313 seeks to replace it, but I haven't found any implementations for OF. Good luck.

Embeddable messaging component for Java web application

In order to satisfy customer requirements, we will need to let users exchange information among each other. The 'messaging system' does not have sophisticated back-end requirements and could be easily implemented with a few tables to store messages and message types.
The problem is that I believe that the requirements on the front-end are very high and usability is very important. In addition I expect this communication's part to become an important part of the system in the long run.
Is there anything that can be directly integrated into a Java web application and adapted to the application's design? What we need is the following interface
From service layer:
send message to user (header, subject)
reply to a message
notification on new message in user inbox (if possible: on current page)
interface to existing user management
Preferably, the component should already have a front-end with the following functionality:
message management (select, remove, reply, delete/restore, ...)
folders: inbox, sent, trash
tagging: message categories
show last x messages in a panel/div
styling to look like the application
If there is something reasonably stable, I would prefer using a component before implementing something like this into the application. The application runs on Wicket, but we are not tied to this framework for the messaging component.
Thank you,
Kariem
In portal servers, you have the flexibility to add portlets that could do something similar to the component I am looking for; e.g. Liferay provides mail and message boards portlets.
As akf points out in a comment Jabber provides a solid basis for messaging. We are looking for something that can be integrated into a web application. If we have to build a lot of UI around Jabber, we cannot really consider it a good fit for our requirements.
Ok, it may be a bit surprising but what about giving the Google Wave a try ?
If I review your criteria :
Is there anything that can be directly
integrated into a Java web application
and adapted to the application's
design [...]
It can be as you will discover on this mini-tutorial : http://blog.zenika.com/index.php?post/2010/01/27/Google-Wave-Embedded-API-the-missing-tutorial (how interesting isn't it ?)
From service layer:
send message to user (header, subject)
reply to a message
notification on new message in user inbox (if possible: on current page)
interface to existing user management
Everything but the last point is offered by the Google Wave instance. The last point may be a bit harder to solve as you will require that all of your user have a googlewave account. Managing those accounts may become available through Google Apps, but atm it's not feasible. If it's absolutely mandatory you could plan to have your own instance since it is an open protocol but your goal was to have something already done for you, right ?
Preferably, the component should
already have a front-end with the
following functionality:
message management (select, remove, reply, delete/restore, ...)
folders: inbox, sent, trash
tagging: message categories
show last x messages in a panel/div
styling to look like the application
Great, all of this is ok with the Wave.
If there is something reasonably
stable, I would prefer using a
component before implementing
something like this into the
application. The application runs on
Wicket, but we are not tied to this
framework for the messaging component.
Ok Wicket is so trendy, you should love this solution :-)
I acknowledge that is a bit 'avant-gardiste', I have never done such a thing myself but thought it could have broaden your vision as regard to your problem...
If you are looking for opensource java email clients:
http://java-source.net/open-source/mail-clients
You may also want to have a look at Google Wave . With this you will have next generation communication and collboration tool. Please see some awesome videos about google wave on www.youtube.com
http://code.google.com/apis/wave/
http://code.google.com/p/wave-protocol/wiki/Installation
.
Updated solution... Web based email clients
http://java-source.net/open-source/web-mail
http://code.google.com/p/cubusmail/
http://www.zimbra.com/downloads/os-downloads.html
I think a web-based IM client like SparkWeb can be useful in your scenario.
Using XMPP protocol for messaging is recommended because you can easily federate your server with other chat servers, such as GTalk and Jabber.
If you intend to embed the messaging server into your application, Tigase is a fast and reliable Java XMPP server which can be easily integrated because of being lightweight and having no third-party dependencies. It also scales to hundreds of thousands of users almost seamlessly.
For the client, you can use many available web-based XMPP clients such as emite which is a GWT-based web client that is both beautiful and AJAX.

Looking for easy Instant Messaging protocol for own IM-server/service in in Java

I am thinking of implementing an easy Instant Messaging server in Java, but I don't want to create yet another protocol, but instead use an already simple IM-protocol. But I don't know which protocol I should use.
The reason Why I want to use an already existing IM-protocol, is that I would like my 'users' to be able to use their own clients, for example pidgin - which already offers a wide spread of protocols, such as XMPP, Simple, Bonjour, etc - and I don't have to develop any clients.
I have looked a bit a XMPP but it since a lot of work embed that protocol into a new server. Maybe there are other protocols that are easier to use?
My questions is, do you guys have any suggestions of protocols that are real basic and easy to use in Java? Pidgin supports a whole bunch of protocols, but which protocols are relevant for me?
XMPP is widely used and has standards backing behind it. It is pretty easy to use if you use an existing library - there are many client libraries for it in many languages. The google says there are many in java.
An advantage of using XMPP is that your server can act as a gateway to all the other Xmpp/Jabber servers on the net, so your users can talk in & out of your network - like to people logged into GoogleTalk, using standard JID addresses, like bob#yourhost.com/desktop.
For the widest support I would go with XMPP/Jabber. There's no other choice really.
According to this thread, it seems like a pain to develop an XMPP-server in Java:
Good XMPP Java Libraries for server side?
Even one comment stated that its better of using an existing server instead of creating one from scratch with a library.

Categories

Resources