Search in sources :

Example 11 with Tracker

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();
}
Also used : Tracker(io.vertx.proton.streams.Tracker) AtomicReference(java.util.concurrent.atomic.AtomicReference) ProtonClient(io.vertx.proton.ProtonClient) CountDownLatch(java.util.concurrent.CountDownLatch) ProtonConnection(io.vertx.proton.ProtonConnection) Subscriber(org.reactivestreams.Subscriber) ProtonSubscriber(io.vertx.proton.streams.ProtonSubscriber) ProtonSubscriberImpl(io.vertx.proton.streams.impl.ProtonSubscriberImpl)

Aggregations

Tracker (io.vertx.proton.streams.Tracker)11 ProtonClient (io.vertx.proton.ProtonClient)9 ProtonConnection (io.vertx.proton.ProtonConnection)9 ProtonSubscriber (io.vertx.proton.streams.ProtonSubscriber)9 Flowable (io.reactivex.Flowable)7 AsyncResult (io.vertx.core.AsyncResult)7 Handler (io.vertx.core.Handler)7 Logger (io.vertx.core.impl.logging.Logger)7 LoggerFactory (io.vertx.core.impl.logging.LoggerFactory)7 Async (io.vertx.ext.unit.Async)7 TestContext (io.vertx.ext.unit.TestContext)7 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)7 FutureHandler (io.vertx.proton.FutureHandler)7 MockServerTestBase (io.vertx.proton.MockServerTestBase)7 ProtonHelper.message (io.vertx.proton.ProtonHelper.message)7 ProtonServer (io.vertx.proton.ProtonServer)7 ProtonStreams (io.vertx.proton.streams.ProtonStreams)7 Arrays (java.util.Arrays)7 ExecutionException (java.util.concurrent.ExecutionException)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7