code: public void onReadyToInvalidate() {
  
          if (isB2BUAOrphan()) {
              logger.debug("Session is B2BUA Orphaned, lets invalidate");
              setReadyToInvalidate(true);
          }
  
          if (!readyToInvalidate) {
              logger.debug("Session not ready to invalidate, wait next chance.");
              return;
          }
  
          boolean allDerivedReady = true;
          Iterator<MobicentsSipSession> derivedSessionsIterator = this.getDerivedSipSessions();
          while (derivedSessionsIterator.hasNext()) {
                  MobicentsSipSession mobicentsSipSession = (MobicentsSipSession) derivedSessionsIterator
                                  .next();
                  boolean derivedIsOrphaned = mobicentsSipSession.isB2BUAOrphan();
                  boolean derivedReady = !mobicentsSipSession.isValid() || derivedIsOrphaned;
                  allDerivedReady = allDerivedReady & derivedReady;
          }
  
              if(logger.isDebugEnabled()) {
                  String msg = String.format("Session [%s] onReadyToInvalidate, hasParent [%s], hasDerivedSessions [%s], will invalidate [%s]", key, parentSession != null, derivedSipSessions != null, allDerivedReady);
                  logger.debug(msg);
              }
  
          if (!allDerivedReady) {
              logger.debug("Cant invalidate yet, lets wait until all derived to be ready.");
              return;
          } else {
              logger.debug("All Derived ready, lets proceed.");
              }
  
      	if(logger.isDebugEnabled()) {
      		logger.debug("invalidateWhenReady flag is set to " + invalidateWhenReady);
      	}
  
      	if(isValid() && this.invalidateWhenReady) {
      		this.notifySipSessionListeners(SipSessionEventType.READYTOINVALIDATE);
      		//If the application does not explicitly invalidate the session in the callback or has not defined a listener,
          	//the container will invalidate the session.
          	if(isValid()) {
          		invalidate(true);
          	}
      	}
      }
docs: This method is called immediately when the conditions for read to invalidate
  session are met