What are the reasons that can motivate a programmer to use Java JMS (Java Message Service) API instead of UDP socket API of the java.net package in a distributed Java application or to use UDP socket API instead of JMS API? If possible, please give example applications.
UDP and JMS are different in many ways, and fundamentally since JMS typically relies on the features inherent to TCP (see this comparison of UDP and TCP to get an idea of the differences of the two underlying protocols).
Basically UDP is suitable for applications which do not require any reliability, ordering, congestion control, or routing between networks (since many consumer and commercial grade routers do not forward UDP packets). JMS provides all of these features missing from UDP and more (like transactions, pub/sub and queueing, durable subscriptions, etc).
UDP might be appropriate for streaming large amounts of data within a local area network where absolute quality is not a requirement; JMS would be better for applications requiring reliable messaging between wide area network hosts. Moreover, JMS obscures the details of sockets, servers, binding, etc. and provides a high-level API which is better suited for enterprise integration.
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