Skip to main content

different ways to create a robust chat module

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2012-06-11

Hi all, my organisation is working on to develop a contact center which has a chat feature as one of its tabbed screen. My question is what are the various ways to develop a highly scalable and a robust chat module. The application will be used by more than 10,000 live users. Each individual data would be stored and will be available offline as well. One of my colleague suggested me that there are two ways:
1) using socket programming
2) objects manipulation.

I want to know which one is better for our product, would be able to handle users and data, much like a facebook kind of application...

Kindly let me know pros/cons of the above methods and let me know if any other technique is there.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-02-17

You'll struggle to write a chat application without using both of those methods, I fear.

What I think you'll need:

  • sockets - you'll find it very difficult to write a chat system, whether client-server or peer-to-peer without using sockets. I recommend using something like 0MQ, which has pub/sub and other systems built in, but if this is a learning exercise, maybe direct sockets would be better.
  • A database - you said that the chat history needs to be stored offline. The easiest way I can think of doing this is to have a database on a central server, which stores all messages, routing them to the required users. MySQL or PostgreSQL will both do what you need, using Hibernate or another ORM system would be easiest.
  • A decent object model - try to think of the problem in terms of what things will be manipulated. From the brief you gave above, I can think of User and Message, but there will undoubtedly be others. ChatRoom perhaps, or ChatSession, if the chats will be about a topic, or time-limited in some way.

Another thing to consider is standards compliance: there is a protocol called XMPP that is designed for chat systems, that is fairly robust and well documented, and used by Google and Facebook; I suggest you look into using that as your wire protocol. If this is not simply a way of learning Java, and you are considering making it a real product (even if for internal use), I would also consider using a freeware chat server like Openfire, and not developing yet another chat system.