Package org.apache.hedwig.client.data

Examples of org.apache.hedwig.client.data.TopicSubscriber


         * {@link DeliveryManagerRequest} methods
         */
        public void performRequest() {

            // Put this subscriber in the channel to subscriber mapping
            ActiveSubscriberState prevSubscriber = subscriberStates.put(new TopicSubscriber(topic, subscriberId), this);

            if (prevSubscriber != null) {
                stopServingSubscriber(prevSubscriber);
            }

View Full Code Here


        }
    }

    public void operationFinished(Object ctx, Void resultOfOperation) {
        MessageConsumeData messageConsumeData = (MessageConsumeData) ctx;
        TopicSubscriber topicSubscriber = new TopicSubscriber(messageConsumeData.topic, messageConsumeData.subscriberId);
        // Message has been successfully consumed by the client app so callback
        // to the ResponseHandler indicating that the message is consumed.
        Channel topicSubscriberChannel = client.getSubscriber().getChannelForTopic(topicSubscriber);
        HedwigClientImpl.getResponseHandlerFromChannel(topicSubscriberChannel).getSubscribeResponseHandler()
        .messageConsumed(messageConsumeData.msg);
View Full Code Here

    public void operationFailed(Object ctx, PubSubException exception) {
        // Message has NOT been successfully consumed by the client app so
        // callback to the ResponseHandler to try the async MessageHandler
        // Consume logic again.
        MessageConsumeData messageConsumeData = (MessageConsumeData) ctx;
        TopicSubscriber topicSubscriber = new TopicSubscriber(messageConsumeData.topic, messageConsumeData.subscriberId);
        logger.error("Message was not consumed successfully by client MessageHandler: " + messageConsumeData);

        // Sleep a pre-configured amount of time (in milliseconds) before we
        // do the retry. In the future, we can have more dynamic logic on
        // what duration to sleep based on how many times we've retried, or
View Full Code Here

            origSubData = pubSubData;
            // Store the mapping for the TopicSubscriber to the Channel.
            // This is so we can control the starting and stopping of
            // message deliveries from the server on that Channel. Store
            // this only on a successful ack response from the server.
            TopicSubscriber topicSubscriber = new TopicSubscriber(pubSubData.topic, pubSubData.subscriberId);
            responseHandler.getSubscriber().setChannelForTopic(topicSubscriber, channel);
            // Lazily create the Set (from a concurrent hashmap) to keep track
            // of outstanding Messages to be consumed by the client app. At this
            // stage, delivery for that topic hasn't started yet so creation of
            // this Set should be thread safe. We'll create the Set with an initial
View Full Code Here

    public void channelDisconnected(Channel channel) {
        // Evils of synchronized programming: there is a race between a channel
        // getting disconnected, and us adding it to the maps when a subscribe
        // succeeds
        synchronized (channel) {
            TopicSubscriber topicSub = channel2sub.remove(channel);
            if (topicSub != null) {
                sub2Channel.remove(topicSub);
            }
        }
    }
View Full Code Here

            }

            @Override
            public void operationFinished(Object ctx, MessageSeqId resultOfOperation) {

                TopicSubscriber topicSub = new TopicSubscriber(topic, subscriberId);

                // race with channel getting disconnected while we are adding it
                // to the 2 maps
                synchronized (channel) {
                    if (!channel.isConnected()) {
View Full Code Here

    //       which is supposed to be fixed in {@link https://issues.apache.org/jira/browse/BOOKKEEPER-503}
    @Override
    public void messageConsumed(ByteString topic, ByteString subscriberId,
                                MessageSeqId consumedSeqId) {
        ActiveSubscriberState subState =
            subscriberStates.get(new TopicSubscriber(topic, subscriberId));
        if (null == subState) {
            return;
        }
        subState.messageConsumed(consumedSeqId.getLocalComponent());
    }
View Full Code Here

         */
        @Override
        public void performRequest() {
            // Put this subscriber in the channel to subscriber mapping
            ActiveSubscriberState prevSubscriber =
                subscriberStates.put(new TopicSubscriber(topic, subscriberId), this);

            // after put the active subscriber in subscriber states mapping
            // trigger the callback to tell it started to deliver the message
            // should let subscriber response go first before first delivered message.
            cb.operationFinished(ctx, (Void)null);
View Full Code Here

        final Object ctx;

        public StopServingSubscriber(ByteString topic, ByteString subscriberId,
                                     SubscriptionEvent event,
                                     Callback<Void> callback, Object ctx) {
            this.ts = new TopicSubscriber(topic, subscriberId);
            this.event = event;
            this.cb = callback;
            this.ctx = ctx;
        }
View Full Code Here

    }

    @Override
    public void stopServingSubscriber(ByteString topic, ByteString subscriberId) {
        lastRequest.add(new TopicSubscriber(topic, subscriberId));
    }
View Full Code Here

TOP

Related Classes of org.apache.hedwig.client.data.TopicSubscriber

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.