Search in sources :

Example 1 with ProtonPublisherImpl

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();
}
Also used : ProtonPublisherImpl(io.vertx.proton.streams.impl.ProtonPublisherImpl) AtomicReference(java.util.concurrent.atomic.AtomicReference) Publisher(org.reactivestreams.Publisher) ProtonPublisher(io.vertx.proton.streams.ProtonPublisher) ProtonClient(io.vertx.proton.ProtonClient) CountDownLatch(java.util.concurrent.CountDownLatch) ProtonConnection(io.vertx.proton.ProtonConnection) Delivery(io.vertx.proton.streams.Delivery)

Aggregations

ProtonClient (io.vertx.proton.ProtonClient)1 ProtonConnection (io.vertx.proton.ProtonConnection)1 Delivery (io.vertx.proton.streams.Delivery)1 ProtonPublisher (io.vertx.proton.streams.ProtonPublisher)1 ProtonPublisherImpl (io.vertx.proton.streams.impl.ProtonPublisherImpl)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Publisher (org.reactivestreams.Publisher)1