Package org.apache.hedwig.client.api

Examples of org.apache.hedwig.client.api.Publisher.publish()


            assertTrue("Async close subscription should succeed.",
                       closeLatch.await(5, TimeUnit.SECONDS));
            assertTrue("Subscribe should succeed.",
                       subLatch.await(5, TimeUnit.SECONDS));
            // publish a message
            publisher.publish(topic, Message.newBuilder().setBody(topic).build());
            // wait for seconds to receive message
            assertTrue("Message should be received through successful subscription.",
                       deliverLatch.await(5, TimeUnit.SECONDS));
        } finally {
            client.close();
View Full Code Here


        ByteString subid = ByteString.copyFromUtf8("testGCSubId");
        sub.subscribe(topic, subid, CreateOrAttach.CREATE_OR_ATTACH);
        sub.closeSubscription(topic, subid);

        for (int i = 1; i <= 100; i++) {
            pub.publish(topic, Message.newBuilder().setBody(
                                ByteString.copyFromUtf8(String.valueOf(i))).build());
        }
        LedgerRanges r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
        assertEquals("Should only have 1 ledger yet", 1, r.getRangesList().size());
        long firstLedger = r.getRangesList().get(0).getLedgerId();
View Full Code Here

        long firstLedger = r.getRangesList().get(0).getLedgerId();

        stopHubServers();
        startHubServers();

        pub.publish(topic, Message.newBuilder().setBody(
                            ByteString.copyFromUtf8(String.valueOf(0xdeadbeef))).build());

        r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
        assertEquals("Should have 2 ledgers after restart", 2, r.getRangesList().size());
View Full Code Here

        r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
        assertEquals("Should have 2 ledgers after restart", 2, r.getRangesList().size());

        for (int i = 100; i <= 200; i++) {
            pub.publish(topic, Message.newBuilder().setBody(
                                ByteString.copyFromUtf8(String.valueOf(i))).build());
        }
        Thread.sleep(5000); // give GC a chance to happen

        r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
View Full Code Here

            assertTrue("Async close subscription should succeed.",
                       closeLatch.await(5, TimeUnit.SECONDS));
            assertTrue("Subscribe should succeed.",
                       subLatch.await(5, TimeUnit.SECONDS));
            // publish a message
            publisher.publish(topic, Message.newBuilder().setBody(topic).build());
            // wait for seconds to receive message
            assertTrue("Message should be received through successful subscription.",
                       deliverLatch.await(5, TimeUnit.SECONDS));
        } finally {
            client.close();
View Full Code Here

        ByteString subid = ByteString.copyFromUtf8("testGCSubId");
        sub.subscribe(topic, subid, CreateOrAttach.CREATE_OR_ATTACH);
        sub.closeSubscription(topic, subid);

        for (int i = 1; i <= 100; i++) {
            pub.publish(topic, Message.newBuilder().setBody(
                                ByteString.copyFromUtf8(String.valueOf(i))).build());
        }
        LedgerRanges r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
        assertEquals("Should only have 1 ledger yet", 1, r.getRangesList().size());
        long firstLedger = r.getRangesList().get(0).getLedgerId();
View Full Code Here

        long firstLedger = r.getRangesList().get(0).getLedgerId();

        stopHubServers();
        startHubServers();

        pub.publish(topic, Message.newBuilder().setBody(
                            ByteString.copyFromUtf8(String.valueOf(0xdeadbeef))).build());

        r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
        assertEquals("Should have 2 ledgers after restart", 2, r.getRangesList().size());
View Full Code Here

        r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
        assertEquals("Should have 2 ledgers after restart", 2, r.getRangesList().size());

        for (int i = 100; i <= 200; i++) {
            pub.publish(topic, Message.newBuilder().setBody(
                                ByteString.copyFromUtf8(String.valueOf(i))).build());
        }
        Thread.sleep(5000); // give GC a chance to happen

        r = LedgerRanges.parseFrom(bktb.getZooKeeperClient().getData(ledgersPath, false, null));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.