I have the following problem to solve.
I need to write a java program that:
- reads JSON object j1,j2,...,jn from a web service.
- does some number crunching on each object to come up with j1',j2',...,jn'
- Sends objects j1',j2',...,jn' to a web service.
The computational, space requirements for steps 1,2, and 3 can vary at any given time.
For example:
- The time it takes to process a JSON object at step 2 can vary depending on the contents of the JSON Object.
- The rate of objects being produced by the webservice in step 1 can go up or down with time.
- The consuming web service in step 3 can get backlogged.
To address the above design concerns want to implement the following architecture:
- Read JSON objects from the external webservice and place them on a Q
- An automatically size adjusting worker thread pool that consumes JSON objects from the Q and processes them. After processing them, places the resulting objects on the second Q
- An automatically size adjusting worker thread pool that consumes JSON objects from the second Q to send them to the consuming webservice.
Question:
I am curious if there is framework which I can use to solve this problem?
Notes:
- I can solve this using a range of components like custom Queues, Threadpools using the concurrency package -- however I'm looking for a solution that allows the writing of such a solution.
- This is not going to live inside a container. This will be a Java process where the entry point is public static void main(String args[])
- However if there is a container suited to this paradigm I would like to learn about it.
- I could split this into multiple processes, however I'd like to keep it very simple and in a single process.
Thanks.
Thanks.