I have a Java Spring Boot app, that has a class @Component, with @SqsListenerreceive
method, listening on AWS SQS queue, pulling in messages and creating Callable tasks using this.executorService.submit(taskResults)
For context:
Callable<Result> resultFuture = new ProcessingTask(various attributes and data sent over)
Then I have a LinkedList of List<Future>, holding my futures on the singleton.
then, every time receive
is invoked, I check the size of the list, if it is more than twice the availableProcessors
, I invoke a helper method that is iterating over the LinkedList, each Future, I check isDone
, if it is, then I do a .get to retrieve results - at this point I implemented catchers for InterruptedException, ExecutionException as well as checking Thread.currentThread.isInterrupted()
on every significant step in the call
method of my ProcessingTask implementation.
I am not sure entirely how to test this complete set of rules, but I started with something simple: Run the app in IDEA, then submit messages into SQS for processing - it picks up everything looks good.
Then I submitted large message to process, and while it is in middle of processing, I hit the red Stop button in IDEA, expecting it to raise Interrupted flag for the threads to gracefully exit - however this did not happen, it kills everything immediately, none of my interrupt code log statements anywhere were called.
So my questions I guess are:
- How to send Interrupt signal while running in IDEA, to test stuff?
- Any references on testing multi processing and interruption logic please?