use of io.vertx.proton.streams.impl.ProtonPublisherImpl in project vertx-proton by vert-x3.
the class DeliveryPublisherVerificationTckTest method createPublisher.
@Override
public Publisher<Delivery> createPublisher(long elements) {
int actualPort = server.actualPort();
ProtonClient client = ProtonClient.create(vertx);
AtomicReference<Publisher<Delivery>> ref = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
client.connect("localhost", actualPort, result -> {
if (result.succeeded()) {
ProtonConnection conn = result.result();
conn.open();
ProtonPublisher<Delivery> stream = ProtonStreams.createDeliveryConsumer(conn, testName);
((ProtonPublisherImpl) 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