1234567891011121314151617181920212223242526 |
- package com.greentech.gateservice.redis;
- import redis.clients.jedis.Jedis;
- import redis.clients.jedis.JedisPool;
- public class SubThread extends Thread{
- private final JedisPool jedisPool;
- private final Subscriber subscriber = new Subscriber();
- public SubThread(JedisPool jedisPool) {
- this.jedisPool = jedisPool;
- }
- @Override
- public void run() {
- try (Jedis jedis = jedisPool.getResource()) {
- String channel = "channel:ptz:92";
- jedis.subscribe(subscriber, channel);
- } catch (Exception e) {
- System.out.printf("subscriber channel error, %s%n\n", e);
- }
- }
- }
|