I'm working on a program where part of it will be working as a chat between different people. I'm trying to figure out the best way to send and receive messages.

A PrintWriter or something similar won't work because the process will stop at the read() method while waiting for a message to be sent to it. I'd like to check to see if there is a new message, and if not, continue the execution.

I've seen some stuff about JMS, but I haven't done enough research to determine if it's up for this job.

Is JMS the best option for this, or is there a better way?

  • Questions about software design decisions are fine here. – user8 Jan 12 '12 at 12:00
  • Can you tell us more about the application? Is it a desktop application or a web application? Peer-to-peer, client-server, or some other architecture? – Thomas Owens Jan 12 '12 at 12:16
  • Hello Thomas. Thanks for response but I have already decided to use JGroups. – latusaki Jan 13 '12 at 23:19
  • I find JMS to be a solution from this discussion at <a href="stackoverflow.com/questions/1035949/… Overflow</a>. – Srikanth Suresh Jun 24 '13 at 15:13

You might want to check Netty.

Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.


You'll want to read up on Java's networking I/O but if you can't use Java 7 then you might want to look into this question/answer



If your project is a web project (like gwt or jsf), you can use reverse ajax to receive the messages in client side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.