Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to choose JMS API over UDP socket API or vice versa?

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.

like image 950
fenerfan18 Avatar asked Dec 14 '11 19:12

fenerfan18


1 Answers

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.

like image 95
maerics Avatar answered Oct 12 '22 02:10

maerics