limit | The maximum number of simultaneous jobs this throttle will allow. |
original | The ExecuutorService to throttle. |
Example 1 | Throttling parallel execution. |
Example 2 | Sharing a throttle. |
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | Yes. |
The maximum number of simultaneous jobs this throttle will allow.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
The ExecuutorService to throttle. This will be automatically set by Oddjob.
Throttling parallel execution.
<oddjob> <job> <parallel id="parallel"> <executorService> <throttle limit="2"/> </executorService> <jobs> <wait name="Wait 1"/> <wait name="Wait 2"/> <wait name="Wait 3"/> <wait name="Wait 4"/> </jobs> </parallel> </job> </oddjob>
Sharing a throttle. The same throttle is shared between to parallel jobs. The total number of jobs executing between both parallels is 2.
<oddjob> <job> <sequential> <jobs> <variables id="vars"> <throttle> <convert> <value> <throttle limit="2"/> </value> </convert> </throttle> </variables> <parallel id="parallel-1"> <executorService> <value value="${vars.throttle.is}"/> </executorService> <jobs> <wait name="Wait 1"/> <wait name="Wait 2"/> </jobs> </parallel> <parallel id="parallel-2"> <executorService> <value value="${vars.throttle.is}"/> </executorService> <jobs> <wait name="Wait 3"/> <wait name="Wait 4"/> </jobs> </parallel> </jobs> </sequential> </job> </oddjob>The throttle type is a factory type and so would provide a new instance each time it's used. To overcome this the throttle is wrapped in a convert convert that creates a single instance.