rocketmq icon indicating copy to clipboard operation
rocketmq copied to clipboard

CommitLog.putMessage setStoreTimestamp repetition

Open luoxn28 opened this issue 7 years ago • 2 comments

进入CommitLog.putMessage方法时,会先执行setStoreTimestamp设置时间戳,后面在对putMessageLock加锁后还会执行setStoreTimestamp设置时间戳,后者保证全局消息时间戳的顺序性,从流程来看,前者没必要设置。

public PutMessageResult putMessage(final MessageExtBrokerInner msg) {
	// Set the storage time
	msg.setStoreTimestamp(System.currentTimeMillis());
	// ...省略部分代码

	putMessageLock.lock(); //spin or ReentrantLock ,depending on store config
	try {
		long beginLockTimestamp = this.defaultMessageStore.getSystemClock().now();
		this.beginTimeInLock = beginLockTimestamp;

		// Here settings are stored timestamp, in order to ensure an orderly
		// global
		msg.setStoreTimestamp(beginLockTimestamp);

		// ...省略部分代码

	return putMessageResult;
}

luoxn28 avatar Jan 30 '19 03:01 luoxn28

This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.

github-actions[bot] avatar Oct 06 '22 00:10 github-actions[bot]

This issue was closed because it has been inactive for 3 days since being marked as stale.

github-actions[bot] avatar Oct 10 '22 00:10 github-actions[bot]