Package org.apache.hedwig.client.api

Examples of org.apache.hedwig.client.api.MessageHandler


                        @Override
                        public void operationFinished(Object ctx, Void resultOfOperation) {
                            if (LOGGER.isDebugEnabled())
                                LOGGER.debug("cross-region subscription done for topic " + topic.toStringUtf8());
                            try {
                                sub.startDelivery(topic, mySubId, new MessageHandler() {
                                    @Override
                                    public void deliver(final ByteString topic, ByteString subscriberId, Message msg,
                                    final Callback<Void> callback, final Object context) {
                                        // When messages are first published
                                        // locally, the PublishHandler sets the
View Full Code Here


                                  new PubSubException.ClientNotSubscribedException("no subscription to start delivery on"),
                                  request.getTxnId()));
                return;
            }

            MessageHandler handler = new MessageHandler() {
                @Override
                public void deliver(ByteString topic, ByteString subscriberId, Message msg,
                final Callback<Void> callback, final Object context) {

                    PubSubResponse response = PubSubResponse.newBuilder().setProtocolVersion(
View Full Code Here

            }

            final String topic = HedwigBenchmark.TOPIC_PREFIX + i;

            subscriber.subscribe(ByteString.copyFromUtf8(topic), subId, CreateOrAttach.CREATE_OR_ATTACH);
            subscriber.startDelivery(ByteString.copyFromUtf8(topic), subId, new MessageHandler() {

                @Override
                public void deliver(ByteString thisTopic, ByteString subscriberId, Message msg,
                Callback<Void> callback, Object context) {
                    if (logger.isDebugEnabled())
View Full Code Here

    public void warmup(int nWarmup) throws Exception {
        ByteString topic = ByteString.copyFromUtf8("warmup" + partitionIndex);
        ByteString subId = ByteString.copyFromUtf8("sub");
        subscriber.subscribe(topic, subId, CreateOrAttach.CREATE_OR_ATTACH);

        subscriber.startDelivery(topic, subId, new MessageHandler() {
            @Override
            public void deliver(ByteString topic, ByteString subscriberId, Message msg, Callback<Void> callback,
            Object context) {
                // noop
                callback.operationFinished(context, null);
View Full Code Here

                .setOptions(userOptions).setMessageFilter(ModMessageFilter.class.getName()).build();
        sub.subscribe(topic, subid, opts);

        final AtomicInteger expected = new AtomicInteger(X);
        final CountDownLatch latch = new CountDownLatch(1);
        sub.startDelivery(topic, subid, new MessageHandler() {
            @Override
            public synchronized void deliver(ByteString topic, ByteString subscriberId,
                                             Message msg,
                                             Callback<Void> callback, Object context) {
                try {
View Full Code Here

        sub.subscribe(topic, subid, CreateOrAttach.ATTACH);

        final AtomicInteger expected = new AtomicInteger(1);
        final CountDownLatch throttleLatch = new CountDownLatch(1);
        final CountDownLatch nonThrottleLatch = new CountDownLatch(1);
        sub.startDelivery(topic, subid, new MessageHandler() {
            @Override
            public synchronized void deliver(ByteString topic, ByteString subscriberId,
                                             Message msg,
                                             Callback<Void> callback, Object context) {
                try {
View Full Code Here

            }, null);
            subscriber.asyncSubscribe(topic, subid, CreateOrAttach.ATTACH, new Callback<Void>() {
                @Override
                public void operationFinished(Object ctx, Void resultOfOperation) {
                    try {
                        subscriber.startDelivery(topic, subid, new MessageHandler() {
                            @Override
                            public void deliver(ByteString topic, ByteString subid, Message msg,
                                                Callback<Void> callback, Object context) {
                                deliverLatch.countDown();
                            }
View Full Code Here

        Channel topicSubscriberChannel = topicSubscriber2Channel.get(topicSubscriber);

        // Need to ensure the setting of handler and the readability of channel is in sync
        // as there's a race condition that connection recovery and user might call this at the same time

        MessageHandler existedMsgHandler = topicSubscriber2MessageHandler.get(topicSubscriber);
        if (restart) {
            // restart using existing msg handler
            messageHandler = existedMsgHandler;
        } else {
            // some has started delivery but not stop it
View Full Code Here

        }
        sub.subscribe(topic, subid, CreateOrAttach.ATTACH);

        final AtomicInteger expected = new AtomicInteger(X - Y);
        final CountDownLatch latch = new CountDownLatch(1);
        sub.startDelivery(topic, subid, new MessageHandler () {
                synchronized public void deliver(ByteString topic, ByteString subscriberId,
                                    Message msg, Callback<Void> callback,
                                    Object context) {
                    try {
                        int value = Integer.valueOf(msg.getBody().toStringUtf8());
View Full Code Here

    public void warmup(int nWarmup) throws Exception {
        ByteString topic = ByteString.copyFromUtf8("warmup" + partitionIndex);
        ByteString subId = ByteString.copyFromUtf8("sub");
        subscriber.subscribe(topic, subId, CreateOrAttach.CREATE_OR_ATTACH);

        subscriber.startDelivery(topic, subId, new MessageHandler() {
            @Override
            public void deliver(ByteString topic, ByteString subscriberId, Message msg, Callback<Void> callback,
            Object context) {
                // noop
                callback.operationFinished(context, null);
View Full Code Here

TOP

Related Classes of org.apache.hedwig.client.api.MessageHandler

Copyright © 2018 www.massapicom. 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.