1

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?

4
  • Questions about software design decisions are fine here.
    – user8
    Commented Jan 12, 2012 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
    Commented Jan 12, 2012 at 12:16
  • Hello Thomas. Thanks for response but I have already decided to use JGroups.
    – latusaki
    Commented Jan 13, 2012 at 23:19
  • I find JMS to be a solution from this discussion at <a href="stackoverflow.com/questions/1035949/… Overflow</a>. Commented Jun 24, 2013 at 15:13

3 Answers 3

0

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.

1

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

HTH

1

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 and acknowledge you have read our privacy policy.

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