| | |
| | | import org.springframework.data.redis.connection.Message; |
| | | import org.springframework.data.redis.connection.MessageListener; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | public RedisRpcResponse request(RedisRpcRequest request, int timeOut) { |
| | | request.setSn((long) random.nextInt(1000) + 1); |
| | | SynchronousQueue<RedisRpcResponse> subscribe = subscribe(request.getSn()); |
| | | |
| | | try { |
| | | sendRequest(request); |
| | | return subscribe.poll(timeOut, TimeUnit.SECONDS); |
| | |
| | | public int getCallbackCount(){ |
| | | return callbacks.size(); |
| | | } |
| | | |
| | | @Scheduled(fixedRate = 1000) //每1秒执行一次 |
| | | public void execute(){ |
| | | System.out.println("callbacks的长度: " + callbacks.size()); |
| | | System.out.println("队列的长度: " + topicSubscribers.size()); |
| | | } |
| | | } |