use of io.vertx.proton.streams.Tracker in project vertx-proton by vert-x3.
the class TrackerSubscriberBlackboxVerificationTckTest method createSubscriber.
@Override
public Subscriber<Tracker> createSubscriber() {
int actualPort = server.actualPort();
ProtonClient client = ProtonClient.create(vertx);
AtomicReference<Subscriber<Tracker>> ref = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
client.connect("localhost", actualPort, result -> {
if (result.succeeded()) {
ProtonConnection conn = result.result();
conn.open();
ProtonSubscriber<Tracker> stream = ProtonStreams.createTrackerProducer(conn, "myAddress");
((ProtonSubscriberImpl) 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 subscriber", e);
}
return ref.get();
}
Aggregations