@Override
    public void persist(MessageQueue mq) {
        if (mq == null) {
            return;
        }
        ControllableOffset offset = this.offsetTable.get(mq);
        if (offset != null) {
            OffsetSerializeWrapper offsetSerializeWrapper = null;
            try {
                offsetSerializeWrapper = readLocalOffset();
            } catch (MQClientException e) {
                log.error("readLocalOffset exception", e);
                return;
            }
            if (offsetSerializeWrapper == null) {
                offsetSerializeWrapper = new OffsetSerializeWrapper();
            }
            offsetSerializeWrapper.getOffsetTable().put(mq, new AtomicLong(offset.getOffset()));
            String jsonString = offsetSerializeWrapper.toJson(true);
            if (jsonString != null) {
                try {
                    MixAll.string2File(jsonString, this.storePath);
                } catch (IOException e) {
                    log.error("persist consumer offset exception, " + this.storePath, e);
                }
            }
        }
    }
@Test
    public void testPersist() throws Exception {
        OffsetStore offsetStore = new LocalFileOffsetStore(mQClientFactory, group);

        MessageQueue messageQueue0 = new MessageQueue(topic, brokerName, 0);
        offsetStore.updateOffset(messageQueue0, 1024, false);
        offsetStore.persist(messageQueue0);
        assertThat(offsetStore.readOffset(messageQueue0, ReadOffsetType.READ_FROM_STORE)).isEqualTo(1024);

        MessageQueue messageQueue1 = new MessageQueue(topic, brokerName, 1);
        assertThat(offsetStore.readOffset(messageQueue1, ReadOffsetType.READ_FROM_STORE)).isEqualTo(-1);
    }