|
@@ -1,57 +1,57 @@
|
|
|
-package com.fdkankan.download.listener;
|
|
|
-
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fdkankan.common.util.CmdUtils;
|
|
|
-import com.fdkankan.download.constant.CommonConstant;
|
|
|
-import com.rabbitmq.client.Channel;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.amqp.core.Message;
|
|
|
-import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
-
|
|
|
-@Slf4j
|
|
|
-@Component
|
|
|
-public class RsyncSceneListener {
|
|
|
-
|
|
|
- public final static String RSYNC_CMD = "rsync -avP -e 'ssh -p $port' $source $user@$host:$dest";
|
|
|
-
|
|
|
- @Value("${rsync.host}")
|
|
|
- private String host;
|
|
|
-
|
|
|
- @Value("${rsync.port}")
|
|
|
- private String port;
|
|
|
-
|
|
|
- @Value("${rsync.username}")
|
|
|
- private String username;
|
|
|
-
|
|
|
- @Value("${rsync.dest}")
|
|
|
- private String dest;
|
|
|
-
|
|
|
- /**
|
|
|
- * 场景计算状态日志记录
|
|
|
- * @param channel
|
|
|
- * @param message
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @RabbitListener(
|
|
|
- queuesToDeclare = @Queue("rsync-scene"),
|
|
|
- concurrency = "2"
|
|
|
- )
|
|
|
- public void buildScenePreHandler(Channel channel, Message message) throws Exception {
|
|
|
- String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
- System.out.println(msg);
|
|
|
- JSONObject jsonObject = JSON.parseObject(msg);
|
|
|
- String path = jsonObject.getString("path");
|
|
|
- String cmd = RSYNC_CMD.replace("$port", port).replace("$source", path).replace("$user", username).replace("$host", host).replace("$dest", dest);
|
|
|
- CmdUtils.callLineSh(cmd);
|
|
|
- FileUtil.del(path);
|
|
|
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+//package com.fdkankan.download.listener;
|
|
|
+//
|
|
|
+//import cn.hutool.core.io.FileUtil;
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
+//import com.alibaba.fastjson.JSONObject;
|
|
|
+//import com.fdkankan.common.util.CmdUtils;
|
|
|
+//import com.fdkankan.download.constant.CommonConstant;
|
|
|
+//import com.rabbitmq.client.Channel;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.springframework.amqp.core.Message;
|
|
|
+//import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
+//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+//import org.springframework.beans.factory.annotation.Value;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//import java.nio.charset.StandardCharsets;
|
|
|
+//
|
|
|
+//@Slf4j
|
|
|
+//@Component
|
|
|
+//public class RsyncSceneListener {
|
|
|
+//
|
|
|
+// public final static String RSYNC_CMD = "rsync -avP -e 'ssh -p $port' $source $user@$host:$dest";
|
|
|
+//
|
|
|
+// @Value("${rsync.host}")
|
|
|
+// private String host;
|
|
|
+//
|
|
|
+// @Value("${rsync.port}")
|
|
|
+// private String port;
|
|
|
+//
|
|
|
+// @Value("${rsync.username}")
|
|
|
+// private String username;
|
|
|
+//
|
|
|
+// @Value("${rsync.dest}")
|
|
|
+// private String dest;
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 场景计算状态日志记录
|
|
|
+// * @param channel
|
|
|
+// * @param message
|
|
|
+// * @throws Exception
|
|
|
+// */
|
|
|
+// @RabbitListener(
|
|
|
+// queuesToDeclare = @Queue("rsync-scene"),
|
|
|
+// concurrency = "2"
|
|
|
+// )
|
|
|
+// public void buildScenePreHandler(Channel channel, Message message) throws Exception {
|
|
|
+// String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+// System.out.println(msg);
|
|
|
+// JSONObject jsonObject = JSON.parseObject(msg);
|
|
|
+// String path = jsonObject.getString("path");
|
|
|
+// String cmd = RSYNC_CMD.replace("$port", port).replace("$source", path).replace("$user", username).replace("$host", host).replace("$dest", dest);
|
|
|
+// CmdUtils.callLineSh(cmd);
|
|
|
+// FileUtil.del(path);
|
|
|
+// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|