|
|
@@ -5,6 +5,7 @@ import com.github.microservice.components.data.mongo.queue.config.ExecQueueConfi
|
|
|
import com.github.microservice.components.data.mongo.queue.dao.ExecQueueDao;
|
|
|
import com.github.microservice.components.data.mongo.queue.domain.ExecQueue;
|
|
|
import com.github.microservice.components.data.mongo.queue.event.ExecQueueEvent;
|
|
|
+import org.apache.commons.lang3.SerializationUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.Assert;
|
|
|
@@ -24,15 +25,21 @@ public class ExecQueueService {
|
|
|
@Autowired
|
|
|
private DBHelper dbHelper;
|
|
|
|
|
|
- // 添加
|
|
|
- public String add(Map<String, Object> data, int maxTryCount, Class<? extends ExecQueueEvent> eventClass) {
|
|
|
+ /**
|
|
|
+ * @param data
|
|
|
+ * @param maxTryCount
|
|
|
+ * @param execQueueEvent , 注意,事件必须是可序列化的
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String add(Map<String, Object> data, int maxTryCount, ExecQueueEvent execQueueEvent) {
|
|
|
Assert.state(maxTryCount > 0, "最大尝试次数必须大于0");
|
|
|
- Assert.notNull(eventClass, "事件不能为空");
|
|
|
+ Assert.notNull(execQueueEvent, "事件不能为空");
|
|
|
|
|
|
final ExecQueue execQueue = new ExecQueue();
|
|
|
-
|
|
|
execQueue.setData(data);
|
|
|
- execQueue.setEventClass(eventClass.getName());
|
|
|
+// execQueue.setEventClass(eventClass.getName());
|
|
|
+
|
|
|
+ execQueue.setExecQueueEvent(SerializationUtils.serialize(execQueueEvent));
|
|
|
|
|
|
execQueue.setCurrentTryCount(0);
|
|
|
execQueue.setMaxTryCount(maxTryCount);
|