Tuesday, August 21, 2012

Forcing TaskRejectedException in Spring

Suppose (for testing purposes) you want to force a TaskRejectedException when using Spring Integration channels. All you have to do is
  • send a reasonable number of objects to the channel (let's say a minimum of 5)
  • configure your queue capacity to .. 0
  • and (important) set the thread-pool size to (as low as you can) 1
I'm using a task executor in this example:

id="someExecutor" keep-alive="120" pool-size="1" queue-capacity="0"








Good luck