Search in sources :

Example 1 with RTopic

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);
        }
    });
}
Also used : MessageListener(org.redisson.api.listener.MessageListener) BaseStatusListener(org.redisson.api.listener.BaseStatusListener) RTopic(org.redisson.api.RTopic)

Example 2 with RTopic

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);
}
Also used : RTopic(org.redisson.api.RTopic)

Example 3 with RTopic

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);
    }
}
Also used : RTopic(org.redisson.api.RTopic)

Example 4 with RTopic

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);
    }
}
Also used : RTopic(org.redisson.api.RTopic)

Example 5 with RTopic

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);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) java.util(java.util) Codec(org.redisson.client.codec.Codec) StringCodec(org.redisson.client.codec.StringCodec) ManagerBase(org.apache.catalina.session.ManagerBase) Config(org.redisson.config.Config) RTopic(org.redisson.api.RTopic) RSet(org.redisson.api.RSet) IOException(java.io.IOException) Log(org.apache.juli.logging.Log) LogFactory(org.apache.juli.logging.LogFactory) File(java.io.File) Redisson(org.redisson.Redisson) RMap(org.redisson.api.RMap) CompositeCodec(org.redisson.codec.CompositeCodec) org.apache.catalina(org.apache.catalina) RedissonClient(org.redisson.api.RedissonClient) MessageListener(org.redisson.api.listener.MessageListener) RTopic(org.redisson.api.RTopic) IOException(java.io.IOException)

Aggregations

RTopic (org.redisson.api.RTopic)10 RedissonClient (org.redisson.api.RedissonClient)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.jupiter.api.Test)3 RPatternTopic (org.redisson.api.RPatternTopic)3 MessageListener (org.redisson.api.listener.MessageListener)3 File (java.io.File)2 IOException (java.io.IOException)2 java.util (java.util)2 HttpSession (javax.servlet.http.HttpSession)2 org.apache.catalina (org.apache.catalina)2 ManagerBase (org.apache.catalina.session.ManagerBase)2 Log (org.apache.juli.logging.Log)2 LogFactory (org.apache.juli.logging.LogFactory)2 Redisson (org.redisson.Redisson)2 RMap (org.redisson.api.RMap)2 RSet (org.redisson.api.RSet)2 BasePatternStatusListener (org.redisson.api.listener.BasePatternStatusListener)2 Codec (org.redisson.client.codec.Codec)2 StringCodec (org.redisson.client.codec.StringCodec)2