views:

758

answers:

2

I am looking for a good TCP connection library from Java with the following facilities:

1. Retry on failed publishes
2. Multiple connections

Which library have you sucessfully used.

EDIT: Based on the comment changed the question to reflect which type of connection library.

+1  A: 

I'm not sure this really makes sense. You're talking about retrying on failed publishes, yet TCP doesn't have a concept of publishing. Merely message transfer. So you could be publishing, or you could be requesting info.

e.g. HTTP over TCP has the verbs GET/PUT/POST (amongst others). All of these run over TCP. Only two actually write something (PUT/POST). And only PUT is supposed to be idempotent (that is to say, you should be able to the same operation again and again with the same result). If you POSTed repeatedly, I'd expect to republish something and create a new version on the server for every POST.

And the above are only recommendations for how PUT/POST are implemented. I wouldn't want an HTTP library to assume this on my behalf.

So the concept of retrying messages at the TCP layer is mistaken (note that TCP will resend packets etc. making up a message). This is a higher-level function, which may use TCP at a lower level. e.g. I've written my own wrappers around HTTPClient to retry PUTting when my remote server becomes temporarily unavailable or reports an error (I'm not sure a retrying HTTP library exists)

Brian Agnew
GET, HEAD, PUT and DELETE, all these four are idempotent. OPTIONS and TRACE are inherently idempotent. And I believe, only POST is non-idempotent.
Adeel Ansari
That's right. I wasn't as clear as I wanted to be. I wanted to highlight that of PUT and POST, only PUT is idempotent
Brian Agnew
A: 

May be Apache MINA will help you.Have a look .

Jinesh
I've used this as well to build some very sophisticated backend communication channels. It also has a many filters which add capabilities, like keep-alive, compression and encryption.
Mark Renouf
Yes ,MINA can be used to make a very sophisticated server programs which needs to handle many TCP/HTTP connections at a time. Its having well maintained thread pools.You can create a chain of filters in MINA.Its a wonderful library actually
Jinesh