code: public Long getNewInvokeId() throws TCAPException {
          try {
              this.dialogLock.lock();
              if (this.freeCount == 0) {
                  throw new TCAPException("No free invokeId");
              }
  
              int tryCnt = 0;
              while (true) {
                  if (++this.lastInvokeIdIndex >= this.invokeIDTable.length)
                      this.lastInvokeIdIndex = 0;
                  if (this.invokeIDTable[this.lastInvokeIdIndex] == _INVOKEID_FREE) {
                      freeCount--;
                      this.invokeIDTable[this.lastInvokeIdIndex] = _INVOKEID_TAKEN;
                      return getInvokeIdFromIndex(this.lastInvokeIdIndex);
                  }
                  if (++tryCnt >= 256)
                      throw new TCAPException("No free invokeId");
              }
  
          } finally {
              this.dialogLock.unlock();
          }
      }
docs: /*
  (non-Javadoc)
  
  @see org.restcomm.protocols.ss7.tcap.api.tc.dialog.Dialog#getNewInvokeId()