package cn.myapps.runtime.excutor.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//	/*todo: checked, rm by hc 20220517, beijing
@Component
public class RuntimeDaoCommandDispatch {
	//private static final Logger log = LoggerFactory.getLogger(RuntimeDaoCommandDispatch.class);
	//private static ThreadLocal<RuntimeDaoCommandGroup> COMMAND_GROUP = new ThreadLocal<>();

	/*
    @Autowired
    JmsTemplate jmsTemplate;

	 */

	public void addToExecGroup(RuntimeDaoCommand command) {
		System.err.println("重要队列: addToExecGroup todo: 被hc注释掉, 准备发送队列数据");
		/*
		RuntimeDaoCommandGroup group = COMMAND_GROUP.get();
		if (group != null) {
			group.add(command);
		}

		 */
	}
	
	
	public static void initAsync() {
		System.err.println("重要队列: initAsync todo: 被hc注释掉, 准备发送队列数据");
		//COMMAND_GROUP.set(new RuntimeDaoCommandGroup());
	}
	
	/**
	 * 判断是否被初始化
	 * @return
	 */
	public static boolean initialized() {
		System.err.println("重要队列: initialized todo: 被hc注释掉, 准备发送队列数据");

		return false;
		//return COMMAND_GROUP.get() != null;
	}
	
	/**
	 * 发送准备好的命令组到消息队列，并且清空队列池，为下个线程做准备
	 */
	public void kickOffAndClean() {
		System.err.println("重要队列: kickOffAndClean todo: 被hc注释掉, 准备发送队列数据");
		/*
		try {
			RuntimeDaoCommandGroup group = COMMAND_GROUP.get();
			if (group != null && group.size() > 0) {
				jmsTemplate.convertAndSend("RUNTIME_DAO_COMMAND", group);
			}
			log.debug("KickOff Command Group with size:{}" , group.size());			
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			COMMAND_GROUP.remove();
		}

		 */
	}
}
