Search in sources :

Example 1 with ProtonPublisherWrapperImpl

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();
}
Also used : Message(org.apache.qpid.proton.message.Message) 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) ProtonPublisherWrapperImpl(io.vertx.proton.streams.impl.ProtonPublisherWrapperImpl)

Aggregations

ProtonClient (io.vertx.proton.ProtonClient)1 ProtonConnection (io.vertx.proton.ProtonConnection)1 ProtonPublisher (io.vertx.proton.streams.ProtonPublisher)1 ProtonPublisherWrapperImpl (io.vertx.proton.streams.impl.ProtonPublisherWrapperImpl)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Message (org.apache.qpid.proton.message.Message)1 Publisher (org.reactivestreams.Publisher)1