Using the dropwizard to process long requests
I have a simple dropwizard service. I want a rest API to start a long-running processing task - including CPU and I / O binding Rest calls do not wait for the task to complete, and notifications occur through polling / long polling / Web sockets
Now, I prefer if I can do this in the dropwizard and save everything in a single deployable jar What choice do I have?
Update: I am interested in the option of running long-running tasks in the dropwizard, which is deployed as a single jar without external dependencies Just generate a new thread? Assuming there are few such requests, it may work, but there should be a better choice
Solution
You may want to use managed resources:
http://www.dropwizard.io/1.0.5/docs/manual/core.html#managed -objects
Set thread pool Your initial request can then push the message to the queue Your thread pool can extract messages from the queue and process them asynchronously
You can provide an additional endpoint so that the client can get the current state of the asynchronous process