Java patterns for a long process in a web service

I am creating a web service that runs a database process (SQL code to run multiple queries, then moving data between two really large tables). I assume that some processes may take from 2 to 10 hours.

What are the best methods for performing a lengthy process of working with a database from a Java web service (it is actually based on REST using JAX-RS and Spring)? The process will be executed by 1 call of the web service. This is expected to be completed once a week.

Thanks in advance!

+4
source share
2 answers

It must be asynchronous.

Since your web service call is RPC, it is best for the implementation to check the request, put it in the queue for processing, and immediately send a response that has a token or URL to check the progress.

Configure the JMS queue and register a listener that pulls the message out of the queue and saves it.

If it really takes 2-10 hours, I would recommend looking at your circuit and queries to see if you can speed it up. There, somewhere, somewhere, somewhere there is no pointer. I bet you.

+6
source

Where I work, I am currently evaluating different strategies for this exact situation, only the times are different.

Over time, when you announce, you may be better served using the Publish / Subscribe Queue ( ActiveMQ ).

+1
source

All Articles