RoundRobinJmsQueueRecordWriter implements RecordWriter<P> { @Override public void writeRecords(Batch<P> batch) throws Exception { for (Record<P> record : batch) { QueueSender queue = queues.get(next++ % queuesNumber); queue.send((Message) record.getPayload()); } } RoundRobinJmsQueueRecordWriter(List<QueueSender> queues); @Override void writeRecords(Batch<P> batch);  }
@Test public void regularRecordsShouldBeDispatchedToQueuesInRoundRobinFashion() throws Exception { roundRobinJmsQueueRecordWriter.writeRecords(new Batch(record1, record2, record3)); InOrder inOrder = Mockito.inOrder(queue1, queue2, record1, record2, record3); inOrder.verify(queue1).send(record1.getPayload()); inOrder.verify(queue2).send(record2.getPayload()); inOrder.verify(queue1).send(record3.getPayload()); }