@Override
  public void addBindings(PersistedType type, String name, String... address) throws Exception {
    Pair<PersistedType, String> key = new Pair<>(type, name);

    long tx = idGenerator.generateID();

    PersistedBindings currentBindings = mapBindings.get(key);
    if (currentBindings != null) {
      jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
    } else {
      currentBindings = new PersistedBindings(type, name);
    }

    mapBindings.put(key, currentBindings);

    for (String adItem : address) {
      currentBindings.addBinding(adItem);
    }

    long newId = idGenerator.generateID();

    currentBindings.setId(newId);

    jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);

    jmsJournal.appendCommitRecord(tx, true);
  }
  @Override
  public void deleteBindings(PersistedType type, String name, String address) throws Exception {
    Pair<PersistedType, String> key = new Pair<>(type, name);

    long tx = idGenerator.generateID();

    PersistedBindings currentBindings = mapBindings.get(key);
    if (currentBindings == null) {
      return;
    } else {
      jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
    }

    currentBindings.deleteBinding(address);

    if (currentBindings.getBindings().size() == 0) {
      mapBindings.remove(key);
    } else {
      long newId = idGenerator.generateID();
      currentBindings.setId(newId);
      jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);
    }

    jmsJournal.appendCommitRecord(tx, true);
  }
  /** @param packet */
  private void handleAppendAddTXRecord(final ReplicationAddTXMessage packet) throws Exception {
    Journal journalToUse = getJournal(packet.getJournalID());

    if (packet.getOperation() == ADD_OPERATION_TYPE.UPDATE) {
      journalToUse.appendUpdateRecordTransactional(
          packet.getTxId(), packet.getId(), packet.getRecordType(), packet.getRecordData());
    } else {
      journalToUse.appendAddRecordTransactional(
          packet.getTxId(), packet.getId(), packet.getRecordType(), packet.getRecordData());
    }
  }