how to notify a live stream auto record by duration (add recorded filename to MySQL)

Hi

regarding to https://www.wowza.com/docs/how-to-start-and-stop-live-stream-recordings-programmatically-imediastreamactionnotify3

how to notify when segment end or new segment is start writing?

I want to know what file is recorded and add file name to database.

package com.wowza.wms.module;
import java.util.HashMap;
import java.util.Map;
import com.wowza.wms.livestreamrecord.model.ILiveStreamRecord;
import com.wowza.wms.livestreamrecord.model.LiveStreamRecorderMP4;
import com.wowza.wms.media.model.MediaCodecInfoAudio;
import com.wowza.wms.media.model.MediaCodecInfoVideo;
import com.wowza.wms.stream.*;
import com.wowza.wms.amf.AMFPacket;
import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.application.WMSProperties;
public class LiveStreamAutoRecordMysql<StreamRecorderParameters> extends ModuleBase implements IModuleOnStream {
	
	private Map<String, ILiveStreamRecord> recorders = new HashMap<String, ILiveStreamRecord>();
	private IApplicationInstance appInstance;
	
	public void onAppStart(IApplicationInstance appInstance)
	{
		this.appInstance = appInstance;
	}
	class StreamListener implements IMediaStreamActionNotify3
	{
		public void onMetaData(IMediaStream stream, AMFPacket metaDataPacket)
		{
			System.out.println("onMetaData[" + stream.getContextStr() + "]: " + metaDataPacket.toString());
		}
		public void onPauseRaw(IMediaStream stream, boolean isPause, double location)
		{
			System.out.println("onPauseRaw[" + stream.getContextStr() + "]: isPause:" + isPause + " location:" + location);
		}
		public void onPause(IMediaStream stream, boolean isPause, double location)
		{
			System.out.println("onPause[" + stream.getContextStr() + "]: isPause:" + isPause + " location:" + location);
		}
		public void onPlay(IMediaStream stream, String streamName, double playStart, double playLen, int playReset)
		{
			System.out.println("onPlay[" + stream.getContextStr() + "]: playStart:" + playStart + " playLen:" + playLen + " playReset:" + playReset);
		}
		
		public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
		{
			System.out.println("onPublish[" + stream.getContextStr() + "]: streamName:" + streamName + " isRecord:" + isRecord + " isAppend:" + isAppend);
			ILiveStreamRecord recorder = new LiveStreamRecorderMP4();
		    recorder.init(appInstance);
		    recorder.setRecordData(true);
		    recorder.setStartOnKeyFrame(true);
		    recorder.setVersionFile(true);
		       
			synchronized (recorders)
			{
				ILiveStreamRecord prevRecorder = recorders.get(streamName);
				if (prevRecorder != null)
					prevRecorder.stopRecording();
				recorders.put(streamName, recorder);
			}
			System.out.println("");
			System.out.println("--- startRecordingSegmentByDuration for 30 minutes");
			System.out.println("");
			recorder.startRecordingSegmentByDuration(stream, null, null, 30*60*1000);
			System.out.println("onPublish[" + stream.getContextStr() + "]: new Recording started:" + recorder.getFilePath());
			
		}
        
		public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
		{
			System.out.println("onUnPublish[" + stream.getContextStr() + "]: streamName:" + streamName + " isRecord:" + isRecord + " isAppend:" + isAppend);
			
			ILiveStreamRecord recorder = null;
			synchronized (recorders)
			{
				recorder = recorders.remove(streamName);
			}
			
			if (recorder != null)
			{
				String filepath = recorder.getFilePath();
				recorder.stopRecording();
				System.out.println("onUnPublish[" + stream.getContextStr() + "]: File Closed:" + filepath);
			}
			else
			{
				System.out.println("onUnPublish[" + stream.getContextStr() + "]: streamName:" + streamName + " stream recorder not found");
			}
		}
		
		public void onSeek(IMediaStream stream, double location)
		{
			System.out.println("onSeek[" + stream.getContextStr() + "]: location:" + location);
		}
		public void onStop(IMediaStream stream)
		{
			System.out.println("onStop[" + stream.getContextStr() + "]: ");
		}
		public void onCodecInfoAudio(IMediaStream stream,MediaCodecInfoAudio codecInfoAudio) {
			System.out.println("onCodecInfoAudio[" + stream.getContextStr() + " Audio Codec" + codecInfoAudio.toCodecsStr() + "]: ");
		}
		public void onCodecInfoVideo(IMediaStream stream,MediaCodecInfoVideo codecInfoVideo) {
			System.out.println("onCodecInfoVideo[" + stream.getContextStr() + " Video Codec" + codecInfoVideo.toCodecsStr() + "]: ");
		}
	}
	public void onStreamCreate(IMediaStream stream)
	{
		getLogger().info("onStreamCreate["+stream+"]: clientId:" + stream.getClientId());
		IMediaStreamActionNotify3 actionNotify = new StreamListener();
		WMSProperties props = stream.getProperties();
		synchronized (props)
		{
			props.put("streamActionNotifier", actionNotify);
		}
		stream.addClientListener(actionNotify);
	}
	public void onStreamDestroy(IMediaStream stream)
	{
		getLogger().info("onStreamDestroy["+stream+"]: clientId:" + stream.getClientId());
		IMediaStreamActionNotify3 actionNotify = null;
		WMSProperties props = stream.getProperties();
		synchronized (props)
		{
			actionNotify = (IMediaStreamActionNotify3) stream.getProperties().get("streamActionNotifier");
		}
		if (actionNotify != null)
		{
			stream.removeClientListener(actionNotify);
			getLogger().info("removeClientListener: " + stream.getSrc());
		}
	}
}

thank you.