Package org.apache.hedwig.client.api

Examples of org.apache.hedwig.client.api.Subscriber.subscribe()


    public void testSyncHubSubscribeWithInvalidSubscriberId() throws Exception {
        Client hubClient = new HedwigHubClient(new ClientConfiguration());
        Subscriber hubSubscriber = hubClient.getSubscriber();
        boolean subscribeSuccess = false;
        try {
            hubSubscriber.subscribe(getTopic(0), localSubscriberId, CreateOrAttach.CREATE_OR_ATTACH);
        } catch (InvalidSubscriberIdException e) {
            subscribeSuccess = true;
        } catch (Exception ex) {
            subscribeSuccess = false;
        }
View Full Code Here


    public void testSyncHubSubscribeWithInvalidSubscriberId() throws Exception {
        Client hubClient = new HedwigHubClient(new ClientConfiguration());
        Subscriber hubSubscriber = hubClient.getSubscriber();
        boolean subscribeSuccess = false;
        try {
            hubSubscriber.subscribe(getTopic(0), localSubscriberId, CreateOrAttach.CREATE_OR_ATTACH);
        } catch (InvalidSubscriberIdException e) {
            subscribeSuccess = true;
        } catch (Exception ex) {
            subscribeSuccess = false;
        }
View Full Code Here

        Publisher pub = client.getPublisher();
        Subscriber sub = client.getSubscriber();

        ByteString topic = ByteString.copyFromUtf8("testServerSideThrottle");
        ByteString subid = ByteString.copyFromUtf8("serverThrottleSub");
        sub.subscribe(topic, subid, CreateOrAttach.CREATE);
        sub.closeSubscription(topic, subid);

        // throttle with hub server's setting
        throttleX(pub, sub, topic, subid, DEFAULT_MESSAGE_WINDOW_SIZE);
View Full Code Here

        // throttle with a lower value than hub server's setting
        SubscriptionOptions.Builder optionsBuilder = SubscriptionOptions.newBuilder()
            .setCreateOrAttach(CreateOrAttach.CREATE)
            .setMessageWindowSize(messageWindowSize);
        topic = ByteString.copyFromUtf8("testServerSideThrottleWithLowerValue");
        sub.subscribe(topic, subid, optionsBuilder.build());
        sub.closeSubscription(topic, subid);
        throttleX(pub, sub, topic, subid, messageWindowSize);

        messageWindowSize = DEFAULT_MESSAGE_WINDOW_SIZE + 5;
        // throttle with a higher value than hub server's setting
View Full Code Here

        // throttle with a higher value than hub server's setting
        optionsBuilder = SubscriptionOptions.newBuilder()
                         .setCreateOrAttach(CreateOrAttach.CREATE)
                         .setMessageWindowSize(messageWindowSize);
        topic = ByteString.copyFromUtf8("testServerSideThrottleWithHigherValue");
        sub.subscribe(topic, subid, optionsBuilder.build());
        sub.closeSubscription(topic, subid);
        throttleX(pub, sub, topic, subid, messageWindowSize);

        client.close();
    }
View Full Code Here

        Subscriber sub = client.getSubscriber();

        ByteString topic = ByteString.copyFromUtf8("testThrottleWithServerSideFilter");
        ByteString subid = ByteString.copyFromUtf8("mysub");
        SubscriptionOptions opts = SubscriptionOptions.newBuilder().setCreateOrAttach(CreateOrAttach.CREATE).build();
        sub.subscribe(topic, subid, opts);
        sub.closeSubscription(topic, subid);

        // message gap: half of the throttle threshold
        throttleWithFilter(pub, sub, topic, subid, messageWindowSize / 2);
        // message gap: equals to the throttle threshold
View Full Code Here

        final CountDownLatch closeLatch = new CountDownLatch(1);
        final CountDownLatch subLatch = new CountDownLatch(1);
        final CountDownLatch deliverLatch = new CountDownLatch(1);

        try {
            subscriber.subscribe(topic, subid, CreateOrAttach.CREATE_OR_ATTACH);
            sleepDeliveryManager(wakeupLatch);
            subscriber.asyncCloseSubscription(topic, subid, new Callback<Void>() {
                @Override
                public void operationFinished(Object ctx, Void resultOfOperation) {
                    closeLatch.countDown();
View Full Code Here

            final ByteString topic = ByteString.copyFromUtf8("TestSimpleClientTopicBusy");
            final ByteString subid = ByteString.copyFromUtf8("mysub");

            subscriber1.subscribe(topic, subid, CreateOrAttach.CREATE_OR_ATTACH);
            subscriber1.closeSubscription(topic, subid);
            subscriber2.subscribe(topic, subid, CreateOrAttach.ATTACH);
            subscriber2.closeSubscription(topic, subid);

            client1.close();
            client2.close();
        }
View Full Code Here

    public void testSyncHubSubscribeWithInvalidSubscriberId() throws Exception {
        Client hubClient = new HedwigHubClient(new ClientConfiguration());
        Subscriber hubSubscriber = hubClient.getSubscriber();
        boolean subscribeSuccess = false;
        try {
            hubSubscriber.subscribe(getTopic(0), localSubscriberId, CreateOrAttach.CREATE_OR_ATTACH);
        } catch (InvalidSubscriberIdException e) {
            subscribeSuccess = true;
        } catch (Exception ex) {
            subscribeSuccess = false;
        }
View Full Code Here

    public void testSyncHubSubscribeWithInvalidSubscriberId() throws Exception {
        Client hubClient = new HedwigHubClient(new ClientConfiguration());
        Subscriber hubSubscriber = hubClient.getSubscriber();
        boolean subscribeSuccess = false;
        try {
            hubSubscriber.subscribe(getTopic(0), localSubscriberId, CreateOrAttach.CREATE_OR_ATTACH);
        } catch (InvalidSubscriberIdException e) {
            subscribeSuccess = true;
        } catch (Exception ex) {
            subscribeSuccess = false;
        }
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.