All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.mt.subscription.AbstractSubscriber Maven / Gradle / Ivy

There is a newer version: 3.3.1
Show newest version
/******************************************************************************
 * © 2020 SAP SE or an SAP affiliate company. All rights reserved.            *
 ******************************************************************************/

package com.sap.cloud.mt.subscription;

public abstract class AbstractSubscriber implements Subscriber {
    protected static final int MINIMUM_TIME = 1000;

    protected void waitSomeTime(long startTime) {
        long endTime = System.nanoTime();
        long passedTimeMillis = (endTime - startTime) * 1000000;
        if (passedTimeMillis < MINIMUM_TIME) {
            try {
                //Un-subscribe and subscribe can be too fast.
                //Then the callback of this task can overtake the "accepted" response of the called unsubscribe endpoint.
                //The saas registry doesn't allow this. The status remains on processing in the cockpit.
                Thread.sleep(MINIMUM_TIME - passedTimeMillis);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy