| | |
| | | @Override |
| | | public void onMessage(Message message, byte[] pattern) { |
| | | log.info("监听Redis key过期,key:{},channel:{}", message.toString(), new String(pattern)); |
| | | synchronized (RedisMqReceiver.class) { |
| | | String ip = localIP; |
| | | log.error("本机的网络IP为:{}", ip); |
| | | String content = message.toString(); |
| | | //判断是不是任务信息,如果不是,直接返回,不需要执行 |
| | | if (!content.contains("taskid")) { |
| | | log.info("不是任务信息"); |
| | | return; |
| | | String ip = localIP; |
| | | log.error("本机的网络IP为:{}", ip); |
| | | String content = message.toString(); |
| | | //判断是不是任务信息,如果不是,直接返回,不需要执行 |
| | | if (!content.contains("taskid")) { |
| | | log.info("不是任务信息"); |
| | | return; |
| | | } |
| | | CommonTaskcallMQ commonTaskcallMQ = null; |
| | | try { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | if (!content.startsWith("{")) { |
| | | commonTaskcallMQ = mapper.readValue("{" + content + "}", CommonTaskcallMQ.class); |
| | | } else { |
| | | commonTaskcallMQ = mapper.readValue(content, CommonTaskcallMQ.class); |
| | | } |
| | | CommonTaskcallMQ commonTaskcallMQ = null; |
| | | try { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | if (!content.startsWith("{")) { |
| | | commonTaskcallMQ = mapper.readValue("{" + content + "}", CommonTaskcallMQ.class); |
| | | } else { |
| | | commonTaskcallMQ = mapper.readValue(content, CommonTaskcallMQ.class); |
| | | } |
| | | //这里之所以这样做一下,是搞不懂,为啥会进来两遍 |
| | | Boolean aBoolean = redisCache.hasKey(commonTaskcallMQ.getTaskid().toString()); |
| | | if (aBoolean) { |
| | | return; |
| | | } else { |
| | | redisCache.setCacheObject(commonTaskcallMQ.getTaskid().toString(), commonTaskcallMQ.getTaskid().toString(), 60, TimeUnit.SECONDS); |
| | | } |
| | | if (commonTaskcallMQ.getTaskType() == 1) { |
| | | //随访 |
| | | sfHandle(commonTaskcallMQ, ip); |
| | | } else if (commonTaskcallMQ.getTaskType() == 2) { |
| | | //问卷 |
| | | wjHandle(commonTaskcallMQ, ip); |
| | | } else if (commonTaskcallMQ.getTaskType() == 3) { |
| | | //宣教 |
| | | xjHandle(commonTaskcallMQ, ip); |
| | | } |
| | | //处理完成,移除redis |
| | | redisCache.deleteObject(message.toString()); |
| | | |
| | | } catch (Exception e) { |
| | | Integer integer = redisCache.getCacheObject(commonTaskcallMQ.getTaskid().toString()); |
| | | if (integer != null && integer == 2) { |
| | | //将消息从队列中删除 |
| | | } else if (integer == null) { |
| | | redisCache.setCacheObject(commonTaskcallMQ.getTaskid().toString(), 1, 120, TimeUnit.MINUTES); |
| | | } else { |
| | | redisCache.setCacheObject(commonTaskcallMQ.getTaskid().toString(), integer + 1, 120, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | log.error("============消费失败,尝试消息补发再次消费!============== {}", e.getMessage()); |
| | | redisCache.setCacheObject(message.toString(), message.toString(), 60, TimeUnit.SECONDS); |
| | | if (commonTaskcallMQ.getTaskType() == 1) { |
| | | //随访 |
| | | sfHandle(commonTaskcallMQ, ip); |
| | | } else if (commonTaskcallMQ.getTaskType() == 2) { |
| | | //问卷 |
| | | wjHandle(commonTaskcallMQ, ip); |
| | | } else if (commonTaskcallMQ.getTaskType() == 3) { |
| | | //宣教 |
| | | xjHandle(commonTaskcallMQ, ip); |
| | | } |
| | | //处理完成,移除redis |
| | | redisCache.deleteObject(message.toString()); |
| | | |
| | | } catch (Exception e) { |
| | | Integer integer = redisCache.getCacheObject(commonTaskcallMQ.getTaskid().toString()); |
| | | if (integer != null && integer == 2) { |
| | | //将消息从队列中删除 |
| | | } else if (integer == null) { |
| | | redisCache.setCacheObject(commonTaskcallMQ.getTaskid().toString(), 1, 120, TimeUnit.MINUTES); |
| | | } else { |
| | | redisCache.setCacheObject(commonTaskcallMQ.getTaskid().toString(), integer + 1, 120, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | log.error("============消费失败,尝试消息补发再次消费!============== {}", e.getMessage()); |
| | | redisCache.setCacheObject(message.toString(), message.toString(), 60, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + ivrTask1.getTaskid().toString() + "¶m2=" + serviceSubtask.getPatid().toString() + "¶m3=" + ivrTask1.getTaskName()); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + ivrTask1.getTaskid().toString() + "¶m2=" + serviceSubtask.getPatid().toString() + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(svyTaskSingle1.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName()); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |