|
|
@ -7,10 +7,28 @@ import java.util.List;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import org.redisson.core.MessageListener;
|
|
|
|
import org.redisson.core.RMap;
|
|
|
|
import org.redisson.core.RMap;
|
|
|
|
|
|
|
|
import org.redisson.core.RTopic;
|
|
|
|
|
|
|
|
|
|
|
|
public class TimeoutTest extends BaseTest {
|
|
|
|
public class TimeoutTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
|
|
|
|
public void testPubSub() throws InterruptedException, ExecutionException {
|
|
|
|
|
|
|
|
RTopic<String> topic = redisson.getTopic("simple");
|
|
|
|
|
|
|
|
topic.addListener(new MessageListener<String>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onMessage(String channel, String msg) {
|
|
|
|
|
|
|
|
System.out.println("msg: " + msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
|
|
|
topic.publish("test" + i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
// @Test
|
|
|
|
public void testReplaceTimeout() throws InterruptedException, ExecutionException {
|
|
|
|
public void testReplaceTimeout() throws InterruptedException, ExecutionException {
|
|
|
|
RMap<Integer, Integer> map = redisson.getMap("simple");
|
|
|
|
RMap<Integer, Integer> map = redisson.getMap("simple");
|
|
|
|