mock.expectedMessageCount(total);
// setup a task executor to be able send the messages in parallel
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.afterPropertiesSet();
for (int i = 0; i < 5; i++) {
final int threadCount = i;
executor.execute(new Runnable() {
public void run() {
int start = threadCount * 200;