use of io.vertx.proton.streams.impl.ProtonPublisherWrapperImpl in project vertx-proton by vert-x3.
the class MessagePublisherVerificationTckTest method createPublisher.
@Override
public Publisher<Message> createPublisher(long elements) {
int actualPort = server.actualPort();
ProtonClient client = ProtonClient.create(vertx);
AtomicReference<Publisher<Message>> ref = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
client.connect("localhost", actualPort, result -> {
if (result.succeeded()) {
ProtonConnection conn = result.result();
conn.open();
ProtonPublisher<Message> stream = ProtonStreams.createConsumer(conn, testName);
((ProtonPublisherWrapperImpl) stream).setEmitOnConnectionEnd(false);
ref.set(stream);
} else {
LOG.error("Connection failed");
}
latch.countDown();
});
try {
LOG.trace("Awaiting connection");
boolean res = latch.await(2, TimeUnit.SECONDS);
LOG.trace("Client connected: " + res);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted while creating publisher", e);
}
return ref.get();
}
Aggregations