//package com.yihu.wlyy.redis; // //import com.yihu.wlyy.service.app.prescription.PrescriptionService; //import com.yihu.wlyy.util.SystemConf; //import org.apache.commons.lang3.StringUtils; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Value; //import org.springframework.data.redis.core.StringRedisTemplate; //import org.springframework.stereotype.Component; // ///** // * Created by Trick on 2017/8/7. // */ //@Component //public class RedisThread implements Runnable { // // @Value("${spring.redis.host}") // private String url; // @Autowired // private RedisMsgPubSubListener redisMsgPubSubListener; // @Autowired // private StringRedisTemplate redisTemplate; // @Autowired // private PrescriptionService prescriptionService; // // @Override // public void run() { // String key = SystemConf.getInstance().getSystemProperties().getProperty("redisMessage"); // while (true){ // redisTemplate.watch(key); // String message = redisTemplate.opsForList().rightPop(key); // redisTemplate.unwatch(); // if(StringUtils.isEmpty(message)){ // try{ // Thread.sleep(1000L);//如果没有读取到记录,等待1秒 // }catch (Exception e){ // e.printStackTrace(); // } // }else { // prescriptionService.redisMessage(message); // } // } // } //}