Difference between JMS and Web Service

SyAu picture SyAu · Sep 2, 2010 · Viewed 38k times · Source

I need to develop a system which accepts orders and returns confirmation. Orders could come from java or non java clients.

Not sure whether to go for web service implementation or JMS.

Any suggestions ...

Answer

Peter Tillemans picture Peter Tillemans · Sep 2, 2010

JMS is an API which abstracts messaging middleware, like ActiveMQ or IBM MQSeries.

Messaging middleware has a store-and-forward paradigm and asynchronous message passing, while web services tend to promote a synchronous procedure calling paradigm. In distributed systems where a lot can go wrong, dealing with things asynchronously tend to focus the mind better to the things you need to do when part of the system is not available or poorly performing and the code needed to deal with that tends to be a lot less complicated.

Clustering parts become trivial if you have multiple servers listening on the same queue, parallelism and load balancing is for free in this case.

Personally I find JMS much easier to work with and more robust and reliable than web services, but the messaging middleware must support all platforms you want to use. If all the components who need to talk to each other are under your control, I would give a messaging middleware with a JMS interface serious consideration.

If the other party is external then probably Web Services rule, and in that case you could think of a using thin layer to convert the external web service to an internal message passing infrastructure so you still have the most of the advantages.

If it is "just slapping an remote API on a webapp" then of course it does not pay either to setup asynch messaging.