private void doSend(Message msg, final Class<?> msgCls) throws Exception {
GridIoManager mgr0 = grid(0).context().io();
GridIoManager mgr1 = grid(1).context().io();
String topic = "test-topic";
final CountDownLatch latch = new CountDownLatch(SAMPLE_CNT);
mgr1.addMessageListener(topic, new GridMessageListener() {
@Override public void onMessage(UUID nodeId, Object msg, byte plc) {
if (msgCls.isInstance(msg))
latch.countDown();
}
});
long time = System.nanoTime();
for (int i = 1; i <= SAMPLE_CNT; i++) {
mgr0.sendToCustomTopic(grid(1).localNode(), topic, msg, GridIoPolicy.PUBLIC_POOL);
if (i % 500 == 0)
info("Sent messages count: " + i);
}
assert latch.await(3, SECONDS);
time = System.nanoTime() - time;
info(">>>");
info(">>> send() time (ms): " + MILLISECONDS.convert(time, NANOSECONDS));
info(">>>");
}