当前位置: 首页>>代码示例>>Java>>正文


Java BinaryJedisPubSub类代码示例

本文整理汇总了Java中redis.clients.jedis.BinaryJedisPubSub的典型用法代码示例。如果您正苦于以下问题:Java BinaryJedisPubSub类的具体用法?Java BinaryJedisPubSub怎么用?Java BinaryJedisPubSub使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BinaryJedisPubSub类属于redis.clients.jedis包,在下文中一共展示了BinaryJedisPubSub类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RedisPubSubSync

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
public RedisPubSubSync(final CacheTemplate cacheTemplate) {
    this.cacheTemplate = cacheTemplate;
    this.cacheSyncHandler = new CacheSyncHandler(this.cacheTemplate);
    this.jedisTemplate = cacheTemplate.getJedisTemplate();

    new Thread(new Runnable() {
        @Override
        public void run() {
            jedisTemplate.subscribe(new BinaryJedisPubSub() {
                @Override
                public void onMessage(byte[] channel, byte[] message) {
                    Command cmd = jedisTemplate.deserializeVal(message);
                    if (cmd != null) {
                        if ((cmd.src != null && !cmd.src.equals(Cache.ID)) || cmd.oper == Command.OPT_FETCH) {
                            logger.debug("recieve from " + cmd.src + " > " + cmd.toString());
                            cacheSyncHandler.handle(cmd);
                        }
                    }
                }
            }, Cache.CACHE_STORE_SYNC);
        }
    }, "RedisPubSubSync.Subscribe").start();
}
 
开发者ID:yrain,项目名称:smart-cache,代码行数:24,代码来源:RedisPubSubSync.java

示例2: JbootEhredisCacheImpl

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
public JbootEhredisCacheImpl() {
    this.ehcacheImpl = new JbootEhcacheImpl();
    this.ehcacheImpl.setCacheEventListener(this);

    this.redisCacheImpl = new JbootRedisCacheImpl();
    this.clientId = StringUtils.uuid();
    this.serializer = Jboot.me().getSerializer();

    this.redis = redisCacheImpl.getRedis();
    this.redis.subscribe(new BinaryJedisPubSub() {
        @Override
        public void onMessage(byte[] channel, byte[] message) {
            JbootEhredisCacheImpl.this.onMessage((String) serializer.deserialize(channel), serializer.deserialize(message));
        }
    }, serializer.serialize(channel));
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:17,代码来源:JbootEhredisCacheImpl.java

示例3: createClosureExSet

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
protected ClosureExSet createClosureExSet(final Object event) {
	ClosureExSet set = super.createClosureExSet(event);

	new Thread(new Runnable() {
		@Override
		public void run() {
			// 这里会阻塞
			// TODO 是否需要把 BinaryJedisPubSub 缓存?做unsubscribe操作
			jedisCluster.subscribe(new BinaryJedisPubSub() {
				@Override
				public void onMessage(byte[] channel, byte[] message) {
					Object evt = deserialize(channel);
					Object[] args = deserialize(message);
					// 这里一定要call父类的方法
					RedisEventBus.super.doFireEvent(evt, args);
				}
			}, serialize(event));
		}
	}, "RedisSubscriber" + threadIndex.incrementAndGet() + "-thread-").start();

	return set;
}
 
开发者ID:5waynewang,项目名称:commons-jkit,代码行数:24,代码来源:RedisEventBus.java

示例4: subscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
public void subscribe(final BinaryJedisPubSub jedisPubSub, final String... channels) {
    if (cluster) {
        jedisCluster.subscribe(jedisPubSub, convertObjectArrayToByteArray_serializeKey(channels));
    } else {
        jedisOperator.subscribe(jedisPubSub, convertObjectArrayToByteArray_serializeKey(channels));
    }
}
 
开发者ID:yrain,项目名称:smart-cache,代码行数:8,代码来源:JedisTemplate.java

示例5: subscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
public void subscribe(final BinaryJedisPubSub jedisPubSub, final byte[]... channels) {
    execute(new JedisExecutor<Void>() {
        @Override
        Void doInJedis(Jedis jedis) {
            jedis.subscribe(jedisPubSub, channels);
            return null;
        }
    });
}
 
开发者ID:yrain,项目名称:smart-cache,代码行数:10,代码来源:JedisOperator.java

示例6: JbootRedismqImpl

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
public JbootRedismqImpl() {

        initChannels();

        JbootmqRedisConfig redisConfig = Jboot.config(JbootmqRedisConfig.class);
        if (redisConfig.isConfigOk()) {
            redis = JbootRedisManager.me().getRedis(redisConfig);
        } else {
            redis = Jboot.me().getRedis();
        }

        if (redis == null) {
            throw new JbootIllegalConfigException("can not use redis mq (redis mq is default), " +
                    "please config jboot.redis.host=yourhost and check your jboot.properties, " +
                    "or use other mq component. ");
        }

        Object[] channels = this.channels.toArray();

        redis.subscribe(new BinaryJedisPubSub() {
            @Override
            public void onMessage(byte[] channel, byte[] message) {
                notifyListeners(redis.bytesToKey(channel), Jboot.me().getSerializer().deserialize(message));
            }
        }, redis.keysToBytesArray(channels));

        dequeueThread = new Thread(this);
        dequeueThread.start();
    }
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:30,代码来源:JbootRedismqImpl.java

示例7: subscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
public void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels) {
  Span span = helper.buildSpan("subscribe");
  span.setTag("channels", Arrays.toString(channels));
  try {
    super.subscribe(jedisPubSub, channels);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:14,代码来源:TracingJedisCluster.java

示例8: psubscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns) {
  Span span = helper.buildSpan("psubscribe");
  span.setTag("patterns", Arrays.toString(patterns));
  try {
    super.psubscribe(jedisPubSub, patterns);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:14,代码来源:TracingJedisCluster.java

示例9: testPsubscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Test
public void testPsubscribe() {
  BinaryJedisPubSub listener = mock(BinaryJedisPubSub.class);
  RedisFacade.RedisPubSub facadeListener = mock(RedisFacade.RedisPubSub.class);
  when(facadeListener.getLinked()).thenReturn(listener);
  String pattern = "test";
  rf.psubscribe(facadeListener, pattern);
  ArgumentCaptor<BinaryJedisPubSub> capture = ArgumentCaptor.forClass(BinaryJedisPubSub.class);
  verify(facadeListener).link(capture.capture());
  verify(jedis).psubscribe(capture.getValue(), SafeEncoder.encode(pattern));
}
 
开发者ID:AmadeusITGroup,项目名称:HttpSessionReplacer,代码行数:12,代码来源:TestJedisPoolFacade.java

示例10: testPsubscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Test
public void testPsubscribe() {
  BinaryJedisPubSub listener = mock(BinaryJedisPubSub.class);
  RedisFacade.RedisPubSub facadeListener = mock(RedisFacade.RedisPubSub.class);
  when(facadeListener.getLinked()).thenReturn(listener);
  String pattern = "test";
  rf.psubscribe(facadeListener, pattern);
  ArgumentCaptor<BinaryJedisPubSub> capture = ArgumentCaptor.forClass(BinaryJedisPubSub.class);
  verify(facadeListener).link(capture.capture());
  verify(jedisCluster).psubscribe(capture.getValue(), SafeEncoder.encode(pattern));
}
 
开发者ID:AmadeusITGroup,项目名称:HttpSessionReplacer,代码行数:12,代码来源:TestJedisClusterFacade.java

示例11: subscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
public void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		delegate.subscribe(jedisPubSub, channels);
	} finally {
		pool.returnResource(delegate);
	}
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:10,代码来源:JedisAdapter.java

示例12: psubscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		delegate.psubscribe(jedisPubSub, patterns);
	} finally {
		pool.returnResource(delegate);
	}
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:10,代码来源:JedisAdapter.java

示例13: punsubscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
public void punsubscribe(final RedisPubSub listener, byte[] pattern) {
  ((BinaryJedisPubSub) listener.getLinked()).punsubscribe(pattern);
}
 
开发者ID:AmadeusITGroup,项目名称:HttpSessionReplacer,代码行数:5,代码来源:JedisPoolFacade.java

示例14: psubscribe

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
@Override
public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns) {
}
 
开发者ID:Inbot,项目名称:inbot-es-http-client,代码行数:4,代码来源:FakeJedis.java

示例15: createResultListener

import redis.clients.jedis.BinaryJedisPubSub; //导入依赖的package包/类
private BinaryJedisPubSub createResultListener() {
    JedisHelper.BinaryCallBackPubSub pubSub = new JedisHelper.BinaryCallBackPubSub();
    pubSub.addOnMessageListener(this::onMessage);
    return pubSub;
}
 
开发者ID:ULYSSIS-KUL,项目名称:ipp,代码行数:6,代码来源:CommandDispatcher.java


注:本文中的redis.clients.jedis.BinaryJedisPubSub类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。