use of org.redisson.api.RTopic in project redisson by redisson.
the class QueueTransferTask method start.
public void start() {
RTopic schedulerTopic = getTopic();
statusListenerId = schedulerTopic.addListener(new BaseStatusListener() {
@Override
public void onSubscribe(String channel) {
pushTask();
}
});
messageListenerId = schedulerTopic.addListener(Long.class, new MessageListener<Long>() {
@Override
public void onMessage(CharSequence channel, Long startTime) {
scheduleTask(startTime);
}
});
}
use of org.redisson.api.RTopic in project redisson by redisson.
the class QueueTransferTask method stop.
public void stop() {
RTopic schedulerTopic = getTopic();
schedulerTopic.removeListener(messageListenerId);
schedulerTopic.removeListener(statusListenerId);
}
use of org.redisson.api.RTopic in project redisson by redisson.
the class TimeoutTest method testPubSub.
// @Test
public void testPubSub() throws InterruptedException, ExecutionException {
RTopic topic = redisson.getTopic("simple");
topic.addListener(String.class, new MessageListener<String>() {
@Override
public void onMessage(CharSequence channel, String msg) {
System.out.println("msg: " + msg);
}
});
for (int i = 0; i < 100; i++) {
Thread.sleep(1000);
topic.publish("test" + i);
}
}
use of org.redisson.api.RTopic in project netty-socketio by mrniko.
the class RedissonPubSubStore method unsubscribe.
@Override
public void unsubscribe(PubSubType type) {
String name = type.toString();
Queue<Integer> regIds = map.remove(name);
RTopic topic = redissonSub.getTopic(name);
for (Integer id : regIds) {
topic.removeListener(id);
}
}
use of org.redisson.api.RTopic in project redisson by redisson.
the class RedissonSessionManager method stopInternal.
@Override
protected void stopInternal() throws LifecycleException {
super.stopInternal();
setState(LifecycleState.STOPPING);
Pipeline pipeline = getContext().getPipeline();
synchronized (pipeline) {
if (readMode == ReadMode.REDIS) {
Arrays.stream(pipeline.getValves()).filter(v -> v.getClass() == UsageValve.class).forEach(v -> {
if (((UsageValve) v).decUsage() == 0) {
pipeline.removeValve(v);
}
});
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
Arrays.stream(pipeline.getValves()).filter(v -> v.getClass() == UpdateValve.class).forEach(v -> {
if (((UpdateValve) v).decUsage() == 0) {
pipeline.removeValve(v);
}
});
}
}
if (messageListener != null) {
RTopic updatesTopic = getTopic();
updatesTopic.removeListener(messageListener);
}
codecToUse = null;
try {
shutdownRedisson();
} catch (Exception e) {
throw new LifecycleException(e);
}
}
Aggregations