English 中文(简体)
要求从信息驱动的信使中减缓吉大港山区的服务。
原标题:Call to slow service over HTTP from within message-driven bean (MDB)

I have a message driven bean which serves messages in a following way: 1. It takes data from incoming message. 2. Calls external service via HTTP (literally, sends GET requests using HttpURLConnection), using the data from step 1. No matter how long the call takes - the message MUST NOT be dropped. 3. Uses the outcome from step 2 to persist data (using entity beans).

Rate of incoming messages is: I. Low most of the time: an order of units / tens in a day. II. Sometimes high: order of hundreds in a few minutes.

QUESTION: Having that service in step (2) is relatively slow (20 seconds per request and degrades upon increasing workload), what is the best way to deal with situation II?

WHAT I TRIED: 1. Letting MDB to wait until service is executed, no matter how long it takes. This tends to rollback MDB transactions by timeout and to re-deliver message, increasing workload and making things even worse. 2. Setting timeout for HttpURLConnection gives some guarantees in terms of completion time of MDB onMessage() method, but leaves an open question: how to proceed with timed out messages.

Any ideas are very much appreciated. Thank you!

最佳回答

This is what I ended up with (mostly, this is application server configuration):

  1. Relatively short (comparing to transaction timeout) timeout for HTTP call. The rationale: long-running transactions from my experience tend to have adverse side effects such as threads which are "hung" from app. server point of view, or extra attention to database configuration, etc.
    I chose 80 seconds as timeout value.
  2. Increased up to several minutes re-delivery interval for failed messages.
  3. Careful adjustment of the number of threads which handle messages simultaneously. I balanced this value with throughput of HTTP service.
问题回答

In that case you can just increase a transaction timeout for your message driven beans.





相关问题
How to set response filename without forcing "save as" dialog

I am returning a stream in some response setting the appropriate content-type header. The behavior I m looking for is this: If the browser is able to render content of the given content type then it ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Does HttpWebRequest send 200 OK automatically?

Background: I am implementing Paypal IPN handler. This great article on Paypal states that I am required to send a 200 OK back to Paypal after I read the response. The processing of IPN request is ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

Finding out where curl was redirected

I m using curl to make php send an http request to some website somewhere and have set CURLOPT_FOLLOWLOCATION to 1 so that it follows redirects. How then, can I find out where it was eventually ...

热门标签