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!