views:

357

answers:

3

Hosting an application on a web application server e.g. JBoss automatically brings in lots of app server specific functionalities with it e.g. security, clustering & load balancing etc. I have a situation where I have to develop a server app with which, legacy apps can talk to over TCP/IP socket as well as be highly available. Initially, I had though of using JBoss app server to leverage its clustering support for HA. However, I am not sure whether it would be possible to connect to a JBoss web app using pure TCP/IP sockets from both java and non-java apps. What is the best way to achieve this without using web service or Http approach?

UPDATE: I am specially interested to know how legacy apps will connect to the hosted web app through TCP/IP socket.

A: 

I would implement a very simple http (1.0) client.

Maurice Perry
The question says 'without an Http approach' :-)
Brian Agnew
I know, but it's still the simplest way to go
Maurice Perry
+1  A: 

There's no reason why you can't open up a normal socket in (say) a servlet application hosted in JBoss.

You can then get a byte stream from this. The headache is then to decide on a platform-independent representation of your messages, such that your client end can format and send such that the JBoss-hosted end can read. But it's all perfectly feasible.

Brian Agnew
hbagchi
I wrote a simple servlet that reads from the request inputstream and prints it. Dropped the servlet into the ROOT context of Tomcat. Wrote a java client which opens a socket to the localhost @ 80. While the client is actually connecting to the tomcat server at port 80, the servlet receives no input from the client. Looks like Tomcat is eating up the message. Is there a specific configuration I have to do in Tomcat?
hbagchi
+1  A: 

A really simple solution to bridge the two worlds would be to add a simple Java server which maps the old TCP/IP requests to HTTP requests. This is probably a pretty braindead task, so this "server" will be simple to write and maintain. Also, this server won't need as much power since it just accepts and forwards connections (no business logic or DB code).

On the JBoss server, you develop like you normally would. The legacy apps connect to the little bridge server which passes the requests on to JBoss and translate the result back.

This ensures that you're building for the future: When new apps are developed, they can connect directly to JBoss and use all the great HTTP features.

Aaron Digulla
HA requirements will now shift to the bridge server. So, the bridge server had to be fault tolerant now. right!
hbagchi