Package org.apache.hedwig.client.api

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


            }

            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


                publisher.publish(topic, msg);
                System.out.println("Pub topic " + topic.toStringUtf8() + " : " + msg.getBody().toStringUtf8());

                // ensure subscriber first, publish next, then we start delivery to receive message
                // if start delivery first before publish, isDone may notify before wait
                subscriber.startDelivery(topic, subId, new MessageHandler() {

                    @Override
                    public void deliver(ByteString thisTopic, ByteString subscriberId,
                            Message message, Callback<Void> callback, Object context) {
                        if (thisTopic.equals(topic) && subscriberId.equals(subId) &&
View Full Code Here

        final CountDownLatch receiveLatch = new CountDownLatch(1);
        final Map<String, MessageSeqId> receivedMsgs =
            new HashMap<String, MessageSeqId>();

        subscriber.subscribe(topic, subid, CreateOrAttach.CREATE_OR_ATTACH);
        subscriber.startDelivery(topic, subid, new MessageHandler() {
            synchronized public void deliver(ByteString topic, ByteString subscriberId,
                                             Message msg, Callback<Void> callback,
                                             Object context) {
                String str = msg.getBody().toStringUtf8();
                receivedMsgs.put(str, msg.getMsgId());
View Full Code Here

        final CountDownLatch receiveLatch = new CountDownLatch(1);
        final Map<String, MessageSeqId> receivedMsgs =
            new HashMap<String, MessageSeqId>();

        subscriber.subscribe(topic, subid, CreateOrAttach.CREATE_OR_ATTACH);
        subscriber.startDelivery(topic, subid, new MessageHandler() {
            synchronized public void deliver(ByteString topic, ByteString subscriberId,
                                             Message msg, Callback<Void> callback,
                                             Object context) {
                String str = msg.getBody().toStringUtf8();
                receivedMsgs.put(str, msg.getMsgId());
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

                publisher.publish(topic, msg);
                System.out.println("Pub topic " + topic.toStringUtf8() + " : " + msg.getBody().toStringUtf8());

                // ensure subscriber first, publish next, then we start delivery to receive message
                // if start delivery first before publish, isDone may notify before wait
                subscriber.startDelivery(topic, subId, new MessageHandler() {

                    @Override
                    public void deliver(ByteString thisTopic, ByteString subscriberId,
                            Message message, Callback<Void> callback, Object context) {
                        if (thisTopic.equals(topic) && subscriberId.equals(subId) &&
View Full Code Here

            @Override
            public void operationFinished(Object ctx, Void resultOfOperation) {
                if (LOGGER.isDebugEnabled())
                    LOGGER.debug("[" + myRegion + "] 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 int base = start + M - start % M;

        final AtomicInteger expected = new AtomicInteger(base);
        final CountDownLatch latch = new CountDownLatch(1);
        MessageHandler msgHandler = 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

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.