Long-term request processing with DropWizard

I have a simple DropWizard service, and I would like the REST API to run a long-term processing task - both with the CPU and with the I / O interface. A REST call will not wait for the task to complete, notification will occur by polling / long polling / web socket.

Currently, I would prefer if I can do this in Dropwizard and save everything in one deployable JAR. What are my options?

UPDATE: I am interested in what my options are for launching long running tasks in Dropwizard, deployed as a single banner without external dependencies. Just create a new thread? Assuming that only a few such queries are likely to work, but there should be better options.

+5
source share
1 answer

You probably want to use a managed resource:

https://dropwizard.io/en/stable/manual/core.html#managed-objects

configure thread pool. Then your initial request can send a message to the queue. Your thread pool can retrieve messages from the queue and process them asynchronously.

Perhaps you could provide an additional endpoint so that clients can get the current status of the asynchronous process.

+13
source

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


All Articles