Is it a good idea to use sockets to send data between two servers, or should I use something like MQ for moving data.
My questions: are sockets reliable, if I need once only/assured delivery of the data?
Are there any other solutions?
Thanks.
Sockets are an application level API for performing network communication. The reliability of sockets depends on the network protocol that you select when you create the socket. If you select TCP/IP, you will get "reliable" transfer ... up to a limit. If you select UDP/IP you will get "unreliable" transfer.
As stated in other answers, TCP ensures that you don't lose or corrupt data up to a point:
For higher levels of reliability guarantees than TCP/IP provides, you need to implement more sensitive checksumming and guaranteed delivery mechanisms over the top of your application's Socket-based networking layer. Or use a message queuing product that does hard the work for you.
So the answer to your question is that it depends on how you use Sockets, and on what level of reliability your system requires.
Sockets are as reliable as you make your implementation, and based upon the underlying hardware. If you don't want the hassle of making a guaranteed delivery service (under what conditions? 100% is never going to happen), a message queue system is a good bet. The message queue will have implemented all of the persistence, queueing, retries, etc which you would need to implement yourself if you went with standard sockets.
You should probably use an MQ if you need guaranteed delivery no matter what happens (like if the other party goes offline for maintenance) and you don't want to write all the logic yourself. Sockets is what you use to connect to an other party, no matter if that party is the MQ or the final receiver of the message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With