hazelcast-master/hazelcast/src/main/java/com/hazelcast/topic/impl/reliable/ReliableMessageListenerAdapter.java
/*
 * Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.topic.impl.reliable;

import com.hazelcast.topic.Message;
import com.hazelcast.topic.MessageListener;
import com.hazelcast.topic.ReliableMessageListener;

public class ReliableMessageListenerAdapter<E> implements ReliableMessageListener<E> {

    final MessageListener<E> messageListener;

    public ReliableMessageListenerAdapter(MessageListener<E> messageListener) {
        this.messageListener = messageListener;
    }

    @Override
    public long retrieveInitialSequence() {
        // -1 indicates start from next message.
        return -1;
    }

    @Override
    public void storeSequence(long sequence) {
        //np-op
    }

    @Override
    public boolean isLossTolerant() {
        return false;
    }

    @Override
    public void onMessage(Message<E> message) {
        messageListener.onMessage(message);
    }

    @Override
    public boolean isTerminal(Throwable failure) {
        return false;
    }

    @Override
    public String toString() {
        return messageListener.toString();
    }
}
