Is it possible to replace JMS messaging with a Webservice call?

Existing scenario: two applications exchange messages using queues. One of them is always a producer, and the other is always a consumer.

"Producer" generates and stores data in its own storage. He then sends it to the consumer using queues.

The more I read about implementing a JMS consumer (and listener) (using Spring), it seems we can easily replace Messaging with Polling Webservice calls.

This is because all that JMS listeners support open thread (s) while listening to queues. Therefore, if your JMS ConnectionFactory listener has 10 connections, you will have 10 blocking threads.

So, instead of keeping 10 threads open, why not just poll every 30 seconds or so using 1 thread. This survey may instruct WebService to send 100 data items (or more) in response to a response.

+4
source share
4 answers

Both of them are just abstractions. If you think this is just a socket that you click on data. What is truly different is the guarantees that each abstraction gives. Crazy enough, you really have SOAP web services that are served through JMS and JMS that use HTTP as a transport.

Short JMS defines a set of guarantees related to messaging (confirmation, re-delivery, transfer to another resource, etc.). Web services (as most people think of them) consist mainly of a thin set of specifications describing the message format (SOAP, JSON), superimposed on top of specifications describing the transport (HTTP).

Regarding the survey. Most JMS implementations are push models. Subscribers are registered with the broker, and as messages arrive, they are pushed to subscribers. Push models have higher throughput than traction models.

+4
source

The answer is latency . With JMS, a message is available to the consumer the same second that it was sent. With any survey permission, you will always experience latency in about half the average survey period.

It also consumes more CPU and network because the polling consumer must wake up every second and make the actual call.

Finally, you should think about duplicates and transactions. If you configure JMS correctly, you will receive a message exactly.

+4
source

Well, it totally depends on your requirements. Having a JMS alert has its advantages, such as:

  • non-blocking (asynchronous) messaging
  • high performance and reliable load balancing
  • high throuput
  • fault tolerance (what if the flow at the other end is turned off)

Of course, all this is expensive, so it all depends on what you need. If you have low bandwidth with a few messages per minute, and you can live to lose some messages due to a communication error, you can very well switch to a survey-based web service.

0
source

If you want to implement your own queue service then feel free to. The only major advantage is that you don’t need to rely on the third component (JMS server).

If your resource is associated with 10 additional streams and 10 additional sockets, you really have other problems to worry about using a JMS server above and above. No ads require additional costs.

If you don’t need the queue at all, just call the web service on the line and do it.

If you implement it yourself, you need to implement a queue, persistence and recovery (when your system drops by the 29th second and loses 100 unsent messages), restore transactions, reconnect logic, etc.

If I had to do this for one queue in one place with one manufacturer, and JMS servers cost X thousand dollars a year for license fees, etc., then yes, I would, of course, think about remaking this bit of logic. Or if I do not want to record the memory pressure on the JMS server.

But the JMS servers are free, they come with my application server, they are configured with half a dozen mouse clicks, and they are "fast enough" for most needs. Today it is a ubiquitous infrastructure.

It's just that the chances are really high, it's just not worth the effort to invent this wheel, IMHO.

0
source

Source: https://habr.com/ru/post/1414036/


All Articles