use of io.aeron.cluster.client.SessionDecorator in project aeron by real-logic.
the class ClusterTest method shouldEchoMessagesViaService.
@Test(timeout = 10_000)
public void shouldEchoMessagesViaService() throws InterruptedException {
final Aeron aeron = client.context().aeron();
final SessionDecorator sessionDecorator = new SessionDecorator(client.clusterSessionId());
final Publication publication = client.ingressPublication();
final ExpandableArrayBuffer msgBuffer = new ExpandableArrayBuffer();
final long msgCorrelationId = aeron.nextCorrelationId();
msgBuffer.putStringWithoutLengthAscii(0, MSG);
final EchoConsumer consumer = new EchoConsumer(client.egressSubscription());
final Thread thread = new Thread(consumer);
thread.setName("consumer");
thread.setDaemon(true);
thread.start();
for (int i = 0; i < MESSAGE_COUNT; i++) {
while (sessionDecorator.offer(publication, msgCorrelationId, msgBuffer, 0, MSG.length()) < 0) {
TestUtil.checkInterruptedStatus();
Thread.yield();
}
}
latch.await();
for (final EchoService service : echoServices) {
assertThat(service.messageCount(), is(MESSAGE_COUNT));
}
}
Aggregations